private void fireInterceptors(Exchange ex) throws HandlerException {
Map<String, ExchangeInterceptor> interceptors =
ex.getContext().getRegistry().lookupByType(ExchangeInterceptor.class);
if (interceptors != null && interceptors.size() > 0) {
CamelExchange syEx = new CamelExchange(ex);
try {
// Seed these values up front so that interceptors don't mess with them
boolean callBefore = isBefore(ex);
boolean callAfter = isAfter(ex);
for (ExchangeInterceptor interceptor : interceptors.values()) {
// Is the interceptor targeting this processor?
if (!matchesTarget(interceptor)) {
continue;
}
if (callBefore) {
interceptor.before(_target, syEx);
} else if (callAfter) {
try {
interceptor.after(_target, syEx);
} catch (Exception error) {
// If we are already in fault state, don't allow the
// interceptor to throw again - this blows up the route
if (ExchangeState.FAULT.equals(syEx.getState())) {
BusLogger.ROOT_LOGGER.alreadyInFaultState(error);
} else {
if (error instanceof HandlerException) {
throw (HandlerException)error;
} else {