Package org.springframework.core.env

Examples of org.springframework.core.env.PropertiesPropertySource


  public void test() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    Properties properties = new Properties();
    properties.put("prefix","foo");
    properties.put("suffix","bar");
    context.getEnvironment().getPropertySources().addLast(new PropertiesPropertySource("options", properties));
    context.register(TestConfiguration.class);
    context.refresh();

    MessageChannel input = context.getBean("input", MessageChannel.class);
    SubscribableChannel output = context.getBean("output", SubscribableChannel.class);
View Full Code Here


    MutablePropertySources propertySources = environment.getPropertySources();
    if (propertySources
        .contains(CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME)) {
      propertySources.addAfter(
          CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME,
          new PropertiesPropertySource("vcap", properties));
    }
    else {
      propertySources.addFirst(new PropertiesPropertySource("vcap", properties));
    }
  }
View Full Code Here

  public PropertySource<?> load(String name, Resource resource, String profile)
      throws IOException {
    if (profile == null) {
      Properties properties = PropertiesLoaderUtils.loadProperties(resource);
      if (!properties.isEmpty()) {
        return new PropertiesPropertySource(name, properties);
      }
    }
    return null;
  }
View Full Code Here

        factory.setDocumentMatchers(new SpringProfileDocumentMatcher(profile));
      }
      factory.setResources(new Resource[] { resource });
      Properties properties = factory.getObject();
      if (!properties.isEmpty()) {
        return new PropertiesPropertySource(name, properties);
      }
    }
    return null;
  }
View Full Code Here

  private static void registerPropertiesFile(String name, String location, ConfigurableWebApplicationContext applicationContext) {
    String resolvedLocation = applicationContext.getEnvironment().resolvePlaceholders(location);
    final Resource resource = applicationContext.getResource(resolvedLocation);
    try {
      final Properties props = PropertiesLoaderUtils.loadProperties(resource);
      final PropertiesPropertySource ps = new PropertiesPropertySource(name, props);
     
      applicationContext.getEnvironment().getPropertySources().addFirst(ps);
    } catch (FileNotFoundException e) {
      log.warn("config file not found (" + resolvedLocation + ")");
    } catch (IOException e1) {
View Full Code Here

    // If properties are set on the context, add them last
    Properties contextProperties = context.getProperties();

    if ( !contextProperties.isEmpty() ) {
      configurers.add( new PropertySourcesConfigurer(
          new PropertiesPropertySource( AcrossContext.BEAN, contextProperties ) ) );
    }

    return configurers;
  }
View Full Code Here

    // Finally add properties set on the module
    Properties moduleProperties = module.getProperties();

    if ( !moduleProperties.isEmpty() ) {
      configurers.add( new PropertySourcesConfigurer(
          new PropertiesPropertySource( module.getName(), moduleProperties ) ) );
    }

    return configurers;
  }
View Full Code Here

TOP

Related Classes of org.springframework.core.env.PropertiesPropertySource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.