You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "mailinglist@j-b-s.de" <ma...@j-b-s.de> on 2013/08/19 06:47:10 UTC

Java DSL / GroovyExpression / Binding

Hi all!

Is there any chance to extend the binding of a GroovyExpression?
Currently (in camel 2.11.1) the Groovy binding is defined on runtime based on the exchange only and I did not find an extension point. My current solutions is to use a GroovyExpression2 class which is a copy of the original class and provided a new constructor method accepting a Map<String,Object> parameter which is added to Binding. This allows me to add additional parameters at time of route creation but I doubt this is the right way. 

Due to the fact createBinding method is private and not protected I can not derive from GroovyExpression and need to copy the class. 

Thanks in advance

Jens



Von meinem iPad gesendet

Re: Java DSL / GroovyExpression / Binding

Posted by Claus Ibsen <cl...@gmail.com>.
You are welcome to provide patches and improve the groovy dsl. We love
contributions
http://camel.apache.org/contributing.html

On Mon, Aug 19, 2013 at 8:52 AM, mailinglist@j-b-s.de
<ma...@j-b-s.de> wrote:
> Hi Willem,
>
> thanks for your answer, unfortunately overriding eval is not sufficient as this method initializes everything and calls several private methods. By copy I meant: new ctor, copy eval, copy instantiateScript and copy
> createBinding to make it work which feels wrong. Furthermore my class needs to be placed in a package org.apache.camel.language.groovy which feels odd, too. Seems to me like expressions are considered internal camel functionality...
>
>
> Jens
>
> Sent from my iPhone
>
> On 19.08.2013, at 08:33, Willem jiang <wi...@gmail.com> wrote:
>
>> Hi,
>>
>> You don't need to copy the class, you can just override the evaluate method to setup the binding as you want.
>>
>> --
>> Willem Jiang
>>
>> Red Hat, Inc.
>> Web: http://www.redhat.com
>> Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
>>          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
>> Twitter: willemjiang
>> Weibo: 姜宁willem
>>
>>
>>
>>
>>
>> On Monday, August 19, 2013 at 12:47 PM, mailinglist@j-b-s.de wrote:
>>
>>> Hi all!
>>>
>>> Is there any chance to extend the binding of a GroovyExpression?
>>> Currently (in camel 2.11.1) the Groovy binding is defined on runtime based on the exchange only and I did not find an extension point. My current solutions is to use a GroovyExpression2 class which is a copy of the original class and provided a new constructor method accepting a Map<String,Object> parameter which is added to Binding. This allows me to add additional parameters at time of route creation but I doubt this is the right way.
>>>
>>> Due to the fact createBinding method is private and not protected I can not derive from GroovyExpression and need to copy the class.
>>>
>>> Thanks in advance
>>>
>>> Jens
>>>
>>>
>>>
>>> Von meinem iPad gesendet
>>
>>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Java DSL / GroovyExpression / Binding

Posted by "mailinglist@j-b-s.de" <ma...@j-b-s.de>.
Hi Willem,

thanks for your answer, unfortunately overriding eval is not sufficient as this method initializes everything and calls several private methods. By copy I meant: new ctor, copy eval, copy instantiateScript and copy 
createBinding to make it work which feels wrong. Furthermore my class needs to be placed in a package org.apache.camel.language.groovy which feels odd, too. Seems to me like expressions are considered internal camel functionality...


Jens

Sent from my iPhone

On 19.08.2013, at 08:33, Willem jiang <wi...@gmail.com> wrote:

> Hi,
> 
> You don't need to copy the class, you can just override the evaluate method to setup the binding as you want.  
> 
> --  
> Willem Jiang
> 
> Red Hat, Inc.
> Web: http://www.redhat.com
> Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
>          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
> Twitter: willemjiang  
> Weibo: 姜宁willem
> 
> 
> 
> 
> 
> On Monday, August 19, 2013 at 12:47 PM, mailinglist@j-b-s.de wrote:
> 
>> Hi all!
>> 
>> Is there any chance to extend the binding of a GroovyExpression?
>> Currently (in camel 2.11.1) the Groovy binding is defined on runtime based on the exchange only and I did not find an extension point. My current solutions is to use a GroovyExpression2 class which is a copy of the original class and provided a new constructor method accepting a Map<String,Object> parameter which is added to Binding. This allows me to add additional parameters at time of route creation but I doubt this is the right way.  
>> 
>> Due to the fact createBinding method is private and not protected I can not derive from GroovyExpression and need to copy the class.  
>> 
>> Thanks in advance
>> 
>> Jens
>> 
>> 
>> 
>> Von meinem iPad gesendet  
> 
> 

Re: Java DSL / GroovyExpression / Binding

Posted by Willem jiang <wi...@gmail.com>.
Hi,

You don't need to copy the class, you can just override the evaluate method to setup the binding as you want.  

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Monday, August 19, 2013 at 12:47 PM, mailinglist@j-b-s.de wrote:

> Hi all!
>  
> Is there any chance to extend the binding of a GroovyExpression?
> Currently (in camel 2.11.1) the Groovy binding is defined on runtime based on the exchange only and I did not find an extension point. My current solutions is to use a GroovyExpression2 class which is a copy of the original class and provided a new constructor method accepting a Map<String,Object> parameter which is added to Binding. This allows me to add additional parameters at time of route creation but I doubt this is the right way.  
>  
> Due to the fact createBinding method is private and not protected I can not derive from GroovyExpression and need to copy the class.  
>  
> Thanks in advance
>  
> Jens
>  
>  
>  
> Von meinem iPad gesendet