File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Stateless Session bean : Multiple Clients reference Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Stateless Session bean : Multiple Clients reference" Watch "Stateless Session bean : Multiple Clients reference" New topic
Author

Stateless Session bean : Multiple Clients reference

chandrasekhar muvvala
Greenhorn

Joined: Nov 12, 2003
Posts: 9
Can Multiple Clients can have a reference to the same bean? w.r.t to Stateless Session Beans.
I found the answers can be both : YES & NO
YES because, can refer but not at the same time.


How to justify this question, what is the correct answer?
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Actually, when a client invokes a method on a stateless session object, the container takes one session bean out of the pool and invokes the method on it. When the call returns, the container might put the instance back in the pool or use it for servicing other incoming calls. The bottom line is that at any time, only one client is executing a method of given session bean instance. So, yes, multiple clients may have a reference to "the same" stateless session bean, but due to the nature of stateless session bean, you have no idea how the container decides to manage those reference, and thus, you have no idea whether the references the client has all point to the same stateless session bean. Actually, you don't even have to care about the instance that is executing your calls since the beans are stateless, and thus, they all do the same job... Does this make sense to you?


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Balaji Natarajan
Greenhorn

Joined: Dec 05, 2002
Posts: 28
me too have the same doubt.

From the above post may i conclude that the business methods of a stateless session bean should not depend on the instance variables of the bean and it should depend only on the input parameters.

Balaji.
Natarajan Shankar
Ranch Hand

Joined: Jun 10, 2004
Posts: 53
Even EJB spec doesn't recommend to create instance variable in the statless bean. So it must depends on input parameter.


Best Regards<br />N.Shankar<br />SCJP, SCWCD
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Stateless session beans may declare instance variables, of course. The only requirement is that those variables should not be used to store client-specific data since they are supposed to be stateless... Examples of instance variables are database connections, etc...
[ June 30, 2004: Message edited by: Valentin Crettaz ]
Balaji Natarajan
Greenhorn

Joined: Dec 05, 2002
Posts: 28
thanks Valentin and Shankar its clear now.

Balaji
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Stateless Session bean : Multiple Clients reference