camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McDaniel <>
Subject Re: Scala DSL - Calling Spring beans as predicates
Date Wed, 14 Dec 2011 15:41:03 GMT

Claus Ibsen-2 wrote
> On Mon, Dec 12, 2011 at 5:53 PM, Craig McDaniel &lt;cpmcdaniel@&gt; 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:

      .choice.when.method("myBean", "myMethod").to("mock:end")

- or -

      .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:
Sent from the Camel - Users mailing list archive at

View raw message