camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: DSL Strings pitfalls, how to avoid them?
Date Fri, 15 May 2009 12:59:35 GMT
On Fri, May 15, 2009 at 2:56 PM, uprooter <> wrote:
> Hello all.
> My first camel ride was really fun, keep up the good work.
> I'm concerned about DSL strings.
> Specifying strings as methods/beans/pojos is something I'd like to avoid
> from two reasons:
> Let's say I have something like this in my code:
>   from("jms").unmarshal(jaxb).choice().when().method("MyBean","isCommand")
> 1. Usually, when I rename "MyBean" in standard java code, my  IDE takes care
> to scan all my project, sometimes even dependency projects. and do the
> refactor.
> In java DSL it does not happen, since it's just a string.
> 2. Moreover, When I accidentally specify a wrong string instead of "MyBean"
> or "isCommand" everything compiles just fine but at runtime errors will
> occur  at unpredictable manner, This kind of error can easily get into
> production environment in projects that lacks organized testing habits.
> The first doubt is something I can live with, but the second is a
> problematic issue.
> Fix me if I'm wrong. Or if there is any solution to this.
> Thanks

You can also use Object or Class to invoke a method call. And the
string for the method name is optional in case where Camel can compute
the method to invoke, such as if there are only a single method, or
the method has been @annotated etc.

So it should be possible to do:

Or eg

MyBean my = new MyBean();

> --
> View this message in context:
> Sent from the Camel - Users mailing list archive at

Claus Ibsen
Apache Camel Committer

Open Source Integration:

View raw message