camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toomanyedwards <>
Subject Re: How to bind context properties to method parameters?
Date Thu, 07 May 2015 16:53:47 GMT
Yes, we want to be able to bind to the properties on the CamelContext.  The
reason we want to do this is that we have config information that is
effectively immutable for the life of the CamelContext  (timeouts, db config
info, etc.) and our routes depend on this info.  When our routes execute we
want to validate that all the preconditions for config data (Message
headers, Exchange properties and Context properties) needed by the route are
met.  To do this we have a bean for each of our routes that implements a
"validateRoutePreconditons" method and we invoke this method via camel bean
at the beginning of the route execution.  Example validator beans:

public class RouteAValidatorBean

	public void validateRoutePreconditions(
            // Check if needed header value is set and if not throw

public class RouteBValidatorBean

	public void validateRoutePreconditions(
            // Check if needed exchange property value is set and if not
throw exception

We'd like to be able validate that the required camelcontext properties are
set in a similar fashion.  I guess one option would be to have a parameter
of type CamelContext on our validate method and then Camel should
dynamically bind this right?  Then in our validator method we'd have to
explicitly get the properties we care about from the context.  Not quite as
clean as being able to just bind context properties that we care about (as
we can do for headers and exchange properties), but might be the best
solution.  Is there a better approach to this?  Are CamelContext properties
the appropriate place to cache static config info that is immutable or is
there a preferred way to do this?

Thanks for your insight.


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

View raw message