Java 类org.apache.camel.impl.DefaultProducer 实例源码

项目:Camel    文件:TradeExecutorComponent.java   
@Override
public Producer createProducer() throws Exception {
    return new DefaultProducer(this) {
        @Override
        public void process(final Exchange exchange) throws Exception {
            executor.execute(new Runnable() {
                @Override
                public void run() {
                    try {
                        tradeExecutor.execute(exchange.getIn().getMandatoryBody(Message.class));
                    } catch (Exception e) {
                        log.error("Error during trade execution", e);
                    }
                }
            });
        }
    };
}
项目:Camel    文件:BrowseEndpoint.java   
public Producer createProducer() throws Exception {
    return new DefaultProducer(this) {
        public void process(Exchange exchange) throws Exception {
            onExchange(exchange);
        }
    };
}
项目:Camel    文件:EndpointWithRawUriParameterTest.java   
@Override
public Producer createProducer() throws Exception {
    return new DefaultProducer(this) {
        @Override
        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setHeader("username", getUsername());
            exchange.getIn().setHeader("password", getPassword());
            exchange.getIn().setHeader("lines", getLines());
        }
    };
}
项目:Camel    文件:WireTapOnExceptionTest.java   
@Override
public Producer createProducer() throws Exception {
    return new DefaultProducer(this) {
        @Override
        public void process(Exchange exchange) throws Exception {
            throw new IllegalArgumentException("Forced");
        }
    };
}
项目:Camel    文件:EventEndpoint.java   
public Producer createProducer() throws Exception {
    ObjectHelper.notNull(applicationContext, "applicationContext");
    return new DefaultProducer(this) {
        public void process(Exchange exchange) throws Exception {
            ApplicationEvent event = toApplicationEvent(exchange);
            applicationContext.publishEvent(event);
        }
    };
}
项目:incubator-batchee    文件:TestComponent.java   
@Override
protected Endpoint createEndpoint(final String uri, final String remaining, final Map<String, Object> parameters) throws Exception {
    final String value = String.class.cast(parameters.remove("value"));
    return new DefaultEndpoint() {
        @Override
        protected String createEndpointUri() {
            return uri;
        }

        @Override
        public Producer createProducer() throws Exception {
            return new DefaultProducer(this) {
                @Override
                public void process(final Exchange exchange) throws Exception {
                    exchange.getIn().setBody(exchange.getIn().getBody(String.class) + value);
                }
            };
        }

        @Override
        public Consumer createConsumer(final Processor processor) throws Exception {
            throw new UnsupportedOperationException();
        }

        @Override
        public boolean isSingleton() {
            return true;
        }
    };
}