Search in sources :

Example 21 with PropertySourcesPlaceholderConfigurer

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

the class FullApplicationConfiguration method properties.

@Bean
public static PropertySourcesPlaceholderConfigurer properties(ResourceLoader resourceLoader) {
    PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
    YamlPropertiesFactoryBean yaml = AlienYamlPropertiesFactoryBeanFactory.get(resourceLoader);
    propertySourcesPlaceholderConfigurer.setProperties(yaml.getObject());
    return propertySourcesPlaceholderConfigurer;
}
Also used : YamlPropertiesFactoryBean(org.springframework.beans.factory.config.YamlPropertiesFactoryBean) PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer) YamlPropertiesFactoryBean(org.springframework.beans.factory.config.YamlPropertiesFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 22 with PropertySourcesPlaceholderConfigurer

use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project cas by apereo.

the class BeanDefinitionStoreFailureAnalyzerTests method createFailure.

private BeanDefinitionStoreException createFailure() {
    val bf = new DefaultListableBeanFactory();
    bf.registerBeanDefinition("testBean", genericBeanDefinition(CasServerProperties.class).addPropertyValue("name", "${not.defined}").getBeanDefinition());
    val ppc = new PropertySourcesPlaceholderConfigurer();
    try {
        ppc.postProcessBeanFactory(bf);
    } catch (final BeanDefinitionStoreException e) {
        return e;
    }
    return null;
}
Also used : lombok.val(lombok.val) CasServerProperties(org.apereo.cas.configuration.model.core.CasServerProperties) BeanDefinitionStoreException(org.springframework.beans.factory.BeanDefinitionStoreException) DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer)

Example 23 with PropertySourcesPlaceholderConfigurer

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

the class PersistenceConfigTest 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 24 with PropertySourcesPlaceholderConfigurer

use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer 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)

Example 25 with PropertySourcesPlaceholderConfigurer

use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project chassis by Kixeye.

the class BootstrapConfiguration method propertySourcesPlaceHolderConfigurer.

@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceHolderConfigurer() {
    PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
    propertySourcesPlaceholderConfigurer.setNullValue("null");
    return propertySourcesPlaceholderConfigurer;
}
Also used : PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer) Bean(org.springframework.context.annotation.Bean)

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