Search in sources :

Example 11 with PropertyPlaceholderConfigurer

use of org.springframework.beans.factory.config.PropertyPlaceholderConfigurer in project spring-framework by spring-projects.

the class FormattingConversionServiceTests method formatFieldForAnnotationWithPlaceholdersAndFactoryBean.

@Test
@SuppressWarnings("resource")
public void formatFieldForAnnotationWithPlaceholdersAndFactoryBean() throws Exception {
    GenericApplicationContext context = new GenericApplicationContext();
    PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
    Properties props = new Properties();
    props.setProperty("dateStyle", "S-");
    props.setProperty("datePattern", "M-d-yy");
    ppc.setProperties(props);
    context.registerBeanDefinition("formattingService", new RootBeanDefinition(FormattingConversionServiceFactoryBean.class));
    context.getBeanFactory().registerSingleton("ppc", ppc);
    context.refresh();
    formattingService = context.getBean("formattingService", FormattingConversionService.class);
    doTestFormatFieldForAnnotation(ModelWithPlaceholders.class, false);
}
Also used : PropertyPlaceholderConfigurer(org.springframework.beans.factory.config.PropertyPlaceholderConfigurer) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) Properties(java.util.Properties) Test(org.junit.Test)

Example 12 with PropertyPlaceholderConfigurer

use of org.springframework.beans.factory.config.PropertyPlaceholderConfigurer in project jaffa-framework by jaffa-projects.

the class PropertyPlaceholderConfig method conversionService.

/**
 * Load the properties files used in application contexts here
 *
 * @return the initialized instance of the PropertyPlaceholderConfigurer class
 */
@Bean(name = "properties")
@Scope(BeanDefinition.SCOPE_SINGLETON)
public PropertyPlaceholderConfigurer conversionService() {
    PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
    Resource resource1 = new ClassPathResource("application_file_1.properties");
    Resource resource2 = new ClassPathResource("application_file_2.properties");
    configurer.setLocations(resource1, resource2);
    return configurer;
}
Also used : PropertyPlaceholderConfigurer(org.springframework.beans.factory.config.PropertyPlaceholderConfigurer) ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) ClassPathResource(org.springframework.core.io.ClassPathResource) Scope(org.springframework.context.annotation.Scope) Bean(org.springframework.context.annotation.Bean)

Example 13 with PropertyPlaceholderConfigurer

use of org.springframework.beans.factory.config.PropertyPlaceholderConfigurer in project kylo by Teradata.

the class DefaultConfiguration method createConfiguration.

private ConfigurableListableBeanFactory createConfiguration(String location) {
    DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
    Resource[] resources = new FileSystemResource[] { new FileSystemResource(location) };
    PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
    ppc.setLocations(resources);
    ppc.setIgnoreUnresolvablePlaceholders(true);
    ppc.setSearchSystemEnvironment(false);
    ppc.postProcessBeanFactory(factory);
    return factory;
}
Also used : PropertyPlaceholderConfigurer(org.springframework.beans.factory.config.PropertyPlaceholderConfigurer) DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) FileSystemResource(org.springframework.core.io.FileSystemResource) Resource(org.springframework.core.io.Resource) FileSystemResource(org.springframework.core.io.FileSystemResource)

Example 14 with PropertyPlaceholderConfigurer

use of org.springframework.beans.factory.config.PropertyPlaceholderConfigurer in project kylo by Teradata.

the class TestConfiguration method jiraPropertiesConfigurer.

@Bean
public PropertyPlaceholderConfigurer jiraPropertiesConfigurer() {
    PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
    configurer.setLocations(new ClassPathResource("/conf/sla.email.properties"));
    configurer.setIgnoreUnresolvablePlaceholders(true);
    configurer.setIgnoreResourceNotFound(true);
    return configurer;
}
Also used : PropertyPlaceholderConfigurer(org.springframework.beans.factory.config.PropertyPlaceholderConfigurer) ClassPathResource(org.springframework.core.io.ClassPathResource) Bean(org.springframework.context.annotation.Bean)

Example 15 with PropertyPlaceholderConfigurer

use of org.springframework.beans.factory.config.PropertyPlaceholderConfigurer in project kylo by Teradata.

the class DeveloperJiraConfiguration method jiraPropertiesConfigurer.

@Bean(name = "jiraProperties")
public PropertyPlaceholderConfigurer jiraPropertiesConfigurer() {
    PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
    configurer.setLocations(new ClassPathResource("/conf/jira.properties"));
    configurer.setIgnoreUnresolvablePlaceholders(true);
    configurer.setIgnoreResourceNotFound(true);
    return configurer;
}
Also used : PropertyPlaceholderConfigurer(org.springframework.beans.factory.config.PropertyPlaceholderConfigurer) ClassPathResource(org.springframework.core.io.ClassPathResource) Bean(org.springframework.context.annotation.Bean)

Aggregations

PropertyPlaceholderConfigurer (org.springframework.beans.factory.config.PropertyPlaceholderConfigurer)19 Bean (org.springframework.context.annotation.Bean)12 ClassPathResource (org.springframework.core.io.ClassPathResource)8 Properties (java.util.Properties)6 Resource (org.springframework.core.io.Resource)4 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)3 Test (org.junit.Test)2 DisconfMgrBean (com.baidu.disconf.client.DisconfMgrBean)1 ReloadablePropertiesFactoryBean (com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean)1 ReloadingPropertyPlaceholderConfigurer (com.baidu.disconf.client.addons.properties.ReloadingPropertyPlaceholderConfigurer)1 SpringPropertyInjectSupport (com.jim.framework.configcenter.spring.SpringPropertyInjectSupport)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 PrintWriter (java.io.PrintWriter)1 StringReader (java.io.StringReader)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1