Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
0001875: Add extensions.xml property which can be used to configure s…
…ymmetric extensions (like jms) via database configuration
  • Loading branch information
chenson42 committed Aug 10, 2014
1 parent f56d0fc commit 357c476
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
Expand Up @@ -187,16 +187,17 @@ protected void init() {
}

String xml = parameterService.getString(ParameterConstants.EXTENSIONS_XML);
File file = new File(parameterService.getTempDirectory(), "extension.xml");
FileUtils.deleteQuietly(file);
if (isNotBlank(xml)) {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
// the "parse" method also validates XML, will throw an exception if misformatted
builder.parse(new InputSource(new StringReader(xml)));
File file = new File(parameterService.getTempDirectory(), "extension.xml");
FileUtils.write(file, xml);
builder.parse(new InputSource(new StringReader(xml)));
FileUtils.write(file, xml, false);
extensionLocations.add("file:" + file.getAbsolutePath());
} catch (Exception e) {
log.error("Invalid " + ParameterConstants.EXTENSIONS_XML + " parameter.");
Expand Down
Expand Up @@ -264,9 +264,17 @@ protected void init() {
MDC.put("engineName", properties.get(ParameterConstants.ENGINE_NAME));

this.platform = createDatabasePlatform(properties);
this.parameterService = new ParameterService(platform, propertiesFactory, properties.get(
ParameterConstants.RUNTIME_CONFIG_TABLE_PREFIX, "sym"));


this.parameterService = new ParameterService(platform, propertiesFactory, properties.get(
ParameterConstants.RUNTIME_CONFIG_TABLE_PREFIX, "sym"));

boolean parameterTableExists = this.platform.getTableFromCache(TableConstants.getTableName(properties.get(ParameterConstants.RUNTIME_CONFIG_TABLE_PREFIX), TableConstants.SYM_PARAMETER), false) != null;
if (parameterTableExists) {
this.parameterService.setDatabaseHasBeenInitialized(true);
this.parameterService.rereadParameters();
}

this.platform.setMetadataIgnoreCase(this.parameterService
.is(ParameterConstants.DB_METADATA_IGNORE_CASE));
this.platform.setClearCacheModelTimeoutInMs(parameterService
Expand Down
Expand Up @@ -1368,8 +1368,11 @@ mssql.trigger.execute.as=caller
extensions.xml=<?xml version="1.0" encoding="UTF-8"?> \n\
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \n\u0020\u0020\u0020\u0020\
xmlns:context="http://www.springframework.org/schema/context" \n\u0020\u0020\u0020\u0020\
xmlns:util="http://www.springframework.org/schema/util" \n\u0020\u0020\u0020\u0020\
xsi:schemaLocation="http://www.springframework.org/schema/beans \n\u0020\u0020\u0020\u0020\
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd \n\u0020\u0020\u0020\u0020\
http://www.springframework.org/schema/util \n\u0020\u0020\u0020\u0020\
http://www.springframework.org/schema/util/spring-util-3.0.xsd \n\u0020\u0020\u0020\u0020\
http://www.springframework.org/schema/context \n\u0020\u0020\u0020\u0020\
http://www.springframework.org/schema/context/spring-context-3.0.xsd"> \n\
</beans>
Expand Up @@ -219,12 +219,15 @@ protected ISymmetricEngine create(String propertiesFile) {
engine = new ServerSymmetricEngine(propertiesFile != null ? new File(propertiesFile)
: null, springContext);
engine.setDeploymentType(deploymentType);
if (!engines.containsKey(engine.getEngineName())) {
engines.put(engine.getEngineName(), engine);
} else {
log.error(
"An engine with the name of {} was not started because an engine of the same name has already been started. Please set the engine.name property in the properties file to a unique name.",
engine.getEngineName());
synchronized (this) {
if (!engines.containsKey(engine.getEngineName())) {
engines.put(engine.getEngineName(), engine);
} else {
log.error(
"An engine with the name of {} was not started because an engine of the same name has already been started. Please set the engine.name property in the properties file to a unique name.",
engine.getEngineName());
}

}
return engine;
} catch (Exception e) {
Expand Down Expand Up @@ -419,12 +422,14 @@ public static Date getCreateTime() {
return createTime;
}

static int threadNumber = 0;

class EngineStarter extends Thread {

String propertiesFile;

public EngineStarter(String propertiesFile) {
super("symmetric-startup");
super("symmetric-engine-startup-"+threadNumber++);
this.propertiesFile = propertiesFile;
}

Expand Down
Expand Up @@ -80,7 +80,8 @@ public Map<String, ParameterMetaData> parse(String fileName) {
extraLine = true;
line = line.substring(0, line.length() - 1);
}
currentMetaData.setDefaultValue(currentMetaData.getDefaultValue() + "\n" + line);
line = StringEscapeUtils.unescapeJava(line);
currentMetaData.setDefaultValue(currentMetaData.getDefaultValue() + line);
}

if (!extraLine) {
Expand Down

0 comments on commit 357c476

Please sign in to comment.