Search in sources :

Example 6 with PropertiesFactoryBean

use of org.springframework.beans.factory.config.PropertiesFactoryBean in project spring-integration by spring-projects.

the class StoredProcInvalidConfigsTests method bootStrap.

private ApplicationContext bootStrap(String configProperty) throws Exception {
    PropertiesFactoryBean pfb = new PropertiesFactoryBean();
    pfb.setLocation(new ClassPathResource("org/springframework/integration/jdbc/config/stored-proc-invalid-configs.properties"));
    pfb.afterPropertiesSet();
    Properties prop = pfb.getObject();
    StringBuilder buffer = new StringBuilder();
    buffer.append(prop.getProperty("xmlheaders")).append(prop.getProperty(configProperty)).append(prop.getProperty("xmlfooter"));
    ByteArrayInputStream stream = new ByteArrayInputStream(buffer.toString().getBytes());
    GenericApplicationContext ac = new GenericApplicationContext();
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(ac);
    reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
    reader.loadBeanDefinitions(new InputStreamResource(stream));
    ac.refresh();
    return ac;
}
Also used : GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) ByteArrayInputStream(java.io.ByteArrayInputStream) XmlBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader) PropertiesFactoryBean(org.springframework.beans.factory.config.PropertiesFactoryBean) Properties(java.util.Properties) ClassPathResource(org.springframework.core.io.ClassPathResource) InputStreamResource(org.springframework.core.io.InputStreamResource)

Example 7 with PropertiesFactoryBean

use of org.springframework.beans.factory.config.PropertiesFactoryBean in project GMM by Katharsas.

the class ApplicationConfiguration method config.

/**
 * Expose to <spring:eval expression="@config.getProperty(...)"  in jsps
 */
@Bean
public PropertiesFactoryBean config() {
    final PropertiesFactoryBean factory = new PropertiesFactoryBean();
    factory.setLocation(new ClassPathResource("meta.properties"));
    return factory;
}
Also used : PropertiesFactoryBean(org.springframework.beans.factory.config.PropertiesFactoryBean) ClassPathResource(org.springframework.core.io.ClassPathResource) PropertiesFactoryBean(org.springframework.beans.factory.config.PropertiesFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 8 with PropertiesFactoryBean

use of org.springframework.beans.factory.config.PropertiesFactoryBean in project onebusaway-application-modules by camsys.

the class PropertiesBeanPostProcessor method postProcessAfterInitialization.

public Object postProcessAfterInitialization(Object obj, String beanName) throws BeansException {
    if (_properties != null && _targets.contains(beanName)) {
        if (obj instanceof Properties) {
            Properties properties = (Properties) obj;
            properties.putAll(_properties);
        } else if (obj instanceof PropertiesFactoryBean) {
            PropertiesFactoryBean factory = (PropertiesFactoryBean) obj;
            System.out.println(factory);
        }
    }
    return obj;
}
Also used : PropertiesFactoryBean(org.springframework.beans.factory.config.PropertiesFactoryBean) Properties(java.util.Properties)

Example 9 with PropertiesFactoryBean

use of org.springframework.beans.factory.config.PropertiesFactoryBean in project TranslateIt-api by zunpiau.

the class DataConfig method jdbcProperties.

@Bean(name = "jdbcProperties")
public PropertiesFactoryBean jdbcProperties() {
    PropertiesFactoryBean bean = new PropertiesFactoryBean();
    bean.setLocations(new ClassPathResource(MessageFormat.format("jdbc-{0}.properties", profile)));
    return bean;
}
Also used : PropertiesFactoryBean(org.springframework.beans.factory.config.PropertiesFactoryBean) ClassPathResource(org.springframework.core.io.ClassPathResource) PropertiesFactoryBean(org.springframework.beans.factory.config.PropertiesFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 10 with PropertiesFactoryBean

use of org.springframework.beans.factory.config.PropertiesFactoryBean in project new-cloud by xie-summer.

the class QuartzConfigration method quartzProperties.

@Bean
public Properties quartzProperties() throws IOException {
    PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
    propertiesFactoryBean.setLocation(new ClassPathResource(quartzConfig));
    propertiesFactoryBean.afterPropertiesSet();
    return propertiesFactoryBean.getObject();
}
Also used : PropertiesFactoryBean(org.springframework.beans.factory.config.PropertiesFactoryBean) ClassPathResource(org.springframework.core.io.ClassPathResource) PropertiesFactoryBean(org.springframework.beans.factory.config.PropertiesFactoryBean) Bean(org.springframework.context.annotation.Bean) SchedulerFactoryBean(org.springframework.scheduling.quartz.SchedulerFactoryBean)

Aggregations

PropertiesFactoryBean (org.springframework.beans.factory.config.PropertiesFactoryBean)23 ClassPathResource (org.springframework.core.io.ClassPathResource)21 Properties (java.util.Properties)12 Bean (org.springframework.context.annotation.Bean)11 ByteArrayInputStream (java.io.ByteArrayInputStream)6 XmlBeanDefinitionReader (org.springframework.beans.factory.xml.XmlBeanDefinitionReader)6 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)6 InputStreamResource (org.springframework.core.io.InputStreamResource)6 SchedulerFactoryBean (org.springframework.scheduling.quartz.SchedulerFactoryBean)6 Ignore (org.junit.Ignore)5 Test (org.junit.Test)5 TwitterTemplate (org.springframework.social.twitter.api.impl.TwitterTemplate)5 Message (org.springframework.messaging.Message)3 Tweet (org.springframework.social.twitter.api.Tweet)2 ArrayList (java.util.ArrayList)1 SimpleUrlValidatorFactoryBean (org.apereo.cas.web.SimpleUrlValidatorFactoryBean)1 FactoryBean (org.springframework.beans.factory.FactoryBean)1 DefaultResourceLoader (org.springframework.core.io.DefaultResourceLoader)1 Resource (org.springframework.core.io.Resource)1 JndiObjectFactoryBean (org.springframework.jndi.JndiObjectFactoryBean)1