Hi

You have hit a limitation what can be done in pure Java with generics
to simulate a DSL.

You can put the predicate inside as a parameter, eg between ( ) on the
method call then it helps.
It has been debated before on this forum so do a bit of search as well.

On Tue, Aug 24, 2010 at 2:37 PM, M.Ismail <[email protected]> wrote:
>
> Hi,
>
> I'm using Camel 2.3 using java DSL to with a route like that:
>
> from("direct:EmRequests")
>        .log("request's Body is ${in.body}")
>
>        .choice()
>        .when(bean("EmLoginBean","isLoggedIn").isNotEqualTo(constant(true)))
>
>                .doTry()
>                        .process(new EmLoginProcessor())
>                        .to(cxfSessionFactory)
>                        .process(new EmProcessor())
>                        .log("Response back to the caller ${body}")
>
> .choice().when(property("MarshalAndUnmarshal").isEqualTo(constant(true))) //
> gives me a compilation error
>                        .convertBodyTo(String.class)
>                        .end()
>                .doCatch(ECIEPermissionDenied.class,ECIESystemDown.class)
>                .process(new ExceptionProcessorHandler())
>                .end()
>
>        .end();
>
> I get the following compilation error if I put a choice() inside the doTry.
> Here it is "The method doCatch(Class<ECIEPermissionDenied>,
> Class<ECIESystemDown>) is undefined for the type ProcessorDefinition"
>
> So I tried to put it as a separate Predicate like that:
>
>
> Predicate pred =
> choice().when(property("MarshalAndUnmarshal").isEqualTo(constant(true)))
>                .convertBodyTo(String.class)
>                .end();
>
> However, I get this compilation error : "The method choice() is undefined
> for the type MyRouteBuilder"
>
> Is there a way to successfully write this Predicate?
>
> thanks,
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/writing-a-choice-predicate-tp2651153p2651153.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Reply via email to