camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Müller <>
Subject Re: Best practice for checking method exists on class when building route?
Date Tue, 04 Feb 2014 17:19:52 GMT
On Mon, Feb 3, 2014 at 11:49 PM, toomanyedwards <>wrote:

> Hi all,
>   In our camel routes we sometimes set header values dynamically, by doing
> something like the following:
> .setHeader(SOME_HEADER_NAME).method(SomeClass.class,
> Ideally, we'd like to able to validate that the method specified by the
> signature SOME_METHOD_SIGNATURE_STRING actually exists on SomeClass.class
> *before* the route tries to invoke it at runtime and we potentially get a
> runtime exception.  ideally, this validation should happen at compile time
> or at least on route initialization.  What's the current camel best
> practice
> here to minimize possible runtime exceptions if the signature string is
> incorrect?

Test your code before delivering it. ;-)

> I imagine somewhere internally camel is parsing
> and using reflection to do the method lookup based on the signature.  Is
> that something currently exposed by the api that we can leverage?  Is there
> a better way to do this?  Thanks!

IF this is really an issue for you I would suggest to use a custom bean
which extends Processor (which tie things more closely together).
I prefer to have a test which makes sure the reflection/script/... stuff is
working as expected...

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

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message