Package org.springframework.core.env

Examples of org.springframework.core.env.ConfigurableEnvironment


   */
  public static void main(String... args) throws Exception{

    final GenericXmlApplicationContext context = new GenericXmlApplicationContext();

    final ConfigurableEnvironment env = context.getEnvironment();
    boolean mapQuestApiKeyDefined = env.containsProperty("mapquest.apikey");

    if (mapQuestApiKeyDefined) {
      env.setActiveProfiles("mapquest");
    }

    context.load("classpath:META-INF/spring/*.xml");
    context.refresh();

 
View Full Code Here


    private FixedDelayPollingScheduler pollingScheduler;

    @SuppressWarnings("deprecated")
    public synchronized void initializeArchaius() {
        if (initialized.compareAndSet(false, true)) {
            ConfigurableEnvironment env = context.getEnvironment();

            String urls = env.getProperty("archaius.urls");
            if (urls != null)
                System.setProperty("archaius.configurationSource.additionalUrls", urls);

            String defaultFileName = env.getProperty("archauis.file.name", "application.yml");
            System.setProperty("archaius.configurationSource.defaultFileName", defaultFileName);

            String id = context.getEnvironment().getProperty("application.id");
            if (id == null) {
                throw new IllegalStateException("application.id may not be null");
View Full Code Here

    return new StandardServletEnvironment();
  }

  @Override
  public ConfigurableWebEnvironment getEnvironment() {
    ConfigurableEnvironment env = super.getEnvironment();
    Assert.isInstanceOf(ConfigurableWebEnvironment.class, env,
        "ConfigurableWebApplication environment must be of type " +
        "ConfigurableWebEnvironment");
    return (ConfigurableWebEnvironment) env;
  }
View Full Code Here

    return new StandardServletEnvironment();
  }

  @Override
  public ConfigurableWebEnvironment getEnvironment() {
    ConfigurableEnvironment env = super.getEnvironment();
    Assert.isInstanceOf(ConfigurableWebEnvironment.class, env,
        "ConfigurableWebApplicationContext environment must be of type " +
        "ConfigurableWebEnvironment");
    return (ConfigurableWebEnvironment) env;
  }
View Full Code Here

    return new StandardServletEnvironment();
  }

  @Override
  public ConfigurableWebEnvironment getEnvironment() {
    ConfigurableEnvironment env = super.getEnvironment();
    Assert.isInstanceOf(ConfigurableWebEnvironment.class, env,
        "ConfigurableWebApplicationContext environment must be of type " +
        "ConfigurableWebEnvironment");
    return (ConfigurableWebEnvironment) env;
  }
View Full Code Here

        return grailsApplication == null ? new StandardServletEnvironment() : new GrailsEnvironment(grailsApplication);
    }

    @Override
    public ConfigurableWebEnvironment getEnvironment() {
        ConfigurableEnvironment env = super.getEnvironment();
        Assert.isInstanceOf(ConfigurableWebEnvironment.class, env,
                "ConfigurableWebApplication environment must be of type ConfigurableWebEnvironment");
        return (ConfigurableWebEnvironment) env;
    }
View Full Code Here

  private static AnnotationConfigApplicationContext context = null;

  public static void initialize() throws IOException {
    context = new AnnotationConfigApplicationContext();
    ConfigurableEnvironment environment = context.getEnvironment();
    environment.addActiveProfile("cryson_logging");
    PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
    configurer.setLocations(new Resource[]{context.getResource("advancedcrysondiary.properties"), context.getResource("cryson.properties")});
    context.addBeanFactoryPostProcessor(configurer);
    context.scan(Spring.class.getPackage().getName(), CrysonServer.class.getPackage().getName());
    context.refresh();
View Full Code Here

    AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext();
    child.setParent(parent);
    child.refresh();

    ConfigurableEnvironment env = child.getBean(ConfigurableEnvironment.class);
    assertThat("UNKNOWN ENV", env, anyOf(sameInstance(parent.getEnvironment()), sameInstance(child.getEnvironment())));
    assertThat("EXPECTED CHILD CTX ENV", env, sameInstance(child.getEnvironment()));
  }
View Full Code Here

    resolveBeans(beanPackages);
    context.refresh();
  }

  private static void configureProfiles() {
    ConfigurableEnvironment environment = context.getEnvironment();
    if ("true".equals(getProperty("cryson.httpserver.enabled"))) {
      environment.addActiveProfile("cryson_httpserver");
    }
    if ("true".equals(getProperty("cryson.database.enabled"))) {
      environment.addActiveProfile("cryson_database");
    }
    if ("true".equals(getProperty("cryson.security.enabled"))) {
      environment.addActiveProfile("cryson_security");
    }
    if ("true".equals(getProperty("cryson.logging.enabled"))) {
      environment.addActiveProfile("cryson_logging");
    }
  }
View Full Code Here

    }

    // The wac environment's #initPropertySources will be called in any case when the context
    // is refreshed; do it eagerly here to ensure servlet property sources are in place for
    // use in any post-processing or initialization that occurs below prior to #refresh
    ConfigurableEnvironment env = wac.getEnvironment();
    if (env instanceof ConfigurableWebEnvironment) {
      ((ConfigurableWebEnvironment) env).initPropertySources(sc, null);
    }

    customizeContext(sc, wac);
View Full Code Here

TOP

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

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.