Examples of MutablePropertySources


Examples of org.springframework.core.env.MutablePropertySources

      // Flatten the sources into a single list so they can be iterated
      return new FlatPropertySources(configurer.getAppliedPropertySources());
    }

    if (this.environment instanceof ConfigurableEnvironment) {
      MutablePropertySources propertySources = ((ConfigurableEnvironment) this.environment)
          .getPropertySources();
      return new FlatPropertySources(propertySources);
    }

    // empty, so not very useful, but fulfils the contract
    return new MutablePropertySources();
  }
View Full Code Here

Examples of org.springframework.core.env.MutablePropertySources

          loader.load(resource, profile);
        }
        loader.load(resource);
      }

      MutablePropertySources loaded = loader.getPropertySources();
      if (mergeDefaultSources) {
        for (PropertySource<?> propertySource : this.propertySources) {
          loaded.addLast(propertySource);
        }
      }
      return loaded;
    }
    catch (IOException ex) {
View Full Code Here

Examples of org.springframework.core.env.MutablePropertySources

      this.propertySources = propertySources;
    }

    @Override
    public Iterator<PropertySource<?>> iterator() {
      MutablePropertySources result = getFlattened();
      return result.iterator();
    }
View Full Code Here

Examples of org.springframework.core.env.MutablePropertySources

    public PropertySource<?> get(String name) {
      return getFlattened().get(name);
    }

    private MutablePropertySources getFlattened() {
      MutablePropertySources result = new MutablePropertySources();
      for (PropertySource<?> propertySource : this.propertySources) {
        flattenPropertySources(propertySource, result);
      }
      return result;
    }
View Full Code Here

Examples of org.springframework.core.env.MutablePropertySources

  /**
   * Create a new {@link PropertySourceLoader} instance backed by a new
   * {@link MutablePropertySources}.
   */
  public PropertySourcesLoader() {
    this(new MutablePropertySources());
  }
View Full Code Here

Examples of org.springframework.core.env.MutablePropertySources

  @Test
  public void testBindFromPropertySource() throws Exception {
    this.targetName = "foo";
    setupFactory();
    MutablePropertySources sources = new MutablePropertySources();
    sources.addFirst(new MapPropertySource("map", Collections.singletonMap(
        "foo.map.name", (Object) "blah")));
    this.factory.setPropertySources(sources);
    this.factory.afterPropertiesSet();
    Foo foo = this.factory.getObject();
    assertEquals("blah", foo.map.get("name"));
View Full Code Here

Examples of org.springframework.core.env.MutablePropertySources

  @Test
  public void testBindFromCompositePropertySource() throws Exception {
    this.targetName = "foo";
    setupFactory();
    MutablePropertySources sources = new MutablePropertySources();
    CompositePropertySource composite = new CompositePropertySource("composite");
    composite.addPropertySource(new MapPropertySource("map", Collections
        .singletonMap("foo.map.name", (Object) "blah")));
    sources.addFirst(composite);
    this.factory.setPropertySources(sources);
    this.factory.afterPropertiesSet();
    Foo foo = this.factory.getObject();
    assertEquals("blah", foo.map.get("name"));
  }
View Full Code Here

Examples of org.springframework.core.env.MutablePropertySources

      }

      @Override
      protected boolean matchesSafely(ConfigurableEnvironment item,
          Description mismatchDescription) {
        MutablePropertySources sources = new MutablePropertySources(
            item.getPropertySources());
        ConfigurationPropertySources.finishAndRelocate(sources);
        mismatchDescription.appendText("Not matched against: ").appendValue(
            sources);
        return sources.contains(sourceName);
      }
    };
  }
View Full Code Here

Examples of org.springframework.core.env.MutablePropertySources

   * @param name the property source name
   * @param pairs the name:value pairs
   */
  public static void addEnvironment(String name, ConfigurableEnvironment environment,
      String... pairs) {
    MutablePropertySources sources = environment.getPropertySources();
    Map<String, Object> map;
    if (!sources.contains(name)) {
      map = new HashMap<String, Object>();
      MapPropertySource source = new MapPropertySource(name, map);
      sources.addFirst(source);
    }
    else {
      @SuppressWarnings("unchecked")
      Map<String, Object> value = (Map<String, Object>) sources.get(name)
          .getSource();
      map = value;
    }
    for (String pair : pairs) {
      int index = pair.indexOf(":");
View Full Code Here

Examples of org.springframework.core.env.MutablePropertySources

  /**
   * Strict tests need a known set of properties so we remove system items which may be
   * environment specific.
   */
  private void removeSystemProperties() {
    MutablePropertySources sources = this.context.getEnvironment()
        .getPropertySources();
    sources.remove("systemProperties");
    sources.remove("systemEnvironment");
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.