Search in sources :

Example 11 with BusLifeCycleManager

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);
    }
}
Also used : ServerLifeCycleManager(org.apache.cxf.endpoint.ServerLifeCycleManager) ClientLifeCycleManager(org.apache.cxf.endpoint.ClientLifeCycleManager) BusLifeCycleManager(org.apache.cxf.buslifecycle.BusLifeCycleManager)

Example 12 with BusLifeCycleManager

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);
        }
    }
}
Also used : ConduitSelectorHolder(org.apache.cxf.endpoint.ConduitSelectorHolder) BusLifeCycleManager(org.apache.cxf.buslifecycle.BusLifeCycleManager) ConduitSelector(org.apache.cxf.endpoint.ConduitSelector)

Example 13 with BusLifeCycleManager

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);
        }
    });
}
Also used : BusLifeCycleManager(org.apache.cxf.buslifecycle.BusLifeCycleManager) BusLifeCycleListener(org.apache.cxf.buslifecycle.BusLifeCycleListener)

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 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 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1