GeeCON Prague 2014*
The moose likes EJB and other Java EE Technologies and the fly likes Question about Stateless : Stateful SessionBean 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 "Question about Stateless : Stateful SessionBean" Watch "Question about Stateless : Stateful SessionBean" New topic
Author

Question about Stateless : Stateful SessionBean

walter wang
Ranch Hand

Joined: Jun 02, 2001
Posts: 154
Dear All,

I have a problem .
I have a stateless SessionBean and a statefull SessionBean.
the call sequence is , Stateless Session bean will always
call one certain method of the Statefull Session bean.

In this scenario, the stateless bean instance : statefullbean instance
is 1:1 or 1:n? Is it possible that EJBContainer generate more statefull
session bean instance for being called from stateless session bean?

Actually I mean Could EJBContaine generate more statefull session bean
instances for one stateless sessionbean client for being called?

Thanks in advance.
WangYan


public class Walter { public boolean is_Working_Now (boolean is_boss_Coming) { return is_boss_Coming; }
Vinay Raj
Ranch Hand

Joined: Jun 19, 2006
Posts: 81
The object references created for a stateless session bean are valid within the scope of SLSB method. If there are multiple invokations SLSB's methods, number of SFSBs will be created.

In order to ensure that only one SFSB is created and reused, you will need capability to hold the reference of the SFSB beyond the SLSB method. This can be achieved via serializing the handle reference using the getHandle API or using a singleton to store all your references. Note that this technique would work in a single JVM environment and is unsuitable for a clustered environment. In clustered environment, an option is to persist state via database etc.
Vinay Raj
Ranch Hand

Joined: Jun 19, 2006
Posts: 81
In my earlier post I have explained how to ensure that only one SFSB instance is created and reused. How many SFSBs are created is entirely upto your application code. It is based on the number of times you would be invoking SFSB creates within the single SLSB method call.
walter wang
Ranch Hand

Joined: Jun 02, 2001
Posts: 154
Hello Thanks for your input
could you tell me the URL for your related post link?

Thanks and Regards
 
GeeCON Prague 2014
 
subject: Question about Stateless : Stateful SessionBean