2 Replies Latest reply on Aug 13, 2012 1:28 AM by davsclaus

    Using OGNL in camel

    lekkie_lomotayo

      Hi all,

       

      I was wondering if it will be possible to access the property of an object. The name of the property is known at run time but the object instance is not.

       

      Is there any shorthand that I can use to access this property e.g.

       

      public void getRemoteHostRoute(@OGNL("request.body.{unknown-object}.RouteId") String routeIdOgnl2)

      {

      .......

      }

       

      Also, I am wondering if it it possible to suppress OGNL exception if the property of that object is not present.

       

      Thanks.

        • 1. Re: Using OGNL in camel
          njiang

          If you want to get the full control of the message body accessibility, you may consider to pass the message as the parameter like this

           

          public void getRemoteHostRoute(Message message) {
                 Object instance  = message.getBody();
                 // do what you want here
          }
          

           

          Willem

          • 2. Re: Using OGNL in camel
            davsclaus

            Some languages support the type safe null operator, eg the .? in groovy for example. We support that in the simple language as well. The OGNL may support it also, but you would need to check its documentation.