Search in sources :

Example 1 with ConduitSelector

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

the class CxfClientCallback method handleException.

public void handleException(Map<String, Object> ctx, Throwable ex) {
    try {
        super.handleException(ctx, ex);
        // need to call the conduitSelector complete method to enable the fail over feature
        ConduitSelector conduitSelector = cxfExchange.get(ConduitSelector.class);
        if (conduitSelector != null) {
            conduitSelector.complete(cxfExchange);
            ex = cxfExchange.getOutMessage().getContent(Exception.class);
            if (ex == null && cxfExchange.getInMessage() != null) {
                ex = cxfExchange.getInMessage().getContent(Exception.class);
            }
            if (ex != null) {
                camelExchange.setException(ex);
            }
        } else {
            camelExchange.setException(ex);
        }
    } finally {
        // add cookies to the cookie store
        if (endpoint.getCookieHandler() != null) {
            try {
                Map<String, List<String>> cxfHeaders = CastUtils.cast((Map<?, ?>) cxfExchange.getInMessage().get(Message.PROTOCOL_HEADERS));
                endpoint.getCookieHandler().storeCookies(camelExchange, endpoint.getRequestUri(camelExchange), cxfHeaders);
            } catch (IOException e) {
                LOG.error("Cannot store cookies", e);
            }
        }
        // process method of org.apache.camel.component.cxf.CxfProducer
        if (!boi.getOperationInfo().isOneWay()) {
            endpoint.getCxfBinding().populateExchangeFromCxfResponse(camelExchange, cxfExchange, ctx);
            camelAsyncCallback.done(false);
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug("{} calling handleException", Thread.currentThread().getName());
        }
    }
}
Also used : List(java.util.List) IOException(java.io.IOException) ConduitSelector(org.apache.cxf.endpoint.ConduitSelector) IOException(java.io.IOException)

Example 2 with ConduitSelector

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

the class FailoverAddressOverrideTest method verifyStrategy.

protected void verifyStrategy(Object proxy, Class<?> clz, int count) {
    ConduitSelector conduitSelector = ClientProxy.getClient(proxy).getConduitSelector();
    if (conduitSelector instanceof FailoverTargetSelector) {
        AbstractStaticFailoverStrategy strategy = (AbstractStaticFailoverStrategy) ((FailoverTargetSelector) conduitSelector).getStrategy();
        assertTrue("unexpected strategy", clz.isInstance(strategy));
        List<String> alternates = strategy.getAlternateAddresses(null);
        assertNotNull("expected alternate addresses", alternates);
        assertEquals("unexpected alternate addresses", count, alternates.size());
    } else {
        fail("unexpected conduit selector: " + conduitSelector);
    }
}
Also used : AbstractStaticFailoverStrategy(org.apache.cxf.clustering.AbstractStaticFailoverStrategy) FailoverTargetSelector(org.apache.cxf.clustering.FailoverTargetSelector) ConduitSelector(org.apache.cxf.endpoint.ConduitSelector)

Example 3 with ConduitSelector

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

the class FailoverTest method verifyStrategy.

protected void verifyStrategy(Object proxy, Class<?> clz) {
    ConduitSelector conduitSelector = ClientProxy.getClient(proxy).getConduitSelector();
    if (conduitSelector instanceof FailoverTargetSelector) {
        Object strategy = ((FailoverTargetSelector) conduitSelector).getStrategy();
        assertTrue("unexpected strategy", clz.isInstance(strategy));
    } else {
        fail("unexpected conduit selector: " + conduitSelector);
    }
}
Also used : FailoverTargetSelector(org.apache.cxf.clustering.FailoverTargetSelector) ConduitSelector(org.apache.cxf.endpoint.ConduitSelector)

Example 4 with ConduitSelector

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

the class FailoverFeature method initializeProvider.

@Override
protected void initializeProvider(InterceptorProvider provider, Bus bus) {
    if (provider instanceof ConduitSelectorHolder) {
        ConduitSelectorHolder csHolder = (ConduitSelectorHolder) provider;
        Endpoint endpoint = csHolder.getConduitSelector().getEndpoint();
        ConduitSelector conduitSelector = initTargetSelector(endpoint);
        csHolder.setConduitSelector(conduitSelector);
    }
}
Also used : Endpoint(org.apache.cxf.endpoint.Endpoint) ConduitSelectorHolder(org.apache.cxf.endpoint.ConduitSelectorHolder) ConduitSelector(org.apache.cxf.endpoint.ConduitSelector)

Example 5 with ConduitSelector

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

the class AbstractFailoverTest method verifyStrategy.

protected void verifyStrategy(Object proxy, Class<?> clz) {
    ConduitSelector conduitSelector = WebClient.getConfig(proxy).getConduitSelector();
    if (conduitSelector instanceof FailoverTargetSelector) {
        Object strategy = ((FailoverTargetSelector) conduitSelector).getStrategy();
        assertTrue("unexpected strategy", clz.isInstance(strategy));
    } else {
        fail("unexpected conduit selector: " + conduitSelector);
    }
}
Also used : FailoverTargetSelector(org.apache.cxf.clustering.FailoverTargetSelector) ConduitSelector(org.apache.cxf.endpoint.ConduitSelector)

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