Search in sources :

Example 11 with ConduitSelector

use of org.apache.cxf.endpoint.ConduitSelector in project cxf by apache.

the class FailoverFeature method initialize.

@Override
public void initialize(Client client, Bus bus) {
    ConduitSelector selector = initTargetSelector(client.getConduitSelector().getEndpoint());
    client.setConduitSelector(selector);
}
Also used : ConduitSelector(org.apache.cxf.endpoint.ConduitSelector)

Example 12 with ConduitSelector

use of org.apache.cxf.endpoint.ConduitSelector in project cxf by apache.

the class ColocFeature method initialize.

@Override
public void initialize(Client client, Bus bus) {
    ConduitSelector selector = new DeferredConduitSelector();
    selector.setEndpoint(client.getEndpoint());
    client.setConduitSelector(selector);
    initializeProvider(client, bus);
}
Also used : ConduitSelector(org.apache.cxf.endpoint.ConduitSelector) DeferredConduitSelector(org.apache.cxf.endpoint.DeferredConduitSelector) DeferredConduitSelector(org.apache.cxf.endpoint.DeferredConduitSelector)

Example 13 with ConduitSelector

use of org.apache.cxf.endpoint.ConduitSelector 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 14 with ConduitSelector

use of org.apache.cxf.endpoint.ConduitSelector in project cxf by apache.

the class JAXRSClientFactoryBean method getConduitSelector.

protected ConduitSelector getConduitSelector(Endpoint ep) {
    ConduitSelector cs = getConduitSelector();
    if (cs == null) {
        cs = new UpfrontConduitSelector();
    }
    cs.setEndpoint(ep);
    return cs;
}
Also used : UpfrontConduitSelector(org.apache.cxf.endpoint.UpfrontConduitSelector) UpfrontConduitSelector(org.apache.cxf.endpoint.UpfrontConduitSelector) ConduitSelector(org.apache.cxf.endpoint.ConduitSelector)

Example 15 with ConduitSelector

use of org.apache.cxf.endpoint.ConduitSelector in project cxf by apache.

the class Proxy method createClient.

protected Client createClient(Bus bus, Endpoint endpoint, final ProtocolVariation protocol, Conduit conduit, final EndpointReferenceType address) {
    ConduitSelector cs = new DeferredConduitSelector(conduit) {

        @Override
        public synchronized Conduit selectConduit(Message message) {
            final Conduit conduit;
            EndpointInfo endpointInfo = getEndpoint().getEndpointInfo();
            EndpointReferenceType original = endpointInfo.getTarget();
            try {
                if (null != address) {
                    endpointInfo.setAddress(address);
                }
                conduit = super.selectConduit(message);
            } finally {
                endpointInfo.setAddress(original);
            }
            return conduit;
        }
    };
    RMClient client = new RMClient(bus, endpoint, cs);
    // WS-RM requires ws-addressing
    WSAddressingFeature wsa = new WSAddressingFeature();
    wsa.setAddressingRequired(true);
    wsa.initialize(client, bus);
    Map<String, Object> context = client.getRequestContext();
    context.put(MAPAggregator.ADDRESSING_NAMESPACE, protocol.getWSANamespace());
    context.put(RMManager.WSRM_VERSION_PROPERTY, protocol.getWSRMNamespace());
    context.put(RMManager.WSRM_WSA_VERSION_PROPERTY, protocol.getWSANamespace());
    return client;
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) WSAddressingFeature(org.apache.cxf.ws.addressing.WSAddressingFeature) Message(org.apache.cxf.message.Message) Conduit(org.apache.cxf.transport.Conduit) ConduitSelector(org.apache.cxf.endpoint.ConduitSelector) DeferredConduitSelector(org.apache.cxf.endpoint.DeferredConduitSelector) DeferredConduitSelector(org.apache.cxf.endpoint.DeferredConduitSelector)

Aggregations

ConduitSelector (org.apache.cxf.endpoint.ConduitSelector)17 Test (org.junit.Test)5 HashMap (java.util.HashMap)4 FailoverTargetSelector (org.apache.cxf.clustering.FailoverTargetSelector)4 LoadDistributorTargetSelector (org.apache.cxf.clustering.LoadDistributorTargetSelector)4 ConduitSelectorHolder (org.apache.cxf.endpoint.ConduitSelectorHolder)3 WebServiceException (javax.xml.ws.WebServiceException)2 DeferredConduitSelector (org.apache.cxf.endpoint.DeferredConduitSelector)2 Endpoint (org.apache.cxf.endpoint.Endpoint)2 Conduit (org.apache.cxf.transport.Conduit)2 IOException (java.io.IOException)1 List (java.util.List)1 Bus (org.apache.cxf.Bus)1 BusLifeCycleManager (org.apache.cxf.buslifecycle.BusLifeCycleManager)1 AbstractStaticFailoverStrategy (org.apache.cxf.clustering.AbstractStaticFailoverStrategy)1 UpfrontConduitSelector (org.apache.cxf.endpoint.UpfrontConduitSelector)1 Message (org.apache.cxf.message.Message)1 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)1 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)1 WSAddressingFeature (org.apache.cxf.ws.addressing.WSAddressingFeature)1