Forum Home » Fuse Distributions » Fuse Mediation Router

Thread: Using OGNL in camel

 
This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Aug 13, 2012 5:28 AM Last Post By: davsclaus
lekkie

Posts: 141
Registered: 11/02/09
Using OGNL in camel
Posted: Jul 30, 2012 5:57 PM
 
  Click to reply to this thread Reply
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.
njiang

Posts: 572
Registered: 09/17/07
Re: Using OGNL in camel
Posted: Aug 10, 2012 1:59 AM   in response to: lekkie in response to: lekkie
 
  Click to reply to this thread Reply
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
davsclaus

Posts: 1,893
Registered: 10/14/08
Re: Using OGNL in camel
Posted: Aug 13, 2012 5:28 AM   in response to: lekkie in response to: lekkie
 
  Click to reply to this thread Reply
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.