// and wrap in unit of work
String routeId = routeContext.getRoute().idOrCreate(routeContext.getCamelContext().getNodeIdFactory());
CamelInternalProcessor internal = new CamelInternalProcessor(target);
internal.addAdvice(new CamelInternalProcessor.UnitOfWorkProcessorAdvice(routeId));
WireTapProcessor answer = new WireTapProcessor(endpoint, internal, 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 = createProcessor(routeContext, header);
answer.addNewExchangeProcessor(processor);
}
}
if (onPrepareRef != null) {
onPrepare = CamelContextHelper.mandatoryLookup(routeContext.getCamelContext(), onPrepareRef, Processor.class);
}
if (onPrepare != null) {
answer.setOnPrepare(onPrepare);
}
return answer;
}