use of org.exoplatform.container.configuration.ConfigurationManagerImpl in project kernel by exoplatform.
the class RootContainer method loadConfigurationManager.
/**
* @param rootContainer
* @return
* @throws Exception
*/
private static ConfigurationManager loadConfigurationManager(RootContainer rootContainer, boolean logEnabled) throws Exception {
final ConfigurationManagerImpl service = new ConfigurationManagerImpl(rootContainer.profiles, logEnabled);
service.addConfiguration(ContainerUtil.getConfigurationURL("conf/configuration.xml"));
if (System.getProperty("maven.exoplatform.dir") != null) {
service.addConfiguration(ContainerUtil.getConfigurationURL("conf/test-configuration.xml"));
}
J2EEServerInfo serverEnv = rootContainer.getServerEnvironment();
service.addConfiguration(Archive.getConfigurationURL(serverEnv.getApplicationDeployDirectories(), serverEnv.getApplicationDeployArchives(), "META-INF/exo-conf/configuration.xml"));
String confDir = serverEnv.getExoConfigurationDirectory();
String overrideConf = confDir + "/configuration.xml";
File file = new File(overrideConf);
if (PrivilegedFileHelper.exists(file)) {
service.addConfiguration("file:" + overrideConf);
}
service.processRemoveConfiguration();
if (PropertyManager.isDevelopping()) {
Configuration conf = service.getConfiguration();
if (conf != null) {
conf.keepCurrentState();
}
}
return service;
}
use of org.exoplatform.container.configuration.ConfigurationManagerImpl in project kernel by exoplatform.
the class TestPropertyManagerConfigurator method testFromXML.
public void testFromXML() throws Exception {
reset();
URL propertiesURL = TestPropertyManagerConfigurator.class.getResource("property-configurator.xml");
assertNotNull(propertiesURL);
System.setProperty(PropertyManager.PROPERTIES_URL, propertiesURL.toString());
System.setProperty("property_2", "property_value_2");
PropertiesParam propertiesParam = new PropertiesParam();
InitParams params = new InitParams();
params.put("properties", propertiesParam);
new PropertyConfigurator(params, new ConfigurationManagerImpl(new HashSet<String>()));
Map<String, String> additions = reset();
assertEquals("property_value_1", additions.get("property_1"));
assertEquals("property_value_2", additions.get("property_2"));
assertEquals("${property_3}", additions.get("property_3"));
assertEquals("property_value_1-property_value_2", additions.get("property_4"));
}
use of org.exoplatform.container.configuration.ConfigurationManagerImpl in project kernel by exoplatform.
the class TestPropertyManagerConfigurator method testFromPropertiesByParam.
public void testFromPropertiesByParam() throws Exception {
reset();
URL propertiesURL = TestPropertyManagerConfigurator.class.getResource("property-configurator.properties");
assertNotNull(propertiesURL);
System.setProperty("property_2", "property_value_2");
ValueParam propertiesPathParam = new ValueParam();
propertiesPathParam.setName("properties.url");
propertiesPathParam.setValue(propertiesURL.toString());
InitParams params = new InitParams();
params.put("properties.url", propertiesPathParam);
new PropertyConfigurator(params, new ConfigurationManagerImpl(new HashSet<String>()));
Map<String, String> additions = reset();
assertEquals("property_value_1", additions.get("property_1"));
assertEquals("property_value_2", additions.get("property_2"));
assertEquals("${property_3}", additions.get("property_3"));
assertEquals("property_value_1-property_value_2", additions.get("property_4"));
}
use of org.exoplatform.container.configuration.ConfigurationManagerImpl in project kernel by exoplatform.
the class TestTemplateConfigurationHelper method testTemplating.
public void testTemplating() throws IOException {
TemplateConfigurationHelper helper = new TemplateConfigurationHelper(new String[] { "^foo-.*", "^jgroups-configuration" }, new String[] { "^foo-configuration" }, new ConfigurationManagerImpl());
String template = "configuration in any format, containing ${foo-template-variable} and many others";
String expectedConfig = "configuration in any format, containing pretty good parameter and many others";
InputStream templateStream = new ByteArrayInputStream(template.getBytes());
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("foo-template-variable", "pretty good parameter");
InputStream configStream = helper.fillTemplate(templateStream, parameters);
String config = Utils.readStream(configStream);
assertTrue(expectedConfig.equals(config));
}
use of org.exoplatform.container.configuration.ConfigurationManagerImpl in project kernel by exoplatform.
the class TestTemplateConfigurationHelper method testFilters2.
public void testFilters2() {
// create helper with predefined include and exclude patterns
TemplateConfigurationHelper helper = new TemplateConfigurationHelper(new String[] { "^foo-.*", "^jgroups-configuration" }, new String[] { "^foo-configuration" }, new ConfigurationManagerImpl());
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("jgroups-configuration", "");
parameters.put("foo-cache.loader", "");
parameters.put("foo-clustername", "");
parameters.put("max-volatile-size", "");
Map<String, String> preparedParameters = helper.prepareParameters(parameters);
assertEquals(3, preparedParameters.size());
// "foo-configuration" and "max-volatile-size" should be excluded
assertFalse(preparedParameters.containsKey("${max-volatile-size}"));
assertTrue(preparedParameters.containsKey("${foo-cache.loader}"));
assertTrue(preparedParameters.containsKey("${foo-clustername}"));
}
Aggregations