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.
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: