Search in sources :

Example 6 with PropertySourcesPlaceholderConfigurer

use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project gravitee-gateway by gravitee-io.

the class EnvironmentConfiguration method properties.

@Bean
public static PropertySourcesPlaceholderConfigurer properties(@Qualifier("graviteeProperties") Properties graviteeProperties) {
    PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
    propertySourcesPlaceholderConfigurer.setProperties(graviteeProperties);
    propertySourcesPlaceholderConfigurer.setIgnoreUnresolvablePlaceholders(true);
    return propertySourcesPlaceholderConfigurer;
}
Also used : PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer) Bean(org.springframework.context.annotation.Bean)

Example 7 with PropertySourcesPlaceholderConfigurer

use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project gravitee-gateway by gravitee-io.

the class ApiContextHandlerFactory method createApplicationContext.

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.getId());
    context.refresh();
    return context;
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer)

Example 8 with PropertySourcesPlaceholderConfigurer

use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project alien4cloud by alien4cloud.

the class Bootstrap method placeHolderConfigurer.

@Bean
public static PropertySourcesPlaceholderConfigurer placeHolderConfigurer() {
    PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
    // this to avoid errors when properties are not resolvable
    // beans should use default value syntax to verify that the property exists
    // @Value("${some.key:#{null}}")
    configurer.setIgnoreUnresolvablePlaceholders(true);
    return configurer;
}
Also used : PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer) YamlPropertiesFactoryBean(org.springframework.beans.factory.config.YamlPropertiesFactoryBean) ServletRegistrationBean(org.springframework.boot.web.servlet.ServletRegistrationBean) Bean(org.springframework.context.annotation.Bean)

Example 9 with PropertySourcesPlaceholderConfigurer

use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project Asqatasun by Asqatasun.

the class AsqatasunTestConfig method propertySourcesPlaceholderConfigurer.

@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
    PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
    YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
    yaml.setResources(new ClassPathResource("application-test.yml"));
    propertySourcesPlaceholderConfigurer.setProperties(yaml.getObject());
    return propertySourcesPlaceholderConfigurer;
}
Also used : YamlPropertiesFactoryBean(org.springframework.beans.factory.config.YamlPropertiesFactoryBean) PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer) ClassPathResource(org.springframework.core.io.ClassPathResource) YamlPropertiesFactoryBean(org.springframework.beans.factory.config.YamlPropertiesFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 10 with PropertySourcesPlaceholderConfigurer

use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project spring-boot by spring-projects.

the class PropertySourcesDeducer method getPropertySources.

PropertySources getPropertySources() {
    PropertySourcesPlaceholderConfigurer configurer = getSinglePropertySourcesPlaceholderConfigurer();
    if (configurer != null) {
        return configurer.getAppliedPropertySources();
    }
    MutablePropertySources sources = extractEnvironmentPropertySources();
    Assert.state(sources != null, "Unable to obtain PropertySources from PropertySourcesPlaceholderConfigurer or Environment");
    return sources;
}
Also used : PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer) MutablePropertySources(org.springframework.core.env.MutablePropertySources)

Aggregations

PropertySourcesPlaceholderConfigurer (org.springframework.context.support.PropertySourcesPlaceholderConfigurer)29 Bean (org.springframework.context.annotation.Bean)18 ClassPathResource (org.springframework.core.io.ClassPathResource)7 Properties (java.util.Properties)5 YamlPropertiesFactoryBean (org.springframework.beans.factory.config.YamlPropertiesFactoryBean)4 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)3 Resource (org.springframework.core.io.Resource)3 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)2 MutablePropertySources (org.springframework.core.env.MutablePropertySources)2 FileSystemResource (org.springframework.core.io.FileSystemResource)2 JndiPropertySource (org.springframework.jndi.JndiPropertySource)2 ArchaiusSpringPropertySource (com.kixeye.chassis.bootstrap.spring.ArchaiusSpringPropertySource)1 SpringEnvironmentProperties (com.thinkbiganalytics.spring.SpringEnvironmentProperties)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintWriter (java.io.PrintWriter)1 lombok.val (lombok.val)1 CasServerProperties (org.apereo.cas.configuration.model.core.CasServerProperties)1 ReloadablePropertySource (org.finra.herd.dao.ReloadablePropertySource)1 Test (org.junit.jupiter.api.Test)1 MutablePropertyValues (org.springframework.beans.MutablePropertyValues)1