// create error handler we need to use for processing the wire tapped
Processor target = wrapInErrorHandler(routeContext, producer);
// and wrap in UoW, which is needed for error handler as well
target = new UnitOfWorkProcessor(routeContext, target);
WireTapProcessor answer = new WireTapProcessor(endpoint, target, getPattern(), threadPool, shutdownThreadPool);
answer.setCopy(isCopy());
if (newExchangeProcessorRef != null) {
newExchangeProcessor = routeContext.mandatoryLookup(newExchangeProcessorRef, Processor.class);
}
if (newExchangeProcessor != null) {
answer.addNewExchangeProcessor(newExchangeProcessor);
}
if (newExchangeExpression != null) {
answer.setNewExchangeExpression(newExchangeExpression.createExpression(routeContext));
}
if (headers != null && !headers.isEmpty()) {
for (SetHeaderDefinition header : headers) {
Processor processor = header.createProcessor(routeContext);
answer.addNewExchangeProcessor(processor);
}
}
if (onPrepareRef != null) {
onPrepare = CamelContextHelper.mandatoryLookup(routeContext.getCamelContext(), onPrepareRef, Processor.class);
}
if (onPrepare != null) {
answer.setOnPrepare(onPrepare);
}
return answer;
}