@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()); } } }
@Override public YarnEnvironmentConfigurer propertiesLocation(String... locations) throws IOException { for (String location : locations) { PropertiesFactoryBean fb = new PropertiesFactoryBean(); fb.setLocation(new ClassPathResource(location)); fb.afterPropertiesSet(); properties.putAll(fb.getObject()); } return this; }
private Properties loadProperties() throws Exception { if (StringUtils.hasText(propertiesLocation)) { PropertiesFactoryBean propsFactory = new PropertiesFactoryBean(); propsFactory.setLocations(resourceResolver.getResources(propertiesLocation)); propsFactory.afterPropertiesSet(); return propsFactory.getObject(); } return null; }
@Bean public Properties propertyFactory() throws IOException { List<Resource> resources = loadPropertyResource(); PropertiesFactoryBean factory = new PropertiesFactoryBean(); factory.setLocations(resources.toArray(new Resource[resources.size()])); factory.afterPropertiesSet(); Properties props = factory.getObject(); props.putAll(new ConfigAccessor().get().getProperties()); return props; }
/** * Returns a Properties object that was read from the file <code>classpath:hibernate.properties * </code>. * * @return Properties object */ @Bean public Properties hibernateProperties() { try { PropertiesFactoryBean props = new PropertiesFactoryBean(); ClassPathResource resource = new ClassPathResource("hibernate.properties"); props.setLocation(resource); return props.getObject(); } catch (IOException e) { return null; } }
static { String resourcePattern = "classpath*:META-INF/spring.integration.default.properties"; try { ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver(IntegrationProperties.class.getClassLoader()); Resource[] defaultResources = resourceResolver.getResources(resourcePattern); PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean(); propertiesFactoryBean.setLocations(defaultResources); propertiesFactoryBean.afterPropertiesSet(); defaults = propertiesFactoryBean.getObject(); } catch (IOException e) { throw new IllegalStateException("Can't load '" + resourcePattern + "' resources.", e); } }
@Bean public ImageSource imageSource() { PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean(); propertiesFactoryBean.setLocations( getImageSourceResources().values().toArray(new Resource[getImageSourceResources().size()])); DefaultImageSource imageSource = null; try { propertiesFactoryBean.afterPropertiesSet(); imageSource = new DefaultImageSource(propertiesFactoryBean.getObject()); } catch (IOException e) { throw new IllegalArgumentException("Error getting imagesource property file", e); } imageSource.setBrokenImageIndicator( applicationContext().getResource("classpath:/com/famfamfam/silk/error.png")); return imageSource; }
private void loadErrorMessage() { String method = "loadErrorMessage"; log.logStartMethod(method); try { PropertiesFactoryBean loader = new PropertiesFactoryBean(); loader.setLocation(new ClassPathResource(ERROR_MESSAGE_FILE_LOCATION)); loader.afterPropertiesSet(); properties = (Properties) loader.getObject(); } catch (IOException ioe) { log.logError(method, "no se pudo cargar el archivo 'errorMessage.properties'"); } log.logEndMethod(method); }
@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 = MessageBuilder.withPayload("Polishing #springintegration migration to Spring Social. test") .build(); StatusUpdatingMessageHandler handler = new StatusUpdatingMessageHandler(template); handler.afterPropertiesSet(); handler.handleMessage(message1); }
@Bean(name = "osperConfiguration") public PropertiesFactoryBean recordConfiguration() { PropertiesFactoryBean bean = new PropertiesFactoryBean(); bean.setLocation(new ClassPathResource("osper_oai.properties")); return bean; }
@Override public void setProperties(Properties properties) { super.setProperties(properties); this.properties = properties; }
public void setLocations(final Resource[] locations) { this.locations = locations; lastModified = new long[locations.length]; super.setLocations(locations); }