use of org.apache.cxf.buslifecycle.BusLifeCycleManager in project fabric8 by jboss-fuse.
the class FabricLoadBalancerFeature method initialize.
public void initialize(Bus bus) {
try {
FabricServerListener lister = new FabricServerListener(getGroup(), addressResolver, getCurator());
// register the server listener itself
ServerLifeCycleManager serverMgr = bus.getExtension(ServerLifeCycleManager.class);
if (serverMgr != null) {
serverMgr.registerListener(lister);
} else {
LOG.error("Cannot find the ServerLifeCycleManager, we cannot publish the service through fabric.");
}
// register the client listener
ClientLifeCycleManager clientMgr = bus.getExtension(ClientLifeCycleManager.class);
FabricClientListener clientListener = new FabricClientListener(this);
if (clientMgr != null) {
clientMgr.registerListener(clientListener);
} else {
LOG.error("Cannot find the ClientLifeCycleManager, the client cannot access the service through fabric");
}
} catch (Exception ex) {
LOG.error("Cannot initialize the bus with FabricLoadBalancerFeature due to " + ex);
}
// setup the BusLifeCycleListener
BusLifeCycleManager manager = bus.getExtension(BusLifeCycleManager.class);
manager.registerLifeCycleListener(this);
try {
Thread.sleep(getWaitingForGroupEvent());
} catch (InterruptedException e) {
LOG.warn("InterruptedException when wait for the GroupEvent notification " + e);
}
}
use of org.apache.cxf.buslifecycle.BusLifeCycleManager in project fabric8 by jboss-fuse.
the class FabricLoadBalancerFeature method initialize.
// this method will be used for JAXRS client
public void initialize(InterceptorProvider interceptorProvider, Bus bus) {
// try to find if the InterceptorProvider is a ConduitSelectorHolder
if (interceptorProvider instanceof ConduitSelectorHolder) {
ConduitSelectorHolder holder = (ConduitSelectorHolder) interceptorProvider;
// get the endpoint of the original ConduitSelector
ConduitSelector oldSelector = holder.getConduitSelector();
LoadBalanceTargetSelector selector = getDefaultLoadBalanceTargetSelector();
selector.setEndpoint(oldSelector.getEndpoint());
try {
selector.setLoadBalanceStrategy(getLoadBalanceStrategy());
holder.setConduitSelector(selector);
} catch (Exception e) {
LOG.error("Cannot setup the LoadBalanceStrategy due to " + e);
}
// setup the BusLifeCycleListener
BusLifeCycleManager manager = bus.getExtension(BusLifeCycleManager.class);
manager.registerLifeCycleListener(this);
try {
Thread.sleep(getWaitingForGroupEvent());
} catch (InterruptedException e) {
LOG.warn("InterruptedException when wait for the GroupEvent notification " + e);
}
}
}
use of org.apache.cxf.buslifecycle.BusLifeCycleManager in project tesb-rt-se by Talend.
the class LocatorRegistrar method addLifeCycleListener.
private void addLifeCycleListener(final Bus bus) {
final BusLifeCycleManager manager = bus.getExtension(BusLifeCycleManager.class);
manager.registerLifeCycleListener(new BusLifeCycleListener() {
@Override
public void initComplete() {
}
@Override
public void preShutdown() {
// preShutdown
}
@Override
public void postShutdown() {
locatorClient.removePostConnectAction(busRegistrars.get(bus));
busRegistrars.remove(bus);
}
});
}
Aggregations