public void onMessage(Message m) {
Bus origBus = BusFactory.getThreadDefaultBus(false);
BusFactory.setThreadDefaultBus(bus);
try {
InterceptorChain phaseChain = null;
if (m.getInterceptorChain() != null) {
phaseChain = m.getInterceptorChain();
synchronized (phaseChain) {
if (phaseChain.getState() == InterceptorChain.State.PAUSED) {
phaseChain.resume();
return;
}
}
}
Message message = getBinding().createMessage(m);
Exchange exchange = message.getExchange();
if (exchange == null) {
exchange = new ExchangeImpl();
m.setExchange(exchange);
}
exchange.setInMessage(message);
setExchangeProperties(exchange, message);
InterceptorProvider dbp = null;
if (endpoint.getService().getDataBinding() instanceof InterceptorProvider) {
dbp = (InterceptorProvider)endpoint.getService().getDataBinding();
}
// setup chain
if (dbp == null) {
phaseChain = chainCache.get(bus.getExtension(PhaseManager.class).getInPhases(),
bus.getInInterceptors(),
endpoint.getService().getInInterceptors(),
endpoint.getInInterceptors(),
getBinding().getInInterceptors());
} else {
phaseChain = chainCache.get(bus.getExtension(PhaseManager.class).getInPhases(),
bus.getInInterceptors(),
endpoint.getService().getInInterceptors(),
endpoint.getInInterceptors(),
getBinding().getInInterceptors(),
dbp.getInInterceptors());
}
message.setInterceptorChain(phaseChain);
phaseChain.setFaultObserver(endpoint.getOutFaultObserver());
addToChain(phaseChain, message);
phaseChain.doIntercept(message);
} finally {
BusFactory.setThreadDefaultBus(origBus);
}
}