Example usage for org.springframework.context.support PropertySourcesPlaceholderConfigurer setEnvironment

List of usage examples for org.springframework.context.support PropertySourcesPlaceholderConfigurer setEnvironment

Introduction

In this page you can find the example usage for org.springframework.context.support PropertySourcesPlaceholderConfigurer setEnvironment.

Prototype

@Override
public void setEnvironment(Environment environment) 

Source Link

Document

PropertySources from the given Environment will be searched when replacing ${...} placeholders.

Usage

From source file:net.bluewizardhat.tfa.web.config.PropertySourcesConfigurer.java

@Bean
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
    PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
    configurer.setEnvironment(env);
    return configurer;
}

From source file:io.gravitee.gateway.handlers.api.ApiContextHandlerFactory.java

AbstractApplicationContext createApplicationContext(Api api) {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.setParent(gatewayApplicationContext);
    context.setClassLoader(new ReactorHandlerClassLoader(gatewayApplicationContext.getClassLoader()));
    context.setEnvironment((ConfigurableEnvironment) gatewayApplicationContext.getEnvironment());

    PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
    configurer.setIgnoreUnresolvablePlaceholders(true);
    configurer.setEnvironment(gatewayApplicationContext.getEnvironment());
    context.addBeanFactoryPostProcessor(configurer);

    context.getBeanFactory().registerSingleton("api", api);
    context.register(ApiHandlerConfiguration.class);
    context.setId("context-api-" + api.getName());
    context.refresh();//from  w  w  w  . j  ava 2  s  .com

    return context;
}

From source file:com.kixeye.chassis.bootstrap.Application.java

private void createChildContext() {
    if (appMetadata.isWebapp()) {
        applicationContext = new AnnotationConfigWebApplicationContext();
        if (appMetadata.getConfigurationClasses().length > 0) {
            ((AnnotationConfigWebApplicationContext) applicationContext)
                    .register(appMetadata.getConfigurationClasses());
        }//from w  w w  .jav a  2 s. c  om
    } 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();
}

From source file:org.springframework.xd.module.CompositeModule.java

private void initContext() {
    Assert.state(context != null, "An ApplicationContext is required");
    boolean propertyConfigurerPresent = false;
    for (String name : context.getBeanDefinitionNames()) {
        if (name.startsWith("org.springframework.context.support.PropertySourcesPlaceholderConfigurer")) {
            propertyConfigurerPresent = true;
            break;
        }/*from w  w w .j a  va2  s  .  c  om*/
    }
    if (!propertyConfigurerPresent) {
        PropertySourcesPlaceholderConfigurer placeholderConfigurer = new PropertySourcesPlaceholderConfigurer();
        placeholderConfigurer.setEnvironment(context.getEnvironment());
        context.addBeanFactoryPostProcessor(placeholderConfigurer);
    }
    context.setId(this.toString());
    context.refresh();
}