-
1. Re: EJBHomeFactory in JBoss
eclaudius Jun 27, 2003 11:09 AM (in response to wlwa4us)Kam
If I understand your question correctly then the answer is that when you lookup the Home interface you are returned a reference to the singleton object. This lets you call the methods on the object but you do not own the object nor do you have a copy of it. You are simply using it. As far as waiting or not I imagine that it is a single threaded object so you would have to wait, but I'm guessing here since I havn't looked at the source code.
Can somebody help us out here?
EClaudius -
2. Re: EJBHomeFactory in JBoss
wlwa4us Jun 27, 2003 4:09 PM (in response to wlwa4us)Hi EClaudius,
Thank you for replying to my question. The EJBHomeFactory is a single class and it is just plain old java class. Let say that there are five servlets they all get a instance of the EJBHomeFactory and lookup the same Home interface myEJBHome at the same time. At this time who get the myEJBHome interface first. Other servlets have to wait. This will slow down others servlets to access the myEJBHome interface. If all servlets access the myEJBHome interface directly using JNDI. Then the application server may have serveral instances of the myEJBHome in its memory and is ready to pass it along.
Kam -
3. Re: EJBHomeFactory in JBoss
cryokeeper Jun 28, 2003 8:02 PM (in response to wlwa4us)I do not think it matters. In a traditional singleton ONLY the getInstance() method is synchronized. Only one thread can be in that method at a time. The method is unblocked as soon as the calling thread leaves the method. Usually within <1 mill depending on how long it takes your singleton to initialize the first time.
As for multiple threads using the same home interface: This should be OK. The home interface is thread safe. The remote/local home is only a factory. Whenever you call create, a new bean created from the pool and assigned to you. None of your threads should be holding up in the home interface (unless the bean pool is full when your calling a create or the finder method has to add a bean to the pool).