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);
}
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);
}
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();
}
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);
}
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"));
}
Aggregations