Hi Lukasz,

Nice to hear from you :-)

> For example my route is following: 
> process(new LoggingProcessor()) 
> or 
> processRef("loggingProcessor") 
As far as I know No, as interception for a given processor is not given at
the DSL level. However what you could do is to make use of your own
InterceptStrategy, something like:

    private static class LoggingProcessorInterceptor implements
InterceptStrategy {

        @Override
        public Processor wrapProcessorInInterceptors(CamelContext context,
ProcessorDefinition<?> definition, final Processor target, Processor
nextTarget) throws Exception {
            if ("process[MyLoggingProcessor]".equals(definition.toString()))
{
                return new Processor() {
                    public void process(Exchange exchange) throws Exception
{
                        // do some interception logic here...
                       
exchange.getContext().createProducerTemplate().requestBody("mock:intercepted",
exchange.getIn().getBody());

                        // and then continue with the given target
                        target.process(exchange);
                    }
                };
            }

            return target;
        }
    }

Where your LoggingProcessor is given as something like:

    private static class LoggingProcessor implements Processor {

        @Override
        public void process(Exchange exchange) throws Exception {
            // your logging logic
        }

        @Override
        public String toString() {
            return "MyLoggingProcessor";
        }

    }

And then add this InterceptorStrategy to your Camel context:

   context.addInterceptStrategy(new LoggingProcessorInterceptor());

> Also, is it's even possible to use interceptSendToEndpoint with bean or
> beanRef DSL elements? 
Yes as interceptSendToEndpoint can be used for any kind of Endpoint
including the bean endpoint:

  
interceptSendToEndpoint("bean:hello?method=camel").to("mock:intercepted");

Also note that you could make use of wildcard or regular expressions while
specifying the endpoint uri:

http://camel.apache.org/intercept.html

Babak



--
View this message in context: 
http://camel.465427.n5.nabble.com/Intercept-processor-bean-tp5717639p5717664.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to