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