File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HomeInterface stored in a static method in a soap service

 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1646
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1209
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic