Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Stateless Session bean : Multiple Clients reference

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even EJB spec doesn't recommend to create instance variable in the statless bean. So it must depends on input parameter.
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Valentin and Shankar its clear now.

Balaji
 
Right! We're on it! Let's get to work tiny ad!
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic