Search in sources :

Example 11 with PropertiesFactoryBean

use of org.springframework.beans.factory.config.PropertiesFactoryBean in project CzechIdMng by bcvsolutions.

the class SchedulerConfig method quartzProperties.

@Bean
public Properties quartzProperties() throws IOException {
    PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
    propertiesFactoryBean.setLocation(new ClassPathResource(propertiesLocation));
    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) SchedulerFactoryBean(org.springframework.scheduling.quartz.SchedulerFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 12 with PropertiesFactoryBean

use of org.springframework.beans.factory.config.PropertiesFactoryBean in project vorto by eclipse.

the class QPidConfiguration method qpidProperties.

@Bean
public PropertiesFactoryBean qpidProperties() {
    PropertiesFactoryBean pfb = new PropertiesFactoryBean();
    pfb.setLocation(new ClassPathResource("qpid.properties"));
    return pfb;
}
Also used : PropertiesFactoryBean(org.springframework.beans.factory.config.PropertiesFactoryBean) ClassPathResource(org.springframework.core.io.ClassPathResource) PropertiesFactoryBean(org.springframework.beans.factory.config.PropertiesFactoryBean) JndiObjectFactoryBean(org.springframework.jndi.JndiObjectFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 13 with PropertiesFactoryBean

use of org.springframework.beans.factory.config.PropertiesFactoryBean in project spring-cloud-framework by zhuwj921.

the class SchedulerConfiguration method schedulerFactoryBean.

@Bean(name = "SchedulerFactory")
public SchedulerFactoryBean schedulerFactoryBean() throws IOException {
    // 获取配置属性
    PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
    propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
    // 在quartz.properties中的属性被读取并注入后再初始化对象
    propertiesFactoryBean.afterPropertiesSet();
    // 创建SchedulerFactoryBean
    SchedulerFactoryBean factory = new SchedulerFactoryBean();
    factory.setQuartzProperties(propertiesFactoryBean.getObject());
    // 使用数据源
    factory.setDataSource(dataSource);
    factory.setJobFactory(jobFactory);
    return factory;
}
Also used : PropertiesFactoryBean(org.springframework.beans.factory.config.PropertiesFactoryBean) SchedulerFactoryBean(org.springframework.scheduling.quartz.SchedulerFactoryBean) 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)

Example 14 with PropertiesFactoryBean

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

the class ChainElementsTests method bootStrap.

private ApplicationContext bootStrap(String configProperty) throws Exception {
    PropertiesFactoryBean pfb = new PropertiesFactoryBean();
    pfb.setLocation(new ClassPathResource("org/springframework/integration/file/config/chain-elements-config.properties"));
    pfb.afterPropertiesSet();
    Properties prop = pfb.getObject();
    StringBuffer buffer = new StringBuffer();
    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 15 with PropertiesFactoryBean

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

the class ChainElementsTests method bootStrap.

private ApplicationContext bootStrap(String configProperty) throws Exception {
    PropertiesFactoryBean pfb = new PropertiesFactoryBean();
    pfb.setLocation(new ClassPathResource("org/springframework/integration/http/config/chain-elements-config.properties"));
    pfb.afterPropertiesSet();
    Properties prop = pfb.getObject();
    StringBuffer buffer = new StringBuffer();
    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)

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