return wrapChannel(routeContext, processor, null);
}
protected Processor wrapChannel(RouteContext routeContext, Processor processor, ProcessorDefinition child) throws Exception {
// put a channel in between this and each output to control the route flow logic
Channel channel = createChannel(routeContext);
channel.setNextProcessor(processor);
// add interceptor strategies to the channel must be in this order: camel context, route context, local
addInterceptStrategies(routeContext, channel, routeContext.getCamelContext().getInterceptStrategies());
addInterceptStrategies(routeContext, channel, routeContext.getInterceptStrategies());
if (routeContext.getManagedInterceptStrategy() != null) {
channel.addInterceptStrategy(routeContext.getManagedInterceptStrategy());
}
addInterceptStrategies(routeContext, channel, this.getInterceptStrategies());
// must do this ugly cast to avoid compiler error on HP-UX
ProcessorDefinition defn = (ProcessorDefinition) this;
// set the child before init the channel
channel.setChildDefinition(child);
channel.initChannel(defn, routeContext);
// set the error handler, must be done after init as we can set the error handler as first in the chain
if (defn instanceof TryDefinition || defn instanceof CatchDefinition || defn instanceof FinallyDefinition) {
// do not use error handler for try .. catch .. finally blocks as it will handle errors itself
return channel;
} else if (defn instanceof MulticastDefinition || defn instanceof RecipientListDefinition) {
// do not use error handler for multicast or recipientlist based as it offers fine grained error handlers for its outputs
return channel;
} else {
// regular definition so add the error handler
Processor output = channel.getOutput();
Processor errorHandler = wrapInErrorHandler(routeContext, getErrorHandlerBuilder(), output);
// set error handler on channel
channel.setErrorHandler(errorHandler);
return channel;
}
}