Package org.springframework.core.env

Examples of org.springframework.core.env.StandardEnvironment


   * @deprecated since Spring 3.1 in favor of
   * {@link #BeanDefinitionParserDelegate(XmlReaderContext, Environment)}
   */
  @Deprecated
  public BeanDefinitionParserDelegate(XmlReaderContext readerContext) {
    this(readerContext, new StandardEnvironment());
  }
View Full Code Here


  private static Environment getOrCreateEnvironment(BeanDefinitionRegistry registry) {
    Assert.notNull(registry, "BeanDefinitionRegistry must not be null");
    if (registry instanceof EnvironmentCapable) {
      return ((EnvironmentCapable) registry).getEnvironment();
    }
    return new StandardEnvironment();
  }
View Full Code Here

  private static Environment getOrCreateEnvironment(BeanDefinitionRegistry registry) {
    Assert.notNull(registry, "BeanDefinitionRegistry must not be null");
    if (registry instanceof EnvironmentCapable) {
      return ((EnvironmentCapable) registry).getEnvironment();
    }
    return new StandardEnvironment();
  }
View Full Code Here

   * {@link Service @Service}, and {@link Controller @Controller}
   * stereotype annotations
   * @see #registerDefaultFilters()
   */
  public ClassPathScanningCandidateComponentProvider(boolean useDefaultFilters) {
    this(useDefaultFilters, new StandardEnvironment());
  }
View Full Code Here

   * Create and return a new {@link StandardEnvironment}.
   * <p>Subclasses may override this method in order to supply
   * a custom {@link ConfigurableEnvironment} implementation.
   */
  protected ConfigurableEnvironment createEnvironment() {
    return new StandardEnvironment();
  }
View Full Code Here

public class EnvironmentTest {

    @Test
    public void test() {
        //会自动注册 System.getProperties() 和 System.getenv()
        Environment environment = new StandardEnvironment();
        System.out.println(environment.getProperty("file.encoding"));
        System.out.println(environment.getProperty("data"));


    }
View Full Code Here

  @Test
  public void configuresRepositoriesCorrectly() {

    JpaRepositoriesRegistrar registrar = new JpaRepositoriesRegistrar();
    registrar.setResourceLoader(new DefaultResourceLoader());
    registrar.setEnvironment(new StandardEnvironment());
    registrar.registerBeanDefinitions(metadata, registry);

    Iterable<String> names = Arrays.asList(registry.getBeanDefinitionNames());
    assertThat(names, hasItems("userRepository", "auditableUserRepository", "roleRepository"));
  }
View Full Code Here

  public void test() {
    //ConfigurableApplicationContext parent = new GenericApplicationContext();
//    parent.refresh();

    ConfigurableApplicationContext child = new ClassPathXmlApplicationContext();
    child.setEnvironment(new StandardEnvironment());
    child.refresh();

    child.close();
//    parent.close();
View Full Code Here

    EmbeddedDatabaseFactory factory = new EmbeddedDatabaseFactory();
    factory.setDatabaseType(EmbeddedDatabaseType.H2);
    EmbeddedDatabase db = factory.getDatabase();
    System.setProperty("security.encryptPassword", "foo");
    System.setProperty("security.encryptSalt", new String(Hex.encode(KeyGenerators.secureRandom().generateKey())));
    DatabaseUpgrader installer = new DatabaseUpgrader(db, new StandardEnvironment(), Encryptors.noOpText());
    installer.run();
    installer.run();
    DatabaseUpgrader installer2 = new DatabaseUpgrader(db, new StandardEnvironment(), Encryptors.noOpText());
    installer2.run();
  }
View Full Code Here

    assertThat(foo, instanceOf(String.class));
  }

  @Test
  public void getBean_withActiveProfile() {
    ConfigurableEnvironment env = new StandardEnvironment();
    env.setActiveProfiles("dev");

    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(bf);
    reader.setEnvironment(env);
    reader.loadBeanDefinitions(XML);
View Full Code Here

TOP

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

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.