Implementing a Stateful Session Bean
When implementing a stateful Session bean, there are a number of issues that you must keep in mind. They are discussed in this section.
Passivation
Unlike stateless Session beans, stateful Session beans are at liberty to store client- specific state information in instance variables. However, because your bean may be passivated, any instance variables you define must be either primitives, references to serializable objects, or—failing that—be transient.
Of course, any transient variables will be reset to null if the bean is passivated and then re-activated, so your implementation will need to deal with this. Classes that are not serializable often depend in some way on the environment, such as an open java.net.Socket ...
Get Sams Teach Yourself J2EE™ in 21 Days now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.