use of org.jumpmind.symmetric.service.impl.ClientExtensionService in project symmetric-ds by JumpMind.
the class ClientSymmetricEngine method init.
@Override
protected void init() {
try {
LogSummaryAppenderUtils.registerLogSummaryAppender();
super.init();
this.dataSource = platform.getDataSource();
PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
configurer.setProperties(parameterService.getAllParameters());
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(springContext);
ctx.addBeanFactoryPostProcessor(configurer);
List<String> extensionLocations = new ArrayList<String>();
extensionLocations.add("classpath:/symmetric-ext-points.xml");
if (registerEngine) {
extensionLocations.add("classpath:/symmetric-jmx.xml");
}
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)));
FileUtils.write(file, xml, false);
extensionLocations.add("file:" + file.getAbsolutePath());
} catch (Exception e) {
log.error("Invalid " + ParameterConstants.EXTENSIONS_XML + " parameter.");
}
}
try {
ctx.setConfigLocations(extensionLocations.toArray(new String[extensionLocations.size()]));
ctx.refresh();
this.springContext = ctx;
((ClientExtensionService) this.extensionService).setSpringContext(springContext);
this.extensionService.refresh();
} catch (Exception ex) {
log.error("Failed to initialize the extension points. Please fix the problem and restart the server.", ex);
}
} catch (RuntimeException ex) {
destroy();
throw ex;
}
}
Aggregations