Sun ONE Application Server 7, Enterprise Edition Application Design Guidelines for Storing Session State |
Chapter 1
IntroductionThis chapter provides some background information on how HTTP session state is managed by the Sun ONE Application Server.
Sun ONE Application Server uses a high-availability database (HADB), to make the state of HTTP session objects highly available and resilient against failures. All serializable objects stored in HttpSession are persisted and made available to other server instances in the event a server instance fails. Since some EJB references and references to other serializable J2EE components such as InitialContexts and DataSources are serializable, the application developer must understand how these references behave when a failover occurs.
This document provides guidelines for working with these reference types in the Sun ONE Application Server.
The following table lists various J2EE object types and provides information on whether reference failover is supported.
The left column lists the EJB reference types, the second column indicates if Home reference is supported or not, the third column indicates if the Object reference is supported or not, and the right-most column indicates if it is recommended or not.
Table 1-1 EJB Reference Types
EJB Reference Types (Local or Remote1)
Home Reference Supported
Object Reference Supported
Recommended
Stateless Session Bean
Yes
Yes
No
Stateful Session Bean
Yes
No
No2
Entity Bean
Yes
Yes
Home - No
Object - Yes
1In the Sun ONE Application Server, remote EJB references are co-located in the same virtual machine as EJB references.
2Stateful Session bean object reference types would be recommended for HttpSession if stateful session bean reference failover was supported by the Sun ONE Application Server.
The left column lists the JMS reference types, the second column indicates if the JMS reference type is supported or not, the third column indicates if it is recommended or not.
Table 1-2 JMS Reference Types
JMS References
Supported
Recommended
ConnectionFactory
No
No
Connection
No
No
Session
No
No
Destination
No
No
MessageProducer
No
No
MessageConsumer
No
No
The left column lists the J2EE reference types, the second column indicates if the J2EE reference type is supported or not, the third column indicates if it is recommended or not.
So of all the reference types listed above, only references to stateful session beans and entity beans should be stored in the session. All the other referenced object types are stateless in nature and must not be held in a user’s session from one web request to the next. Since the Sun ONE Application Server does not provide failover support for stateful session beans, if failover is a requirement in your application, the only reference type that should be stored in HttpSession is an entity bean reference.