Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about Stateless : Stateful SessionBean

 
walter wang
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Vinay Raj
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Thanks for your input
could you tell me the URL for your related post link?

Thanks and Regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic