use of org.springframework.beans.factory.config.PropertiesFactoryBean in project spring-integration by spring-projects.
the class SearchReceivingMessageSourceTests method demoReceiveSearchResults.
@SuppressWarnings("unchecked")
@Test
@Ignore
public void demoReceiveSearchResults() throws Exception {
PropertiesFactoryBean pf = new PropertiesFactoryBean();
pf.setLocation(new ClassPathResource("sample.properties"));
pf.afterPropertiesSet();
Properties prop = pf.getObject();
TwitterTemplate template = new TwitterTemplate(prop.getProperty("z_oleg.oauth.consumerKey"), prop.getProperty("z_oleg.oauth.consumerSecret"), prop.getProperty("z_oleg.oauth.accessToken"), prop.getProperty("z_oleg.oauth.accessTokenSecret"));
SearchReceivingMessageSource tSource = new SearchReceivingMessageSource(template, "foo");
tSource.setQuery(SEARCH_QUERY);
tSource.afterPropertiesSet();
for (int i = 0; i < 50; i++) {
Message<Tweet> message = (Message<Tweet>) tSource.receive();
if (message != null) {
Tweet tweet = message.getPayload();
logger.info(tweet.getFromUser() + " - " + tweet.getText() + " - " + tweet.getCreatedAt());
}
}
}
use of org.springframework.beans.factory.config.PropertiesFactoryBean in project spring-integration by spring-projects.
the class TimelineReceivingMessageSourceTests method demoReceiveTimeline.
@SuppressWarnings("unchecked")
@Test
@Ignore
public void demoReceiveTimeline() throws Exception {
PropertiesFactoryBean pf = new PropertiesFactoryBean();
pf.setLocation(new ClassPathResource("sample.properties"));
pf.afterPropertiesSet();
Properties prop = pf.getObject();
TwitterTemplate template = new TwitterTemplate(prop.getProperty("z_oleg.oauth.consumerKey"), prop.getProperty("z_oleg.oauth.consumerSecret"), prop.getProperty("z_oleg.oauth.accessToken"), prop.getProperty("z_oleg.oauth.accessTokenSecret"));
TimelineReceivingMessageSource tSource = new TimelineReceivingMessageSource(template, "foo");
tSource.afterPropertiesSet();
for (int i = 0; i < 50; i++) {
Message<Tweet> message = (Message<Tweet>) tSource.receive();
if (message != null) {
Tweet tweet = message.getPayload();
logger.info(tweet.getFromUser() + " - " + tweet.getText() + " - " + tweet.getCreatedAt());
}
}
}
use of org.springframework.beans.factory.config.PropertiesFactoryBean in project spring-integration by spring-projects.
the class StatusUpdatingMessageHandlerTests method demoSendStatusMessage.
@Test
@Ignore
public void demoSendStatusMessage() throws Exception {
PropertiesFactoryBean pf = new PropertiesFactoryBean();
pf.setLocation(new ClassPathResource("sample.properties"));
pf.afterPropertiesSet();
Properties prop = pf.getObject();
TwitterTemplate template = new TwitterTemplate(prop.getProperty("z_oleg.oauth.consumerKey"), prop.getProperty("z_oleg.oauth.consumerSecret"), prop.getProperty("z_oleg.oauth.accessToken"), prop.getProperty("z_oleg.oauth.accessTokenSecret"));
Message<?> message1 = new GenericMessage<>("Polishing #springintegration migration to Spring Social. test");
StatusUpdatingMessageHandler handler = new StatusUpdatingMessageHandler(template);
handler.afterPropertiesSet();
handler.handleMessage(message1);
}
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/xml/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;
}
use of org.springframework.beans.factory.config.PropertiesFactoryBean in project springBoot-learn-demo by nbfujx.
the class SchedulerConfig method quartzProperties.
@Bean
public Properties quartzProperties() throws IOException {
PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
// 在quartz.properties中的属性被读取并注入后再初始化对象
propertiesFactoryBean.afterPropertiesSet();
return propertiesFactoryBean.getObject();
}
Aggregations