Search in sources :

Example 1 with ConfigurationBuilder

use of com.kixeye.chassis.bootstrap.configuration.ConfigurationBuilder in project chassis by Kixeye.

the class BootstrapConfiguration method applicationConfiguration.

@Bean
@SuppressWarnings("resource")
public AbstractConfiguration applicationConfiguration() throws ClassNotFoundException {
    AppMetadata appMetadata = appMetadata();
    ServerInstanceContext serverInstanceContext = serverInstanceContext();
    if (appEnvironment == null && serverInstanceContext != null) {
        appEnvironment = serverInstanceContext.getEnvironment();
    }
    ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(appMetadata.getName(), appEnvironment, addSystemConfigs, reflections());
    configurationBuilder.withConfigurationProvider(configurationProvider());
    configurationBuilder.withServerInstanceContext(serverInstanceContext());
    configurationBuilder.withApplicationProperties(appMetadata.getPropertiesResourceLocation());
    configurationBuilder.withScanModuleConfigurations(scanModuleConfigurations);
    configurationBuilder.withAppVersion(appMetadata.getDeclaringClass().getPackage().getImplementationVersion());
    AbstractConfiguration configuration = configurationBuilder.build();
    if (serverInstanceContext != null) {
        serverInstanceContext.setAppName(appMetadata.getName());
        serverInstanceContext.setVersion(configuration.getString(BootstrapConfigKeys.APP_VERSION_KEY.getPropertyName()));
    }
    return configuration;
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) ConfigurationBuilder(com.kixeye.chassis.bootstrap.configuration.ConfigurationBuilder) ServerInstanceContext(com.kixeye.chassis.bootstrap.aws.ServerInstanceContext) Bean(org.springframework.context.annotation.Bean)

Example 2 with ConfigurationBuilder

use of com.kixeye.chassis.bootstrap.configuration.ConfigurationBuilder in project chassis by Kixeye.

the class ConfigurationBuilderTest method setup.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Before
public void setup() throws Exception {
    initializeZookeeper();
    configurationBuilder = new ConfigurationBuilder(APP_NAME, ENVIRONMENT, true, BootstrapConfiguration.REFLECTIONS);
    configurationBuilder.withAppVersion(APP_VERSION);
    TestUtils.resetArchaius();
    resetZookeeper();
    TestUtils.writePropertiesToFile(TEST_MODULE_CONFIG_PROPERTIES, filesCreated, new SimpleEntry[] { new SimpleEntry(MODULE_1_KEY_1, MODULE_1_VALUE_1), new SimpleEntry(MODULE_1_KEY_2, MODULE_1_VALUE_2), new SimpleEntry(MODULE_1_KEY_3, MODULE_1_VALUE_3) });
    TestUtils.writePropertiesToFile(TEST_MODULE_CONFIG_PROPERTIES_2, filesCreated, new SimpleEntry(MODULE_2_KEY_1, MODULE_2_VALUE_1));
}
Also used : ConfigurationBuilder(com.kixeye.chassis.bootstrap.configuration.ConfigurationBuilder) SimpleEntry(java.util.AbstractMap.SimpleEntry) Before(org.junit.Before)

Aggregations

ConfigurationBuilder (com.kixeye.chassis.bootstrap.configuration.ConfigurationBuilder)2 ServerInstanceContext (com.kixeye.chassis.bootstrap.aws.ServerInstanceContext)1 SimpleEntry (java.util.AbstractMap.SimpleEntry)1 AbstractConfiguration (org.apache.commons.configuration.AbstractConfiguration)1 Before (org.junit.Before)1 Bean (org.springframework.context.annotation.Bean)1