Search in sources :

Example 1 with BusLifeCycleListener

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

the class CXFBusLifeCycleManager method initComplete.

public void initComplete() {
    if (bus != null) {
        bus.getExtension(ConfiguredBeanLocator.class).getBeansOfType(BusLifeCycleListener.class);
    }
    preShutdownCalled = false;
    postShutdownCalled = false;
    initCalled = true;
    for (BusLifeCycleListener listener : listeners) {
        listener.initComplete();
    }
}
Also used : ConfiguredBeanLocator(org.apache.cxf.configuration.ConfiguredBeanLocator) BusLifeCycleListener(org.apache.cxf.buslifecycle.BusLifeCycleListener)

Example 2 with BusLifeCycleListener

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

the class CXFBusImplTest method testShutdownWithBusLifecycle.

@Test
public void testShutdownWithBusLifecycle() {
    final Bus bus = new ExtensionManagerBus();
    BusLifeCycleManager lifeCycleManager = bus.getExtension(BusLifeCycleManager.class);
    BusLifeCycleListener listener = EasyMock.createMock(BusLifeCycleListener.class);
    EasyMock.reset(listener);
    listener.preShutdown();
    EasyMock.expectLastCall();
    listener.postShutdown();
    EasyMock.expectLastCall();
    EasyMock.replay(listener);
    lifeCycleManager.registerLifeCycleListener(listener);
    bus.shutdown(true);
    EasyMock.verify(listener);
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) BusLifeCycleManager(org.apache.cxf.buslifecycle.BusLifeCycleManager) BusLifeCycleListener(org.apache.cxf.buslifecycle.BusLifeCycleListener) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) Test(org.junit.Test)

Example 3 with BusLifeCycleListener

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

the class SpringBusFactoryTest method testForLifeCycle.

@Test
public void testForLifeCycle() {
    BusLifeCycleListener bl = EasyMock.createMock(BusLifeCycleListener.class);
    Bus bus = new SpringBusFactory().createBus();
    BusLifeCycleManager lifeCycleManager = bus.getExtension(BusLifeCycleManager.class);
    lifeCycleManager.registerLifeCycleListener(bl);
    EasyMock.reset(bl);
    bl.preShutdown();
    EasyMock.expectLastCall();
    bl.postShutdown();
    EasyMock.expectLastCall();
    EasyMock.replay(bl);
    bus.shutdown(true);
    EasyMock.verify(bl);
}
Also used : Bus(org.apache.cxf.Bus) BusLifeCycleListener(org.apache.cxf.buslifecycle.BusLifeCycleListener) BusLifeCycleManager(org.apache.cxf.buslifecycle.BusLifeCycleManager) Test(org.junit.Test)

Example 4 with BusLifeCycleListener

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

the class SpringBeansTest method testChildContext.

@Test
public void testChildContext() throws Exception {
    // Test for CXF-2283 - if a Child context is closed,
    // we shouldn't be shutting down
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] { "/org/apache/cxf/jaxws/spring/servers.xml" });
    final Bus b = (Bus) ctx.getBean("cxf");
    BusLifeCycleManager lifeCycleManager = b.getExtension(BusLifeCycleManager.class);
    BusLifeCycleListener listener = new BusLifeCycleListener() {

        public void initComplete() {
        }

        public void postShutdown() {
            b.setProperty("post.was.called", Boolean.TRUE);
        }

        public void preShutdown() {
            b.setProperty("pre.was.called", Boolean.TRUE);
        }
    };
    lifeCycleManager.registerLifeCycleListener(listener);
    ClassPathXmlApplicationContext ctx2 = new ClassPathXmlApplicationContext(new String[] { "/org/apache/cxf/jaxws/spring/child.xml" }, ctx);
    ctx2.close();
    assertNull(b.getProperty("post.was.called"));
    assertNull(b.getProperty("pre.was.called"));
}
Also used : 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)

Example 5 with BusLifeCycleListener

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

the class BusApplicationListenerTest method testParentApplicationEvent.

@Test
public void testParentApplicationEvent() {
    AbstractRefreshableApplicationContext parent = new ClassPathXmlApplicationContext();
    parent.refresh();
    SpringBusFactory factory = new SpringBusFactory(parent);
    Bus bus = factory.createBus();
    CXFBusLifeCycleManager manager = bus.getExtension(CXFBusLifeCycleManager.class);
    BusLifeCycleListener listener = EasyMock.createMock(BusLifeCycleListener.class);
    manager.registerLifeCycleListener(listener);
    EasyMock.reset(listener);
    listener.preShutdown();
    EasyMock.expectLastCall().times(1);
    listener.postShutdown();
    EasyMock.expectLastCall().times(1);
    EasyMock.replay(listener);
    parent.close();
    EasyMock.verify(listener);
}
Also used : Bus(org.apache.cxf.Bus) AbstractRefreshableApplicationContext(org.springframework.context.support.AbstractRefreshableApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) BusLifeCycleListener(org.apache.cxf.buslifecycle.BusLifeCycleListener) CXFBusLifeCycleManager(org.apache.cxf.bus.managers.CXFBusLifeCycleManager) 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