aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes How a Statefull Session Bean is tied to the Client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How a Statefull Session Bean is tied to the Client" Watch "How a Statefull Session Bean is tied to the Client" New topic
Author

How a Statefull Session Bean is tied to the Client

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
How a Statefull Session Bean is tied to a particular Client? Does the tieup depends on the parameter we pass in the ejbcreate() method or it is independent.How exactly the tie-up is build & when does it breaks.
1 more.
By looking at the code is it possible to distinguish between Stateful Session Bean & Stateless Session Bean. If so, then on what basis.
Thnxs.
Mark Uppeteer
Ranch Hand

Joined: Mar 02, 2004
Posts: 159

it is in the deployment descriptor that you say if its a statefull or stateless session bean.


I know where my towel is. (SCJP 5, OCPJWCD)
[Free Quiz Tips for a fun night with friends or family] Flash games
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

Store a handle to the stateful bean in your Session.


Customer surveys are for companies who didn't pay proper attention to begin with.
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1066
How a Statefull Session Bean is tied to a particular Client?
Does the tieup depends on the parameter we pass in the ejbcreate() method or it is independent?

This is handled by the EJBHome/Object stub of your SFSB client and the EJB Container.We do not have to worry about that. The EJB Container manages it smartly.It maintains the session for us and does not dependent on any data that we pass in the methods.We only pass the state information specific to the client depending on our business logic.
How exactly the tie-up is build & when does it breaks?
- It breaks when home.remove() or remote.remove() is called by the client or a time-out for the SFSB occurs at the server side. SFSB bean instance serving this client is destroyed by the Container.

By looking at the code is it possible to distinguish between Stateful Session Bean & Stateless Session Bean. If so, then on what basis?

Yes it is possible if you understand the differences between SFSB and SLSB.
1. SLSB has only 1 ejbCreate() method in the bean, while SFSB can have overloaded ejbCreate() methods with different parameters.
2. There could be member variables in the bean class to hold client-specific state for SFSB
3. There could be some valid code in ejbActivate() and ejbPassivate() methods for SFSB.These methods do not make sense for SLSB, should be empty as they are never called by the container for SLSB.
4. The "bean-ness" - the ability to do different things inside a method is different for SFSB and SLSB. The ejbCreate(), ejbRemove(), ejbActivate(), ejbPassivate() methods of SFSB can access other resource managers/enterprise beans, as they have a security context available for these methods. This is not possible for SLSB as they do not have a client security context associated with these methods.
5. If the bean implements SessionSynchronization interface also, then it is a SFSB.
6. If the bean methods contain bean managed transactions and if the transaction is kept open across multiple methods, then also it is a SFSB.
7. Lastly in the DD-XML file, the type of Session bean describes whether it is a SFSB or SLSB.
[ March 18, 2004: Message edited by: Vish Kumar ]
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Thnx a lot....
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Nirant,
Please take a look at our naming policy and edit your display name accordingly.
Thanks.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How a Statefull Session Bean is tied to the Client