if (doIt) {
if (event instanceof ContextRefreshedEvent) {
Bus bus = (Bus)ctx.getBean("cxf");
((CXFBusImpl)bus).initialize();
BusLifeCycleManager lcm = (BusLifeCycleManager)
ctx.getBean("org.apache.cxf.buslifecycle.BusLifeCycleManager",
BusLifeCycleManager.class);
lcm.initComplete();
} else if (event instanceof ContextClosedEvent && ctx.isActive()) {
// To avoid the ctx to be closed twice
BusLifeCycleManager lcm = (BusLifeCycleManager)ctx
.getBean("org.apache.cxf.buslifecycle.BusLifeCycleManager", BusLifeCycleManager.class);
lcm.postShutdown();
}
}
}