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());
}
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations