On Fri, Oct 26, 2012 at 9:38 AM, Zhemzhitsky Sergey <sergey_zhemzhit...@sberbank-cib.ru> wrote: > Hello guys, > > One more question, > > What is the reason to allow DefaultEndpoint.isSingleton() and > DefaultProducer.isSingleton() return false as it prevents caching of these > objects and new instances of endpoints and producers will be created on each > lookup? >
To allow component developers the freedom to decide if their endpoints / producers / consumers is thread-safe or not. Though 95+% of the components out of the box is singleton scoped. So in reality its own a few components that may need this. > > Best Regards, > Sergey > > > -----Original Message----- > From: Zhemzhitsky Sergey [mailto:sergey_zhemzhit...@sberbank-cib.ru] > Sent: Thursday, October 25, 2012 12:52 PM > To: users@camel.apache.org > Subject: RE: Endpoint and Producer isSingleton behavior in the OSGi > > Hello Claus, > > Thanks a lot for clarification! > > Best Regards, > Sergey > > -----Original Message----- > From: Claus Ibsen [mailto:claus.ib...@gmail.com] > Sent: Thursday, October 25, 2012 12:49 PM > To: users@camel.apache.org > Subject: Re: Endpoint and Producer isSingleton behavior in the OSGi > > On Thu, Oct 25, 2012 at 10:18 AM, Zhemzhitsky Sergey > <sergey_zhemzhit...@sberbank-cib.ru> wrote: >> Hello camel gurus, >> >> I just need some clarification about how DefaultEndpoint, DefaultProducer >> behave depends on whether their isSingleton method returns true or false. >> >> My understanding is the follosing: >> >> >> 1. If DefaultEndpoint.isSingleton() returns true the same instance of >> the endpoint will be reused across all the camel contexts, and in case of >> OSGi this mean that the same endpoint instance will be reused across all the >> bundles that contain some camel functionality. >> > > No its reused per CamelContext. Endpoints / producers / consumers et all is > per CamelContext and not shared across bundles. > > > >> 2. If DefaultEndpoint.isSingleton() returns false then for each camel >> context a new instance of the endpoint is created and in the OSGi the new >> instance of the endpoint will be created for each separate bundle that >> contains a camel context. >> > > if false, then the endpoint is not stored in the endpoint registry for any > re-use. And on each endpoint lookup a new instance is created. > > >> 3. If DefaultProducer.isSingleton() returns true then the same >> instance of the producer, i.e., will be used every time not depending on the >> endpoint uri, i.e. for the following producers <to >> uri=”comp:producer?param1=val1”/> and <to >> uri=”comp:producer?param1=val1¶m2=val2”/> will be used the same instance >> of the producer? >> > > No these are 2 different endpoints (unless the endpoint supports lenient > properties - eg a bit special but think like a http endpoint where any of the > uri parameters can be dynamic, but you want to use the same Camel endpoint) > > >> 4. If DefaultProducer.isSingleton() returns false then for the >> different endpoint URIs will be returned different instances of producer. >> >> So summarizing all the points above if DefaultEndpoint.isSingleton() is true >> and DefaultProducer.isSingleton() in the OSGi environment then the producers >> will be shared across all the camel contexts located in all the OSGi >> bundles, right? >> >> >> Best Regards, >> Sergey >> >> >> _______________________________________________________ >> CONFIDENTIALITY NOTICE: This email and any files attached to it may be >> confidential. If you are not the intended recipient you are notified that >> using, copying, distributing or taking any action in reliance on the >> contents of this information is strictly prohibited. If you have received >> this email in error please notify the sender and delete this email. >> > > > > -- > Claus Ibsen > ----------------- > Red Hat, Inc. > FuseSource is now part of Red Hat > Email: cib...@redhat.com > Web: http://fusesource.com > Twitter: davsclaus > Blog: http://davsclaus.com > Author of Camel in Action: http://www.manning.com/ibsen -- Claus Ibsen ----------------- Red Hat, Inc. FuseSource is now part of Red Hat Email: cib...@redhat.com Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen