Java 类org.apache.camel.processor.DelegateAsyncProcessor 实例源码

项目:eds    文件:DemoInterceptor.java   
@Override
    public Processor wrapProcessorInInterceptors(CamelContext context,
            final ProcessorDefinition<?> definition, final Processor target,
            final Processor nextTarget) throws Exception {
        return new DelegateAsyncProcessor(new Processor() {
            @Override
            public void process(Exchange exchange) throws Exception {
//              if(!camelConfig.isRunning()){
//                  System.err.println("系统将关闭,不在处理任务");
//                  return ;
//              }
                System.out.println("defainition :"+definition);
                System.out.println("nextTarget :"+nextTarget);
                target.process(exchange);
            }
        });
    }
项目:Camel    文件:Debug.java   
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 + "]";
        }
    };
}
项目:Camel    文件:NoErrorHandlerBuilder.java   
public Processor createErrorHandler(RouteContext routeContext, Processor processor) {
    return new DelegateAsyncProcessor(processor) {
        @Override
        public boolean process(final Exchange exchange, final AsyncCallback callback) {
            return super.process(exchange, new AsyncCallback() {
                @Override
                public void done(boolean doneSync) {
                    exchange.removeProperty(Exchange.REDELIVERY_EXHAUSTED);
                    callback.done(doneSync);
                }
            });
        }

        @Override
        public String toString() {
            if (processor == null) {
                // if no output then dont do any description
                return "";
            }
            return "NoErrorHandler[" + processor + "]";
        }
    };
}
项目:Camel    文件:AdviceWithStartTargetIssueTest.java   
public Processor wrapProcessorInInterceptors(final CamelContext context, final ProcessorDefinition<?> definition,
                                             final Processor target, final Processor nextTarget) throws Exception {

    return new DelegateAsyncProcessor(new Processor() {

        public void process(Exchange exchange) throws Exception {
            // we just count number of interceptions
            count++;
            LOG.info("I am the container wide interceptor. Intercepted total count: " + count);
            target.process(exchange);
        }

        @Override
        public String toString() {
            return "ContainerWideInterceptor[" + target + "]";
        }
    });
}
项目:Camel    文件:AsyncEndpointCustomAsyncInterceptorTest.java   
public Processor wrapProcessorInInterceptors(final CamelContext context, final ProcessorDefinition<?> definition,
                                             final Processor target, final Processor nextTarget) throws Exception {

    // use DelegateAsyncProcessor to ensure the interceptor works well with the asynchronous routing
    // engine in Camel.
    // The target is the processor to continue routing to, which we must provide
    // in the constructor of the DelegateAsyncProcessor
    return new DelegateAsyncProcessor(target) {
        @Override
        public boolean process(Exchange exchange, AsyncCallback callback) {
            // we just want to count number of interceptions
            counter.incrementAndGet();

            // invoke processor to continue routing the message
            return processor.process(exchange, callback);
        }
    };
}
项目:Camel    文件:AuditInterceptorAsyncDelegateIssueTest.java   
public Processor wrapProcessorInInterceptors(CamelContext context, ProcessorDefinition<?> definition, Processor target, Processor nextTarget) throws Exception {
    return new DelegateAsyncProcessor(target) {
        public boolean process(Exchange exchange, AsyncCallback callback) {
            invoked = true;
            return processor.process(exchange, callback);
        }
    };
}
项目:omakase    文件:CamelBeanProcessorInterceptor.java   
@Override
public Processor wrapProcessorInInterceptors(CamelContext context, ProcessorDefinition<?> definition, Processor target, Processor nextTarget) throws Exception {
    if ("bean".equals(definition.getShortName())) {
        return new DelegateAsyncProcessor(exchange -> processorProxy.doAsSystem(target, exchange));
    } else {
        return target;
    }
}
项目:camelinaction2    文件:MyInterceptor.java   
public Processor wrapProcessorInInterceptors(CamelContext context,
        ProcessorDefinition<?> definition, final Processor target,
        Processor nextTarget) throws Exception {

    return new DelegateAsyncProcessor(new Processor() {

        public void process(Exchange exchange) throws Exception {
            LOG.info("Before the processor...");
            target.process(exchange);
            LOG.info("After the processor...");
        }
    });
}
项目:camelinaction    文件:MyInterceptor.java   
public Processor wrapProcessorInInterceptors(CamelContext context,
        ProcessorDefinition<?> definition, final Processor target,
        Processor nextTarget) throws Exception {

    return new DelegateAsyncProcessor(new Processor() {

        public void process(Exchange exchange) throws Exception {
            LOG.info("Before the processor...");
            target.process(exchange);
            LOG.info("After the processor...");
        }
    });
}
项目:bio2rdf-rest    文件:CamelStat.java   
public void initStatisticsInterceptor() throws NullPointerException {
      theContext.addInterceptStrategy(new InterceptStrategy() {

    public Processor wrapProcessorInInterceptors(CamelContext context,
            final ProcessorDefinition<?> node, final Processor target,
            Processor nextTarget) throws Exception {
        return new DelegateAsyncProcessor(target) {
            public boolean process(Exchange exchange, AsyncCallback callback) {
                CamelStat.this.addRowByTargetNode(node.getId());
                return super.process(exchange, callback);
            }
        };
    }
});
  }
项目:t4f-data    文件:MyInterceptor.java   
public Processor wrapProcessorInInterceptors(CamelContext context,
        ProcessorDefinition<?> definition, final Processor target,
        Processor nextTarget) throws Exception {
    // to make the Default channel happy
    return new DelegateAsyncProcessor(new Processor() {

        public void process(Exchange exchange) throws Exception {
            log.info("Before the processor...");
            target.process(exchange);
            log.info("After the processor...");
        }
    });
}