Hi

You can likely bind using the @Simple language and refer to the
properties with an expression in the likes of something:
camelContext.properties['foo']

http://camel.apache.org/simple


On Thu, May 7, 2015 at 6:53 PM, toomanyedwards <[email protected]> wrote:
> 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(
>                 @Header(NAME_OF_HEADER_NEEDED_BY_ROUTE_A)String
> valueOfHeaderNeededByRouteA
>             )
>         {
>             // Check if needed header value is set and if not throw
> exception
>         }
> }
>
> public class RouteBValidatorBean
> {
>
>         public void validateRoutePreconditions(
>                 @Property(NAME_OF_EXCHANGE_PROPERTY_NEEDED_BY_ROUTE_B)String
> valueOfExchangePropertyNeededByRouteB
>             )
>         {
>             // 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.
>
> -e
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/How-to-bind-context-properties-to-method-parameters-tp5766819p5766828.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [email protected]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Reply via email to