Package org.springframework.core.env

Examples of org.springframework.core.env.MutablePropertySources.addAfter()


    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");
      }
View Full Code Here


    assertThat(sources.get("b").getProperty("p1"), equalTo((Object)"bValue"));
    assertThat(sources.get("d"), not(nullValue()));
    assertThat(sources.get("d").getProperty("p1"), equalTo((Object)"dValue"));

    sources.addBefore("b", new MockPropertySource("a"));
    sources.addAfter("b", new MockPropertySource("c"));

    assertThat(sources.size(), equalTo(5));
    assertThat(sources.precedenceOf(PropertySource.named("a")), is(0));
    assertThat(sources.precedenceOf(PropertySource.named("b")), is(1));
    assertThat(sources.precedenceOf(PropertySource.named("c")), is(2));
View Full Code Here

    assertThat(sources.precedenceOf(PropertySource.named("c")), is(2));
    assertThat(sources.precedenceOf(PropertySource.named("d")), is(3));
    assertThat(sources.precedenceOf(PropertySource.named("f")), is(4));

    sources.addBefore("f", new MockPropertySource("e"));
    sources.addAfter("f", new MockPropertySource("g"));

    assertThat(sources.size(), equalTo(7));
    assertThat(sources.precedenceOf(PropertySource.named("a")), is(0));
    assertThat(sources.precedenceOf(PropertySource.named("b")), is(1));
    assertThat(sources.precedenceOf(PropertySource.named("c")), is(2));
View Full Code Here

    assertEquals(sources.remove("a"), null);
    assertThat(sources.size(), equalTo(6));

    String bogusPS = "bogus";
    try {
      sources.addAfter(bogusPS, new MockPropertySource("h"));
      fail("expected non-existent PropertySource exception");
    } catch (IllegalArgumentException ex) {
      assertThat(ex.getMessage(),
          equalTo(format(NON_EXISTENT_PROPERTY_SOURCE_MESSAGE, bogusPS)));
    }
View Full Code Here

      assertThat(ex.getMessage(),
          equalTo(format(ILLEGAL_RELATIVE_ADDITION_MESSAGE, "b")));
    }

    try {
      sources.addAfter("b", new MockPropertySource("b"));
      fail("expected exception");
    } catch (IllegalArgumentException ex) {
      assertThat(ex.getMessage(),
          equalTo(format(ILLEGAL_RELATIVE_ADDITION_MESSAGE, "b")));
    }
View Full Code Here

    addWithPrefix(properties, getPropertiesFromServices(environment),
        "vcap.services.");
    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

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.