This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Confused about STFL and STLS beans

 
Kiril Nugmanov
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm really confused about usage of STFL and STLS beans .
The main difference benwen them is that STFL can hold clients state and STLS can't. Thus I tried to test it with local client.
(1) Created 2 EJBs - StatelessBean and StatefullBean
(2) Deployed to Glassfish 2.1.1 AS. No any aditional configurations were made.





First time I called client and set "data" variable to 1 in STFL and STLS beans. By second call I just tried to obtain that value.
Results in fist time were as supposed:

But when calling second time I obtained following results:


There is no question about STFL - each time I obtain reference to new STFL bean thus value is 0. But why I obtained the same STLS bean
There is server.log



 
Hany Shafik
Ranch Hand
Posts: 80
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is exactly how stateless bean behaves, the server uses the same instance of the stateless bean to serve multiple clients requests.
That is why it is not recommended for you to keep state in the stateless bean as your instance may end up serving a totally different client.
To recap what I have just said, any instance of stateless bean in the pool can serve any client. However statefull session bean instance are attached to the client that created it and can't be reused by another client while it is in use.
 
Kiril Nugmanov
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hany Shafik,

Thanks for clearing the situation.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic