Claus Ibsen-2 wrote
> 
> On Mon, Dec 12, 2011 at 5:53 PM, Craig McDaniel <cpmcdaniel@> wrote:
>> I guess I should clarify that I'm getting an
>> AmbiguousMethodCallException,
>> not that the bean binding can't see the method.
>>
> 
> We can use help on the Scala DSL. Maybe we could add a method so you
> can invoke a bean from the Scala predicates.
> 
> However can you just do as in Java DSL
> 
> when().method("myBean") instead?
> 

The only way I can figure to do this is to make this one whole route a Java
DSL route by using the inherited "builder" reference to the underlying Java
RouteBuilder. It looks like this:

builder.from("quartz://feeds/carbon?cron=0+00+8+?+*+2-6")
      .choice.when.method("myBean", "myMethod").to("mock:end")

- or -

builder.from("quartz://feeds/carbon?cron=0+00+8+?+*+2-6")
      .choice.when(builder.beanRef("myBean", "myMethod")).to("mock:end")

The latter is more semantically similar to what I was trying to do.

It looks rather simple to add this to the Scala DSL, so I think I'll take a
stab at it. The DSL will look something like this:

when (_.bean("myBean", "myMethod")) { ... }
when (_.bean(myClass, "myMethod")) { ... }
when (_.bean(myObj, "myMethod")) { ... }

I think we should also add these to the DSL trait so the same pattern can be
used by all of the *Definition wrappers. So something like this would also
be supported:

"direct:foo" bean("myBean", "myMethod")

--
View this message in context: 
http://camel.465427.n5.nabble.com/Scala-DSL-Calling-Spring-beans-as-predicates-tp5068888p5074843.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to