Should a member variable be declared "public" to participate in session state in a Statefull Session Bean. I am simply startled to see a simple Count bean example from Ed Roman book which has a "public int val". Is it part of the EJB Specs? What you people have to say about it? Guru are you listening? :roll:
I don�t think so. I won�t make references to EJB specs, since I cannot remember the specs totally (I hope someone else will do), but when we speak about a SFSB�s session state I might consider couple of things:
The way SFSB�s state is saved/retrieved during passivation/activation.
The way the container saves the bean�s state in a cluster environment if a sever failure occurs.
As far as I remember the first one has nothing to do with public, private or protected variables. It has everything to do whether the attributes themselves are serializable or not. As for the second one, it is vendor specific. WebLogic for example does an in-memory replication of the SFSB, which means that it keeps two copies of the same bean on different server instance within a cluster, in a primary-secondary manner (they are kept in sync using IP-multicast). If the primary server fails, WL will redirect client�s requests to the secondary (which will get promoted to primary and another secondary will be picked up). Again this has nothing to do with whether the variables are public or not. Finally I would imagine that a strategy that doesn�t save "private" state would be error prone, since good OOD says that internal attributes must be declared private, no matter if the class is a POJO or a SFSB.
I think, therefore I exist -- Rene Descartes
Joined: Jul 23, 2003
Your explanation created special interest to my post. I personally found the points quite informative, especially, the second one. I now understand that access modifiers for instance variables should be declared private for SF Session Beans.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com