You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by maheetw <ma...@gmail.com> on 2013/08/12 12:27:36 UTC

Bean's scope in Camel

Can someone explain the bean's scope in camel ? 
let's say i am having one endpoint bean ,scope as a prototype and using this
bean in two routes .So it will be two different objects of endpoints or same
? 



--
View this message in context: http://camel.465427.n5.nabble.com/Bean-s-scope-in-Camel-tp5737137.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Bean's scope in Camel

Posted by Claus Ibsen <cl...@gmail.com>.
Yes they will have different object instances as its prototype scoped
in the spring <bean> tag.
In fact for each message Camel will lookup the bean in the spring app
context and get a new instance.

You can tell Camel to cache the lookup by setting cache=true. See more at
http://camel.apache.org/bean

On Mon, Aug 12, 2013 at 5:42 PM, maheetw <ma...@gmail.com> wrote:
> Suppose i have following configuration
>
> <beans>
> <bean id="dbwriter" class="com.test.WriterComponent" scope="prototype">
>              </bean>
>
> <camelContext>
>                   <route id = "ROUTE1">
>                   <from uri="direct:start"/>
>                   <to uri="dbwriter:writer"/>
>
>                   <route id = "ROUTE2">
>                   <from uri="direct:start"/>
>                   <to uri="dbwriter:writer"/>
> </camelContext>
> <beans>
>
> now since i am having dbwriter's scope as prototype then both the route
> should have different object of bean of endpoint or same?
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Bean-s-scope-in-Camel-tp5737137p5737165.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
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: Bean's scope in Camel

Posted by maheetw <ma...@gmail.com>.
Suppose i have following configuration

<beans>
<bean id="dbwriter" class="com.test.WriterComponent" scope="prototype">
	     </bean>
		
<camelContext>
		  <route id = "ROUTE1">
		  <from uri="direct:start"/>
                  <to uri="dbwriter:writer"/>

		  <route id = "ROUTE2">
		  <from uri="direct:start"/>
                  <to uri="dbwriter:writer"/>
</camelContext>
<beans>

now since i am having dbwriter's scope as prototype then both the route
should have different object of bean of endpoint or same?




--
View this message in context: http://camel.465427.n5.nabble.com/Bean-s-scope-in-Camel-tp5737137p5737165.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Bean's scope in Camel

Posted by Claus Ibsen <cl...@gmail.com>.
Can you explain a bit more what you mean, maybe with an example?



On Mon, Aug 12, 2013 at 12:27 PM, maheetw
<ma...@gmail.com> wrote:
> Can someone explain the bean's scope in camel ?
> let's say i am having one endpoint bean ,scope as a prototype and using this
> bean in two routes .So it will be two different objects of endpoints or same
> ?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Bean-s-scope-in-Camel-tp5737137.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
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