Search in sources :

Example 1 with BusLifeCycleManager

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

the class ExtensionManagerBus method shutdown.

public void shutdown(boolean wait) {
    if (state == BusState.SHUTTING_DOWN) {
        return;
    }
    BusLifeCycleManager lifeCycleManager = this.getExtension(BusLifeCycleManager.class);
    if (null != lifeCycleManager) {
        lifeCycleManager.preShutdown();
    }
    synchronized (this) {
        state = BusState.SHUTTING_DOWN;
    }
    destroyBeans();
    synchronized (this) {
        state = BusState.SHUTDOWN;
        notifyAll();
    }
    if (null != lifeCycleManager) {
        lifeCycleManager.postShutdown();
    }
    if (BusFactory.getDefaultBus(false) == this) {
        BusFactory.setDefaultBus(null);
    }
    BusFactory.clearDefaultBusForAnyThread(this);
}
Also used : BusLifeCycleManager(org.apache.cxf.buslifecycle.BusLifeCycleManager)

Example 2 with BusLifeCycleManager

use of org.apache.cxf.buslifecycle.BusLifeCycleManager 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 BusLifeCycleManager

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

the class OSGiBusListenerTest method setUp.

@Before
public void setUp() {
    control = EasyMock.createNiceControl();
    bus = control.createMock(Bus.class);
    BusLifeCycleManager blcManager = control.createMock(BusLifeCycleManager.class);
    EasyMock.expect(bus.getExtension(BusLifeCycleManager.class)).andReturn(blcManager).anyTimes();
    blcManager.registerLifeCycleListener(EasyMock.isA(OSGIBusListener.class));
    EasyMock.expectLastCall();
    bundleContext = control.createMock(BundleContext.class);
    BundleContext app = control.createMock(BundleContext.class);
    EasyMock.expect(bus.getExtension(BundleContext.class)).andReturn(app).anyTimes();
    bundle = control.createMock(Bundle.class);
    EasyMock.expect(app.getBundle()).andReturn(bundle).anyTimes();
    EasyMock.expect(bundle.getSymbolicName()).andReturn(BUNDLE_NAME).anyTimes();
}
Also used : Bus(org.apache.cxf.Bus) Bundle(org.osgi.framework.Bundle) BusLifeCycleManager(org.apache.cxf.buslifecycle.BusLifeCycleManager) BundleContext(org.osgi.framework.BundleContext) Before(org.junit.Before)

Example 4 with BusLifeCycleManager

use of org.apache.cxf.buslifecycle.BusLifeCycleManager 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 5 with BusLifeCycleManager

use of org.apache.cxf.buslifecycle.BusLifeCycleManager 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)

Aggregations

BusLifeCycleManager (org.apache.cxf.buslifecycle.BusLifeCycleManager)13 Bus (org.apache.cxf.Bus)5 BusLifeCycleListener (org.apache.cxf.buslifecycle.BusLifeCycleListener)5 Test (org.junit.Test)3 ManagedBus (org.apache.cxf.bus.ManagedBus)2 IOException (java.io.IOException)1 PostConstruct (javax.annotation.PostConstruct)1 JMException (javax.management.JMException)1 MBeanServer (javax.management.MBeanServer)1 ExtensionManagerBus (org.apache.cxf.bus.extension.ExtensionManagerBus)1 BusCreationListener (org.apache.cxf.buslifecycle.BusCreationListener)1 ConfiguredBeanLocator (org.apache.cxf.configuration.ConfiguredBeanLocator)1 ClientLifeCycleManager (org.apache.cxf.endpoint.ClientLifeCycleManager)1 ConduitSelector (org.apache.cxf.endpoint.ConduitSelector)1 ConduitSelectorHolder (org.apache.cxf.endpoint.ConduitSelectorHolder)1 ServerLifeCycleManager (org.apache.cxf.endpoint.ServerLifeCycleManager)1 Capture (org.easymock.Capture)1 Before (org.junit.Before)1 Bundle (org.osgi.framework.Bundle)1 BundleContext (org.osgi.framework.BundleContext)1