dcsimg
can l make the EJB home handler/Datasource shared by 1+ EJB bean instances. ??
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ah_So
Posted On:   Friday, August 9, 2002 12:10 AM

all ejb guru As far as l know, it is general rule of thumb to cache the EJB home handlers and datasource object at EJB bean instance. But can l go a step further, make the same instance of EJB home handlers and datasource object shared by more than 1 EJB bean instance ? ( l checked out the methods of javax.ejb.EJBhome and javax.sql.DataSource. They are not declared as synchronized. It seems to me that EJB home handlers and datasource object are not thread safe and not suitable for being shared. Even they are thread-safe, if they are shared by 1+ EJB bean instance. Sharing EJB home handlers and datasource object may interfere the thread management of EJB container. Am l correct ? )    More>>


all ejb guru



As far as l know, it is general rule of thumb to cache the EJB home handlers and datasource object at EJB bean instance. But can l go a step further, make the same instance of EJB home handlers and datasource object shared by more than 1 EJB bean instance ?



( l checked out the methods of javax.ejb.EJBhome and javax.sql.DataSource. They are not declared as synchronized. It seems to me that EJB home handlers and datasource object are not thread safe and not suitable for being shared. Even they are thread-safe, if they are shared by 1+ EJB bean instance. Sharing EJB home handlers and datasource object may interfere the thread management of EJB container. Am l correct ? )



It is highly appreciated someone can share with me your insight in this issue.



thanks & regards


Danny

   <<Less

Re: can l make the EJB home handler/Datasource shared by 1+ EJB bean instances. ??

Posted By:   Nick_Maiorano  
Posted On:   Sunday, August 11, 2002 06:51 PM

Danny,



Obtaining a home or datasource object is a very simple task which involves a jndi lookup and a downcast (or narrow) operation. Traditionally, developers do not bother sharing these objects since obtaining them is so simple that it's simply not worth the trouble. For this reason, I would recommend you save yourself the trouble of determining whether or not they are threadsafe and simply not share them. Furthermore, obtaining home objects and creating EJBs out of them is usually something done once in the lifetime of the bean. This further eliminates any advantage in object sharing (since it's something only done once).



Regards,
Nick.
About | Sitemap | Contact