Package org.springframework.context.support

Examples of org.springframework.context.support.GenericApplicationContext.refresh()


    prepareContext(context);
    customizeBeanFactory(context.getDefaultListableBeanFactory());
    createBeanDefinitionReader(context).loadBeanDefinitions(locations);
    AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
    customizeContext(context);
    context.refresh();
    context.registerShutdownHook();
    return context;
  }

  /**
 
View Full Code Here


   */
  protected ConfigurableApplicationContext createApplicationContext(String[] locations) {
    GenericApplicationContext context = new GenericApplicationContext();
    customizeBeanFactory(context.getDefaultListableBeanFactory());
    new XmlBeanDefinitionReader(context).loadBeanDefinitions(locations);
    context.refresh();
    return context;
  }

  /**
   * Customize the internal bean factory of the ApplicationContext used by this test.
View Full Code Here

  protected ConfigurableApplicationContext loadContext(String configLocation) {
    GenericApplicationContext ctx = new GenericApplicationContext();
    new XmlBeanDefinitionReader(ctx).loadBeanDefinitions(configLocation);
    ctx.getDefaultListableBeanFactory().registerSingleton("server", this.server);
    ctx.refresh();
    return ctx;
  }

  protected void tearDown() throws Exception {
    releaseServer();
View Full Code Here

  protected ConfigurableApplicationContext createApplicationContext(String[] locations) {
    GenericApplicationContext context = new GenericApplicationContext();
    prepareApplicationContext(context);
    customizeBeanFactory(context.getDefaultListableBeanFactory());
    createBeanDefinitionReader(context).loadBeanDefinitions(locations);
    context.refresh();
    return context;
  }

  /**
   * Prepare the GenericApplicationContext used by this test.
View Full Code Here

    BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean();

    GenericApplicationContext ctx = new GenericApplicationContext();
    ctx.registerBeanDefinition(PROCESSOR_BEAN_NAME, processorBeanDefinition);
    ctx.registerBeanDefinition(MESSENGER_BEAN_NAME, scriptedBeanDefinition);
    ctx.refresh();

    Messenger messenger = (Messenger) ctx.getBean(MESSENGER_BEAN_NAME);
    assertEquals(MESSAGE_TEXT, messenger.getMessage());
    // cool; now let's change the script and check the refresh behaviour...
    pauseToLetRefreshDelayKickIn(DEFAULT_SECONDS_TO_PAUSE);
View Full Code Here

    BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean();

    GenericApplicationContext ctx = new GenericApplicationContext();
    ctx.registerBeanDefinition(PROCESSOR_BEAN_NAME, processorBeanDefinition);
    ctx.registerBeanDefinition(MESSENGER_BEAN_NAME, scriptedBeanDefinition);
    ctx.refresh();

    Messenger messenger = (Messenger) ctx.getBean(MESSENGER_BEAN_NAME);
    assertEquals(MESSAGE_TEXT, messenger.getMessage());
    // cool; now let's change the script and check the refresh behaviour...
    pauseToLetRefreshDelayKickIn(DEFAULT_SECONDS_TO_PAUSE);
View Full Code Here

    GenericApplicationContext ctx = new GenericApplicationContext();
    ctx.registerBeanDefinition(PROCESSOR_BEAN_NAME, processorBeanDefinition);
    ctx.registerBeanDefinition(MESSENGER_BEAN_NAME, scriptedBeanDefinition);
    final String collaboratorBeanName = "collaborator";
    ctx.registerBeanDefinition(collaboratorBeanName, collaboratorBuilder.getBeanDefinition());
    ctx.refresh();

    Messenger messenger = (Messenger) ctx.getBean(MESSENGER_BEAN_NAME);
    assertEquals(MESSAGE_TEXT, messenger.getMessage());
    // cool; now let's change the script and check the refresh behaviour...
    pauseToLetRefreshDelayKickIn(DEFAULT_SECONDS_TO_PAUSE);
View Full Code Here

  }

  public void testReferencesAcrossAContainerHierarchy() throws Exception {
    GenericApplicationContext businessContext = new GenericApplicationContext();
    businessContext.registerBeanDefinition("messenger", BeanDefinitionBuilder.rootBeanDefinition(StubMessenger.class).getBeanDefinition());
    businessContext.refresh();

    BeanDefinitionBuilder scriptedBeanBuilder = BeanDefinitionBuilder.rootBeanDefinition(GroovyScriptFactory.class);
    scriptedBeanBuilder.addConstructorArgValue(DELEGATING_SCRIPT);
    scriptedBeanBuilder.addPropertyReference("messenger", "messenger");
View Full Code Here

    scriptedBeanBuilder.addPropertyReference("messenger", "messenger");

    GenericApplicationContext presentationCtx = new GenericApplicationContext(businessContext);
    presentationCtx.registerBeanDefinition("needsMessenger", scriptedBeanBuilder.getBeanDefinition());
    presentationCtx.registerBeanDefinition("scriptProcessor", createScriptFactoryPostProcessor(true));
    presentationCtx.refresh();
  }

  public void testScriptHavingAReferenceToAnotherBean() throws Exception {
    // just tests that the (singleton) script-backed bean is able to be instantiated with references to its collaborators
    new ClassPathXmlApplicationContext("org/springframework/scripting/support/groovyReferences.xml");
View Full Code Here

    GenericApplicationContext ctx = new GenericApplicationContext();
    ctx.registerBeanDefinition(PROCESSOR_BEAN_NAME, processorBeanDefinition);
    ctx.registerBeanDefinition(MESSENGER_BEAN_NAME, scriptedBeanDefinition);
    final String collaboratorBeanName = "collaborator";
    ctx.registerBeanDefinition(collaboratorBeanName, collaboratorBuilder.getBeanDefinition());
    ctx.refresh();

    Messenger messenger = (Messenger) ctx.getBean(MESSENGER_BEAN_NAME);
    assertEquals(MESSAGE_TEXT, messenger.getMessage());
    // cool; now let's change the script and check the refresh behaviour...
    pauseToLetRefreshDelayKickIn(DEFAULT_SECONDS_TO_PAUSE);
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.