List<Interceptor> i4 = endpoint.getBinding().getInInterceptors();
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Interceptors contributed by binding: " + i4);
}
PhaseInterceptorChain chain;
if (endpoint.getService().getDataBinding() instanceof InterceptorProvider) {
InterceptorProvider p = (InterceptorProvider)endpoint.getService().getDataBinding();
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Interceptors contributed by databinging: " + p.getInInterceptors());
}
chain = inboundChainCache.get(pm.getInPhases(), i1, i2, i3, i4,
p.getInInterceptors());
} else {
chain = inboundChainCache.get(pm.getInPhases(), i1, i2, i3, i4);
}
message.setInterceptorChain(chain);
chain.setFaultObserver(outFaultObserver);
modifyChain(chain, message, true);
modifyChain(chain, message.getExchange().getOutMessage(), true);
Bus origBus = BusFactory.getThreadDefaultBus(false);
BusFactory.setThreadDefaultBus(bus);
// execute chain
ClientCallback callback = message.getExchange().get(ClientCallback.class);
try {
if (callback != null) {
if (callback.isCancelled()) {
getConduitSelector().complete(message.getExchange());
return;
}
callback.start(message);
}
String startingAfterInterceptorID = (String) message.get(
PhaseInterceptorChain.STARTING_AFTER_INTERCEPTOR_ID);
String startingInterceptorID = (String) message.get(
PhaseInterceptorChain.STARTING_AT_INTERCEPTOR_ID);
if (startingAfterInterceptorID != null) {
chain.doInterceptStartingAfter(message, startingAfterInterceptorID);
} else if (startingInterceptorID != null) {
chain.doInterceptStartingAt(message, startingInterceptorID);
} else if (message.getContent(Exception.class) != null) {
outFaultObserver.onMessage(message);
} else {
callback = message.getExchange().get(ClientCallback.class);
if (callback != null && !isPartialResponse(message)) {
try {
chain.doIntercept(message);
} catch (Throwable error) {
//so that asyn callback handler get chance to
//handle non-runtime exceptions
message.getExchange().setInMessage(message);
Map<String, Object> resCtx = CastUtils
.cast((Map<?, ?>) message.getExchange()
.getOutMessage().get(
Message.INVOCATION_CONTEXT));
resCtx = CastUtils.cast((Map<?, ?>) resCtx
.get(RESPONSE_CONTEXT));
if (resCtx != null) {
responseContext.put(Thread.currentThread(), resCtx);
}
callback.handleException(resCtx, error);
}
} else {
chain.doIntercept(message);
}
}
callback = message.getExchange().get(ClientCallback.class);