Package org.springframework.core.env

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


            "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


            "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

    }

    public void testOverridingDefaultTemplateViaConfig() throws Exception {
            ConfigObject config = new ConfigSlurper().parse("grails.sitemesh.default.layout='otherApplication'");
            MutablePropertySources propertySources = new MutablePropertySources();
            propertySources.addLast(new MapPropertySource("grails", config));

            GrailsWebRequest webRequest = buildMockRequest(new PropertySourcesConfig(propertySources));
            webRequest.setAttribute(GrailsLayoutDecoratorMapper.RENDERING_VIEW, Boolean.TRUE, RequestAttributes.SCOPE_REQUEST);
            MockApplicationContext appCtx = (MockApplicationContext)webRequest.getApplicationContext();
            appCtx.registerMockResource("/grails-app/views/layouts/application.gsp", "<html><body><h1>Default Layout</h1><g:layoutBody /></body></html>");
View Full Code Here

                "resource", "classpath:resources.properties");


        MutablePropertySources propertySources = new MutablePropertySources();
        propertySources.addFirst(propertySource1);
        propertySources.addLast(propertySource2);
        System.out.println(propertySources.get("resource").getProperty("encoding"));

        for (PropertySource propertySource : propertySources) {
            System.out.println(propertySource.getProperty("encoding"));
        }
View Full Code Here

        propertySources.replace(name, composite);
      }
    }
    else {
      if (this.propertySourceNames.isEmpty()) {
        propertySources.addLast(propertySource);
      }
      else {
        String firstProcessed = this.propertySourceNames.get(this.propertySourceNames.size() - 1);
        propertySources.addBefore(firstProcessed, propertySource);
      }
View Full Code Here

        genericBeanDefinition(TestBean.class)
          .addPropertyValue("name", "${my.name}")
          .getBeanDefinition());

    MutablePropertySources propertySources = new MutablePropertySources();
    propertySources.addLast(new MockPropertySource().withProperty("my.name", "foo"));

    PropertySourcesPlaceholderConfigurer pc = new PropertySourcesPlaceholderConfigurer();
    pc.setPropertySources(propertySources);
    pc.postProcessBeanFactory(bf);
    assertThat(bf.getBean(TestBean.class).getName(), equalTo("foo"));
View Full Code Here

        genericBeanDefinition(TestBean.class)
          .addPropertyValue("name", "${my.name}")
          .getBeanDefinition());

    MutablePropertySources propertySources = new MutablePropertySources();
    propertySources.addLast(new MockPropertySource());

    PropertySourcesPlaceholderConfigurer pc = new PropertySourcesPlaceholderConfigurer();
    pc.setPropertySources(propertySources);
    pc.setEnvironment(new MockEnvironment().withProperty("my.name", "env"));
    pc.setIgnoreUnresolvablePlaceholders(true);
View Full Code Here

        genericBeanDefinition(TestBean.class)
          .addPropertyValue("name", "${my.name}")
          .getBeanDefinition());

    MutablePropertySources propertySources = new MutablePropertySources();
    propertySources.addLast(new MockPropertySource());

    PropertySourcesPlaceholderConfigurer pc = new PropertySourcesPlaceholderConfigurer();
    pc.setPropertySources(propertySources);
    pc.setProperties(new Properties() {{
      put("my.name", "local");
View Full Code Here

public class MutablePropertySourcesTests {

  @Test
  public void test() {
    MutablePropertySources sources = new MutablePropertySources();
    sources.addLast(new MockPropertySource("b").withProperty("p1", "bValue"));
    sources.addLast(new MockPropertySource("d").withProperty("p1", "dValue"));
    sources.addLast(new MockPropertySource("f").withProperty("p1", "fValue"));

    assertThat(sources.size(), equalTo(3));
    assertThat(sources.contains("a"), is(false));
View Full Code Here

  @Test
  public void test() {
    MutablePropertySources sources = new MutablePropertySources();
    sources.addLast(new MockPropertySource("b").withProperty("p1", "bValue"));
    sources.addLast(new MockPropertySource("d").withProperty("p1", "dValue"));
    sources.addLast(new MockPropertySource("f").withProperty("p1", "fValue"));

    assertThat(sources.size(), equalTo(3));
    assertThat(sources.contains("a"), is(false));
    assertThat(sources.contains("b"), is(true));
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.