use of org.apache.camel.processor.DelegateAsyncProcessor in project camel by apache.
the class ProcessDefinition method createProcessor.
@Override
public Processor createProcessor(RouteContext routeContext) {
Processor answer = processor;
if (processor == null) {
ObjectHelper.notNull(ref, "ref", this);
answer = routeContext.mandatoryLookup(getRef(), Processor.class);
}
// (a Processor must be a Service to be enlisted in JMX)
if (!(answer instanceof Service)) {
if (answer instanceof AsyncProcessor) {
// the processor is async by nature so use the async delegate
answer = new DelegateAsyncProcessor(answer);
} else {
// the processor is sync by nature so use the sync delegate
answer = new DelegateSyncProcessor(answer);
}
}
return answer;
}
use of org.apache.camel.processor.DelegateAsyncProcessor in project camel by apache.
the class Debug method wrapProcessorInInterceptors.
public Processor wrapProcessorInInterceptors(final CamelContext context, final ProcessorDefinition<?> definition, final Processor target, final Processor nextTarget) throws Exception {
return new DelegateAsyncProcessor(target) {
@Override
public boolean process(final Exchange exchange, final AsyncCallback callback) {
debugger.beforeProcess(exchange, target, definition);
final StopWatch watch = new StopWatch();
return processor.process(exchange, new AsyncCallback() {
public void done(boolean doneSync) {
long diff = watch.stop();
debugger.afterProcess(exchange, processor, definition, diff);
// must notify original callback
callback.done(doneSync);
}
});
}
@Override
public String toString() {
return "Debug[" + target + "]";
}
};
}
Aggregations