You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Ilya S <de...@gmail.com> on 2010/09/08 20:08:51 UTC
InterceptionStrategy: target vs nextTarget (camel 2.3.0)
I'm implementing a global InterceptStrategy that is supposed to wrap only
some of the processors (in particular I'm interested in the processors that
implement particular interface).
When debugging my strategy, I noticed that in most cases the *target *object
does not contain the actual object I'm interested in (e.g. more often I get
TraceInterceptor that wraps the real object),while *nextTarget *contains the
processor that I actually want to wrap.
>From the docs I can see the following:
* @param target the processor to be wrapped
* @param nextTarget the next processor to be routed to
Could someone clarify the meaning of nextTarget?
In my implementation I had to do the following (based on the source of some
interception strategies):
// prefer next target over target as next target is the real target
Processor interceptedProcessor = nextTarget != null ? nextTarget :
target;
// Intercept Dharma Process
if(com.my.company.Event.class.isAssignableFrom(interceptedProcessor.getClass()))
{
// Wrap the interceptedProcessor here, and return it
}
return target;
Does this code make sense, or am I doing something weird here? The code
seems to perform what I need, though, it seems to me that the intention of
this interface is to wrap the target and not the nextTarget.
Thank you for your help.
Ilya