Package org.springframework.core.env

Examples of org.springframework.core.env.MutablePropertySources


    this.propertySourceMap = propertySourceMap;
  }

  @Override
  public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
    MutablePropertySources propertySources = event.getEnvironment().getPropertySources();
    if (propertySources.contains(CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME)) {
      if(log.isDebugEnabled()) {
        log.debug("Adding afterCommandLineArgs property source after "
            + CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME);
      }
      propertySources.addAfter(CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME,
          new MapPropertySource("afterCommandLineArgs", propertySourceMap));
    } else {
      if(log.isDebugEnabled()) {
        log.debug("Adding afterCommandLineArgs property source as first");
      }
      propertySources.addFirst(new MapPropertySource("afterCommandLineArgs", propertySourceMap));
    }
  }
View Full Code Here


public class PropertyMockingApplicationContextInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {

    @Override
    public void initialize(ConfigurableApplicationContext applicationContext) {
        MutablePropertySources propertySources = applicationContext.getEnvironment().getPropertySources();
        MockPropertySource mockEnvVars = new MockPropertySource().withProperty("bookService.port", PortFactory.findFreePort());
        propertySources.replace(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, mockEnvVars);
    }
View Full Code Here

   * Setting this property indicates that environment property sources and local
   * properties should be ignored.
   * @see #postProcessBeanFactory
   */
  public void setPropertySources(PropertySources propertySources) {
    this.propertySources = new MutablePropertySources(propertySources);
  }
View Full Code Here

   * sources, and once set, the configurer makes no assumptions about adding additional sources.
   */
  @Override
  public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    if (this.propertySources == null) {
      this.propertySources = new MutablePropertySources();
      if (this.environment != null) {
        this.propertySources.addLast(
          new PropertySource<Environment>(ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME, this.environment) {
            @Override
            public String getProperty(String key) {
View Full Code Here

      if (!(this.environment instanceof ConfigurableEnvironment)) {
        logger.warn("Ignoring @PropertySource annotations. " +
            "Reason: Environment must implement ConfigurableEnvironment");
      }
      else {
        MutablePropertySources envPropertySources = ((ConfigurableEnvironment)this.environment).getPropertySources();
        while (!parsedPropertySources.isEmpty()) {
          envPropertySources.addLast(parsedPropertySources.pop());
        }
      }
    }

    // Read the model and create bean definitions based on its content
View Full Code Here

   * Setting this property indicates that environment property sources and local
   * properties should be ignored.
   * @see #postProcessBeanFactory
   */
  public void setPropertySources(PropertySources propertySources) {
    this.propertySources = new MutablePropertySources(propertySources);
  }
View Full Code Here

   * sources, and once set, the configurer makes no assumptions about adding additional sources.
   */
  @Override
  public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    if (this.propertySources == null) {
      this.propertySources = new MutablePropertySources();
      if (this.environment != null) {
        this.propertySources.addLast(
          new PropertySource<Environment>(ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME, this.environment) {
            @Override
            public String getProperty(String key) {
View Full Code Here

      if (!(this.environment instanceof ConfigurableEnvironment)) {
        logger.warn("Ignoring @PropertySource annotations. " +
            "Reason: Environment must implement ConfigurableEnvironment");
      }
      else {
        MutablePropertySources envPropertySources = ((ConfigurableEnvironment)this.environment).getPropertySources();
        while (!parsedPropertySources.isEmpty()) {
          envPropertySources.addLast(parsedPropertySources.pop());
        }
      }
    }

    // Read the model and create bean definitions based on its content
View Full Code Here

        if (config == null) {
            if(parentContext != null) {

                org.springframework.core.env.Environment environment = parentContext.getEnvironment();
                if(environment instanceof ConfigurableEnvironment) {
                    MutablePropertySources propertySources = ((ConfigurableEnvironment) environment).getPropertySources();
                    this.config = new PropertySourcesConfig(propertySources);
                }
            }
            else {
                this.config = new PropertySourcesConfig();
View Full Code Here

   
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        org.springframework.core.env.Environment environment = applicationContext.getEnvironment();
        if(environment instanceof ConfigurableEnvironment) {
            MutablePropertySources propertySources = ((ConfigurableEnvironment) environment).getPropertySources();
            PropertySourcesConfig newConfig = new PropertySourcesConfig(propertySources);
            if(this.config != null) {
                newConfig.merge(this.config);
            }
            this.config = newConfig;
View Full Code Here

TOP

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

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.