Hi

The bean component will create one time and reuse, (it caches by default)

And the 1st solution will only create it once, the new constructor is
only invoked once during defining the routes using the route builders.


On Thu, Mar 12, 2015 at 3:11 PM, yuncil <jonas.stei...@hotmail.de> wrote:
> Hi Guys,
>
> according to the camel documentation I have two different options to invoke
> a method of a bean.
>
>
> /// Explicit selection of bean method to be invoked.
> from("direct:start").bean(new ExampleBean(), "methodName");
>
> // Camel will create the instance of bean and cache it for you.
> from("direct:start").bean(ExampleBean.class);/
>
> I guess the first solution creates a new bean instance every time. The
> second one caches the instance of the object, but what does that mean
> explicitly? How long is the object available? During one invocation or for
> the whole lifecycle of my Webservice?
>
> I'll give you an example, within my route I have the following:
>
> .bean(MyBeanA.class, "doMyBeanA")
> .bean(MyBeanB.class, "doMyBeanB")
> .bean(MyBeanA.class, "doMyBeanA2")
>
> I must invoke one method of one bean, then one method of another bean and
> finally another method of the first bean. I want to avoid to create more
> than one instance of MyBeanA. Every instance of every bean should be created
> just once per route-invocation.
>
> I hope It was understandable, maybe one of you can give me a hint. Thank you
> in advance
>
> regards
>
>
>
>
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Bean-invocation-class-vs-new-tp5764039.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cib...@redhat.com
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