This week's book giveaway is in the Testing forum.
We're giving away four copies of Data Structures the Fun Way: An Amusing Adventure with Coffee-Filled Examples and have Jeremy Kubica on-line!
See this thread for details.
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

How does Stateful Session bean store its state ?

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
can somebody explain how this is done,can u give a simple example?
thanks in advance
Pradeep
 
Bartender
Posts: 3793
40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, both Stateless and Stateful beans can keep their state in instance or class (means static) variables.

like bean class :



For both Stateless and Stateful Session beans "a" variable will keep some value between calls.

The main difference is:

- For Stateful beans there is relation 1 client - 1 bean, so client invokes 5 times "doSomething" and get 5 in method "getA()"

- For Stateless beans there is a relation 1 client - many beans (they are taken every time from pool, and pool implementation is vendor specific), so client invokes 5 times "doSomething", but each call may be done on any bean instance (the same or different) and impossible to predict what method "getA()" returns.

In case static class variable, we can utilize state of stateless bean like this:





for any instance of stateless bean will be now 1 common reference to home interface among several calls.
 
That is a really big piece of pie for such a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic