You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by JasonN <ja...@googlemail.com> on 2012/11/21 12:05:33 UTC

Call constructor from route

Hi,

I am able to call a static method from a route but can someone please advise
on how to call a constructor?

e.g.:

      <setBody>
          <method beanType="com.company.HelloBean"
method="HelloBean(${body})"/>
      </setBody>

Thanks!



--
View this message in context: http://camel.465427.n5.nabble.com/Call-constructor-from-route-tp5723059.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Call constructor from route

Posted by JasonN <ja...@googlemail.com>.
Christian Mueller wrote
> Can you use a scripting language?
> 
> Sent from a mobile device
> Am 21.11.2012 12:46 schrieb "JasonN" &lt;

> jasonnorth3001@

> &gt;:
> 
>> Thanks for your help.
>>
>> That's a shame though as you may not have control over the class to be
>> able
>> to add default constructor + other methods and even if you do there could
>> be
>> objections to designing classes around camel.
>>
>> I guess I could add another method somewhere to call the constructor or
>> implement a processor but that seems unnecessarily verbose (and generally
>> camel seems very good at keeping things concise+convenient).
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Call-constructor-from-route-tp5723059p5723063.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>

I do not know much about scripting languages with camel but I assume there
would be a performance hit and therefore this would not be possible for me.



--
View this message in context: http://camel.465427.n5.nabble.com/Call-constructor-from-route-tp5723059p5723240.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Call constructor from route

Posted by Christian Müller <ch...@gmail.com>.
Can you use a scripting language?

Sent from a mobile device
Am 21.11.2012 12:46 schrieb "JasonN" <ja...@googlemail.com>:

> Thanks for your help.
>
> That's a shame though as you may not have control over the class to be able
> to add default constructor + other methods and even if you do there could
> be
> objections to designing classes around camel.
>
> I guess I could add another method somewhere to call the constructor or
> implement a processor but that seems unnecessarily verbose (and generally
> camel seems very good at keeping things concise+convenient).
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Call-constructor-from-route-tp5723059p5723063.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Call constructor from route

Posted by JasonN <ja...@googlemail.com>.
Thanks for your help.

That's a shame though as you may not have control over the class to be able
to add default constructor + other methods and even if you do there could be
objections to designing classes around camel.

I guess I could add another method somewhere to call the constructor or
implement a processor but that seems unnecessarily verbose (and generally
camel seems very good at keeping things concise+convenient).



--
View this message in context: http://camel.465427.n5.nabble.com/Call-constructor-from-route-tp5723059p5723063.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Call constructor from route

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Nov 21, 2012 at 12:05 PM, JasonN <ja...@googlemail.com> wrote:
> Hi,
>
> I am able to call a static method from a route but can someone please advise
> on how to call a constructor?
>
> e.g.:
>
>       <setBody>
>           <method beanType="com.company.HelloBean"
> method="HelloBean(${body})"/>
>       </setBody>
>
> Thanks!
>

Thats not supported.
A constructor doesn't return an value etc. So it doesn't make much sense.

You can have a default no-arg ctr, and then invoke a method instead.



>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Call-constructor-from-route-tp5723059.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



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