|
![]() |
Sun Certified Programmer for the Java 2 Platform, Standard Edition 5.0 (88 %)
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Originally posted by Jothi Shankar Kumar Sankararaj:
Since your refreshes are spontaneous, the instance is not requested from the pool everytime and the same instance serves you the result which gets incremented each time you refresh. Use a timeout method and return the instance to the pool and then refresh the page again and you will find that it again sarts with 0.
Sun Certified Programmer for the Java 2 Platform, Standard Edition 5.0 (88 %)
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Sun Certified Programmer for the Java 2 Platform, Standard Edition 5.0 (88 %)
Originally posted by Edvins Reisons:
Moving the bean into the pool does not reset its member variables.
So, the counter will increase with each method call, no matter which client calls it.
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
The specification says equal instances of Stateless beans must exist in the pool which means all the state values for different instances must be equal.
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Originally posted by Paul Sturrock:
Yes. Think about it. The container can respond to a request for an EJB by instantiating a new instance of the stateless session EJB or using an existing one. If its a new instance the member variable has not been initialised. If its an existing one the member variable has and it has been incremented n times. Any state saved in a specific instance is therefore not reliable. If you need such state, a stateful EJB is the one you need.
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Originally posted by Paul Sturrock:
The instance isn't removed, so I'd imagine its state is unchanged. But then again, why does it matter? My point is state in stateless code can't be trusted, so don't use it.
[ September 26, 2008: Message edited by: Paul Sturrock ]
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
You are right paul, using a state in a stateless bean is pointless and untrustworthy but why can't the container when getting the instance back to the pool make the state which was initialized n times, to a default value?
[OCP 21 book] | [OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2