From 80ea041e0240eb3d9291eb0d699bb09c90aaa2a9 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Fri, 23 Feb 2018 13:35:12 +0100 Subject: first untested unfactoring for Postgresql suppport The scheme of configuration DB changed, therefore this version is incompatible to 3.3.2 configuration --- .../configuration/config/ConfigurationProvider.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'id/ConfigWebTool/src/main') diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java index c5ae5065f..8aab7ef06 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java @@ -34,6 +34,7 @@ import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; +import java.util.ArrayList; import java.util.Properties; import java.util.Timer; import java.util.jar.Attributes; @@ -51,7 +52,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.AutowireCapableBeanFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.web.context.support.GenericWebApplicationContext; +import at.gv.egovernment.moa.id.commons.config.SpringProfileConstants; import at.gv.egovernment.moa.id.commons.db.NewConfigurationDBRead; import at.gv.egovernment.moa.id.commons.ex.MOAHttpProtocolSocketFactoryException; import at.gv.egovernment.moa.id.commons.utils.MOAHttpProtocolSocketFactory; @@ -93,6 +96,8 @@ public class ConfigurationProvider { private NewConfigurationDBRead deprecatedDBRead = null; private FileBasedUserConfiguration userManagement = null; + private ArrayList activeProfiles = new ArrayList(); + public static ConfigurationProvider getInstance() throws ConfigurationException { if (instance == null) { @@ -134,12 +139,24 @@ public class ConfigurationProvider { props.load(fis); fis.close(); + //initialize generic SpringContext to set profiles + GenericWebApplicationContext rootContext = new GenericWebApplicationContext(); + if (Boolean.valueOf(props.getProperty("configuration.database.byteBasedValues", "false"))) + activeProfiles.add(SpringProfileConstants.BYTEBASEDCONFIG); + + log.info("Activate SpingProfiles: " + activeProfiles.toString()); + for (String el: activeProfiles) + rootContext.getEnvironment().addActiveProfile(el); + + //initialize SpringContext context = new ClassPathXmlApplicationContext( new String[] { "configuration.beans.xml", "moaid.webgui.beans.xml", "moaid.migration.beans.xml", "moaid.configurationtool.beans.xml" - }); + }, rootContext); + + //Autowire beans in these context AutowireCapableBeanFactory acbFactory = context.getAutowireCapableBeanFactory(); acbFactory.autowireBean(this); -- cgit v1.2.3