aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes HomeInterface stored in a static method in a soap service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "HomeInterface stored in a static method in a soap service" Watch "HomeInterface stored in a static method in a soap service" New topic
Author

HomeInterface stored in a static method in a soap service

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hello all
i need advice !!!
I try to improve perfoemance on code that access statless session ejb within a soap service.
Is it interresting to store the home interface in a static variable?
Do you think it will increase performance ??? or slow down ??
this is my implementation proposition.....
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Yes, doing the JNDI lookup is fairly expensive compared to other operations, and holding a singleton reference to the home interface is safe. Having multiple threads calling create() on the home stub is safe and will save you having to lookup the home on each call.
The question I have yet to answer satisfactorily is "Can you store the *stateless* session bean stub in a singleton and have multiple threads calling business methods on it simultaneously? As the stub isn't tied to a specific bean, it seems it should be safe and that each method invocation would end up going to a different physical bean. Is this the case?
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
Originally posted by David Harkness:
The question I have yet to answer satisfactorily is "Can you store the *stateless* session bean stub in a singleton and have multiple threads calling business methods on it simultaneously? As the stub isn't tied to a specific bean, it seems it should be safe and that each method invocation would end up going to a different physical bean. Is this the case?

If a runtime exception gets thrown in the bean, the container i guess destroys the bean instance. I wonder if we c'd get
NoSuchObjectLocalException when we try to use the EJBLocalObject reference that we have cached? I did'nt see this happening in practice on weblogic.
So its obvious that the container has actually swapped the destroyed bean with a different live bean. So i guess, i can cache the local reference as well probably @ the cost of losing out on benefits that come with object pooling.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Thanks for the information.
But if i understand: i should be able to store stub of the remote interface in a static variable safely and then avoid the .create() and the .remove()??? for every call.
 
Consider Paul's rocket mass heater.
 
subject: HomeInterface stored in a static method in a soap service