Search in sources :

Example 1 with ArchaiusSpringPropertySource

use of com.kixeye.chassis.bootstrap.spring.ArchaiusSpringPropertySource in project chassis by Kixeye.

the class Application method createChildContext.

private void createChildContext() {
    if (appMetadata.isWebapp()) {
        applicationContext = new AnnotationConfigWebApplicationContext();
        if (appMetadata.getConfigurationClasses().length > 0) {
            ((AnnotationConfigWebApplicationContext) applicationContext).register(appMetadata.getConfigurationClasses());
        }
    } else {
        applicationContext = new AnnotationConfigApplicationContext();
        if (appMetadata.getConfigurationClasses().length > 0) {
            ((AnnotationConfigApplicationContext) applicationContext).register(appMetadata.getConfigurationClasses());
        }
    }
    applicationContext.setParent(bootstrapApplicationContext);
    applicationContext.getEnvironment().getPropertySources().addFirst(new ArchaiusSpringPropertySource(appMetadata.getName() + "-archaius"));
    PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
    configurer.setEnvironment(applicationContext.getEnvironment());
    applicationContext.addBeanFactoryPostProcessor(configurer);
    applicationContext.setId(appMetadata.getName());
    applicationContext.refresh();
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer) AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) ArchaiusSpringPropertySource(com.kixeye.chassis.bootstrap.spring.ArchaiusSpringPropertySource)

Aggregations

ArchaiusSpringPropertySource (com.kixeye.chassis.bootstrap.spring.ArchaiusSpringPropertySource)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 PropertySourcesPlaceholderConfigurer (org.springframework.context.support.PropertySourcesPlaceholderConfigurer)1 AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)1