Package org.springframework.context

Examples of org.springframework.context.ConfigurableApplicationContext.refresh()


    public void configure(Object beanInstance) {
        // check the ApplicationContext states first , and call the refresh if necessary
        if (((SpringCamelContext)getCamelContext()).getApplicationContext() instanceof ConfigurableApplicationContext) {
            ConfigurableApplicationContext context = (ConfigurableApplicationContext)((SpringCamelContext)getCamelContext()).getApplicationContext();
            if (!context.isActive()) {
                context.refresh();
            }
        }
        configurer.configureBean(beanId, beanInstance);
    }
View Full Code Here


    //ConfigurableApplicationContext parent = new GenericApplicationContext();
//    parent.refresh();

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

    child.close();
//    parent.close();

//    Object ac2 = new GenericXmlApplicationContext();
View Full Code Here

public class ReproTests {
  @SuppressWarnings("unchecked")
  @Test
  public void repro() {
    ConfigurableApplicationContext parent = new GenericApplicationContext();
    parent.refresh();

    AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext();
    child.setParent(parent);
    child.refresh();
View Full Code Here

    void configure(Object beanInstance) {
        // check the ApplicationContext states first , and call the refresh if necessary
        if (((SpringCamelContext)getCamelContext()).getApplicationContext() instanceof ConfigurableApplicationContext) {
            ConfigurableApplicationContext context = (ConfigurableApplicationContext)((SpringCamelContext)getCamelContext()).getApplicationContext();
            if (!context.isActive()) {
                context.refresh();
            }
        }
        configurer.configureBean(beanId, beanInstance);
    }
   
View Full Code Here

public class EnvironmentIntegrationTests {

  @Test
  public void repro() {
    ConfigurableApplicationContext parent = new GenericApplicationContext();
    parent.refresh();

    AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext();
    child.setParent(parent);
    child.refresh();
View Full Code Here

  }

  @Test
  public void genericApplicationContext_standardEnv() {
    ConfigurableApplicationContext ctx = new GenericApplicationContext(newBeanFactoryWithEnvironmentAwareBean());
    ctx.refresh();

    assertHasStandardEnvironment(ctx);
    assertEnvironmentBeanRegistered(ctx);
    assertEnvironmentAwareInvoked(ctx, ctx.getEnvironment());
  }
View Full Code Here

  @Test
  public void classPathXmlApplicationContext() {
    ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext(XML_PATH);
    ctx.setEnvironment(prodEnv);
    ctx.refresh();

    assertEnvironmentBeanRegistered(ctx);
    assertHasEnvironment(ctx, prodEnv);
    assertEnvironmentAwareInvoked(ctx, ctx.getEnvironment());
    assertThat(ctx.containsBean(DEV_BEAN_NAME), is(false));
View Full Code Here

    // strange - FSXAC strips leading '/' unless prefixed with 'file:'
    ConfigurableApplicationContext ctx =
        new FileSystemXmlApplicationContext(new String[] {"file:" + tmpFile.getPath()}, false);
    ctx.setEnvironment(prodEnv);
    ctx.refresh();
    assertEnvironmentBeanRegistered(ctx);
    assertHasEnvironment(ctx, prodEnv);
    assertEnvironmentAwareInvoked(ctx, ctx.getEnvironment());
    assertThat(ctx.containsBean(DEV_BEAN_NAME), is(false));
    assertThat(ctx.containsBean(PROD_BEAN_NAME), is(true));
View Full Code Here

  @Test
  public void abstractApplicationContextValidatesRequiredPropertiesOnRefresh() {
    {
      ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext();
      ctx.refresh();
    }

    {
      ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext();
      ctx.getEnvironment().setRequiredProperties("foo", "bar");
View Full Code Here

    {
      ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext();
      ctx.getEnvironment().setRequiredProperties("foo", "bar");
      try {
        ctx.refresh();
        fail("expected missing property exception");
      }
      catch (MissingRequiredPropertiesException ex) {
      }
    }
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.