Search in sources :

Example 6 with BusLifeCycleListener

use of org.apache.cxf.buslifecycle.BusLifeCycleListener in project cxf by apache.

the class BusDefinitionParserTest method testBusConfigureCreateBus.

@Test
public void testBusConfigureCreateBus() {
    ClassPathXmlApplicationContext context = null;
    final AtomicBoolean b = new AtomicBoolean();
    try {
        context = new ClassPathXmlApplicationContext("org/apache/cxf/bus/spring/customerBus2.xml");
        Bus cxf1 = (Bus) context.getBean("cxf1");
        assertTrue(cxf1.getOutInterceptors().size() == 1);
        assertTrue(cxf1.getInInterceptors().isEmpty());
        Bus cxf2 = (Bus) context.getBean("cxf2");
        assertTrue(cxf2.getInInterceptors().size() == 1);
        assertTrue(cxf2.getOutInterceptors().isEmpty());
        cxf2.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(new BusLifeCycleListener() {

            public void initComplete() {
            }

            public void preShutdown() {
            }

            public void postShutdown() {
                b.set(true);
            }
        });
    } finally {
        if (context != null) {
            context.close();
        }
    }
    assertTrue("postShutdown not called", b.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Bus(org.apache.cxf.Bus) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) BusLifeCycleManager(org.apache.cxf.buslifecycle.BusLifeCycleManager) BusLifeCycleListener(org.apache.cxf.buslifecycle.BusLifeCycleListener) Test(org.junit.Test)

Aggregations

BusLifeCycleListener (org.apache.cxf.buslifecycle.BusLifeCycleListener)6 Bus (org.apache.cxf.Bus)5 Test (org.junit.Test)5 BusLifeCycleManager (org.apache.cxf.buslifecycle.BusLifeCycleManager)4 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 ExtensionManagerBus (org.apache.cxf.bus.extension.ExtensionManagerBus)1 CXFBusLifeCycleManager (org.apache.cxf.bus.managers.CXFBusLifeCycleManager)1 ConfiguredBeanLocator (org.apache.cxf.configuration.ConfiguredBeanLocator)1 AbstractRefreshableApplicationContext (org.springframework.context.support.AbstractRefreshableApplicationContext)1