Skip to content

Commit

Permalink
0001701: Re-add support for db.spring.bean.name. Also added web.xml i…
Browse files Browse the repository at this point in the history
…nit parameter to tell symmetric to look for and use a webapp's application context
  • Loading branch information
chenson42 committed Apr 30, 2014
1 parent e39e21c commit 272a4c6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
Expand Up @@ -163,14 +163,18 @@ protected SecurityServiceType getSecurityServiceType() {
@Override
protected void init() {
try {
super.init();

this.propertiesFactory = createTypedPropertiesFactory();

this.securityService = SecurityServiceFactory.create(getSecurityServiceType(), propertiesFactory.reload());
TypedProperties properties = this.propertiesFactory.reload();

PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
configurer.setProperties(parameterService.getAllParameters());

configurer.setProperties(properties);
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(springContext);
ctx.addBeanFactoryPostProcessor(configurer);

if (registerEngine) {
ctx.setConfigLocations(new String[] { "classpath:/symmetric-ext-points.xml",
"classpath:/symmetric-jmx.xml" });
Expand All @@ -180,6 +184,10 @@ protected void init() {
ctx.refresh();

this.springContext = ctx;

super.init();



this.dataSource = platform.getDataSource();

Expand Down Expand Up @@ -248,6 +256,7 @@ public static IDatabasePlatform createDatabasePlatform(ApplicationContext spring

String springBeanName = properties.getProperty(ParameterConstants.DB_SPRING_BEAN_NAME);
if (isNotBlank(springBeanName)) {
log.info("Using datasource from spring. The spring bean name is {}", springBeanName);
dataSource = (DataSource)springContext.getBean(springBeanName);
}

Expand Down
Expand Up @@ -247,14 +247,22 @@ public void setDeploymentType(String deploymentType) {
protected abstract SecurityServiceType getSecurityServiceType();

protected void init() {
this.propertiesFactory = createTypedPropertiesFactory();
this.securityService = SecurityServiceFactory.create(getSecurityServiceType(), propertiesFactory.reload());
if (propertiesFactory == null) {
this.propertiesFactory = createTypedPropertiesFactory();
}

if (securityService == null) {
this.securityService = SecurityServiceFactory.create(getSecurityServiceType(),
propertiesFactory.reload());
}

TypedProperties properties = this.propertiesFactory.reload();

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"));

MDC.put("engineName", this.parameterService.getEngineName());
ParameterConstants.RUNTIME_CONFIG_TABLE_PREFIX, "sym"));

this.platform.setMetadataIgnoreCase(this.parameterService
.is(ParameterConstants.DB_METADATA_IGNORE_CASE));
Expand Down

0 comments on commit 272a4c6

Please sign in to comment.