Package org.springframework.context.support

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


    ctx.registerPrototype("testService", TestService.class, new MutablePropertyValues());
    ctx.registerAlias("testService", "1");
    MutablePropertyValues mpv = new MutablePropertyValues();
    mpv.addPropertyValue("serviceLocatorInterface", TestServiceLocator3.class);
    ctx.registerSingleton("factory", ServiceLocatorFactoryBean.class, mpv);
    ctx.refresh();

    TestServiceLocator3 factory = (TestServiceLocator3) ctx.getBean("factory");
    TestService testBean1 = factory.getTestService();
    TestService testBean2 = factory.getTestService("testService");
    TestService testBean3 = factory.getTestService(1);
View Full Code Here


    ctx.registerPrototype("testService2", ExtendedTestService.class, new MutablePropertyValues());
    MutablePropertyValues mpv = new MutablePropertyValues();
    mpv.addPropertyValue("serviceLocatorInterface", TestServiceLocator3.class);
    mpv.addPropertyValue("serviceMappings", "=testService1\n1=testService1\n2=testService2");
    ctx.registerSingleton("factory", ServiceLocatorFactoryBean.class, mpv);
    ctx.refresh();

    TestServiceLocator3 factory = (TestServiceLocator3) ctx.getBean("factory");
    TestService testBean1 = factory.getTestService();
    TestService testBean2 = factory.getTestService("testService1");
    TestService testBean3 = factory.getTestService(1);
View Full Code Here

        this.proxyController = new ProxyController();
        this.proxyController
            .setCentralAuthenticationService(getCentralAuthenticationService());

        StaticApplicationContext context = new StaticApplicationContext();
        context.refresh();
        this.proxyController.setApplicationContext(context);
    }

    @Test
    public void testNoParams() throws Exception {
View Full Code Here

    private ServiceValidateController serviceValidateController;

    @Before
    public void onSetUp() throws Exception {
        StaticApplicationContext context = new StaticApplicationContext();
        context.refresh();
        this.serviceValidateController = new ServiceValidateController();
        this.serviceValidateController
            .setCentralAuthenticationService(getCentralAuthenticationService());
        final Cas20ProxyHandler proxyHandler = new Cas20ProxyHandler();
        proxyHandler.setHttpClient(new HttpClient());
View Full Code Here

  public void testContextStartedEvent() {
    StaticApplicationContext context = new StaticApplicationContext();
    context.registerSingleton("lifecycle", LifecycleTestBean.class);
    context.registerSingleton("listener", LifecycleListener.class);
    context.refresh();
    LifecycleTestBean lifecycleBean = (LifecycleTestBean) context.getBean("lifecycle");
    LifecycleListener listener = (LifecycleListener) context.getBean("listener");
    assertFalse(lifecycleBean.isRunning());
    assertEquals(0, listener.getStartedCount());
    context.start();
View Full Code Here

  public void testContextStoppedEvent() {
    StaticApplicationContext context = new StaticApplicationContext();
    context.registerSingleton("lifecycle", LifecycleTestBean.class);
    context.registerSingleton("listener", LifecycleListener.class);
    context.refresh();
    LifecycleTestBean lifecycleBean = (LifecycleTestBean) context.getBean("lifecycle");
    LifecycleListener listener = (LifecycleListener) context.getBean("listener");
    assertFalse(lifecycleBean.isRunning());
    context.start();
    assertTrue(lifecycleBean.isRunning());
View Full Code Here

    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("applicationEventClass", TestEvent.class.getName());
    // should automatically receive applicationEventPublisher reference
    ctx.registerSingleton("publisher", EventPublicationInterceptor.class, pvs);
    ctx.registerSingleton("otherListener", FactoryBeanTestListener.class);
    ctx.refresh();

    EventPublicationInterceptor interceptor =
        (EventPublicationInterceptor) ctx.getBean("publisher");
    ProxyFactory factory = new ProxyFactory(target);
    factory.addAdvice(0, interceptor);
View Full Code Here

    context.registerBeanDefinition("broadcaster", new RootBeanDefinition(BeanThatBroadcasts.class));
    RootBeanDefinition listenerDef = new RootBeanDefinition(BeanThatListens.class);
    listenerDef.getConstructorArgumentValues().addGenericArgumentValue(new RuntimeBeanReference("broadcaster"));
    context.registerBeanDefinition("listener", listenerDef);
    try {
      context.refresh();
      fail("Should have thrown BeanCreationException with nested BeanCurrentlyInCreationException");
    }
    catch (BeanCreationException ex) {
      assertTrue(ex.contains(BeanCurrentlyInCreationException.class));
    }
View Full Code Here

    StaticApplicationContext context = new StaticApplicationContext();
    context.registerBeanDefinition("broadcaster", new RootBeanDefinition(BeanThatBroadcasts.class));
    RootBeanDefinition listenerDef = new RootBeanDefinition(BeanThatListens.class);
    listenerDef.getConstructorArgumentValues().addGenericArgumentValue(new RuntimeBeanReference("broadcaster"));
    context.registerBeanDefinition("listener", listenerDef);
    context.refresh();

    BeanThatBroadcasts broadcaster = (BeanThatBroadcasts) context.getBean("broadcaster");
    context.publishEvent(new MyEvent(context));
    assertEquals("The event was not received by the listener", 2, broadcaster.receivedCount);
  }
View Full Code Here

        };
        MessageSourceAccessor accessor = new MessageSourceAccessor(source);
        applicationServices.setMessageSourceAccesor(accessor);
        applicationServices.setMessageSource(source);

        applicationContext.refresh();

        // create formmodel to test on and initialize value models
        model = FormModelHelper.createFormModel(new ValidatingObject());
        model.getValueModel("stringValue");
        model.getValueModel("intValue");
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.