Exemple #1
0
  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;
  }
  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;
 }
 public void setLocations(final Resource[] locations) {
   this.locations = locations;
   lastModified = new long[locations.length];
   super.setLocations(locations);
 }