5.2.2. Stateful session beans
Stateful session bean components can not only hold state across multiple invocations of the bean, but also across multiple requests. Any application state that does not belong in the database should be held by stateful session beans. This is a major difference between Seam and many other web application frameworks. Current conversation data should be stored in the instance variables of a stateful session bean bound to the conversation context, rather than in the
HttpSession
. This lets Seam manage state lifecycle, and ensures there are no collisions between state relating to different concurrent conversations.
Stateful session beans are often used as JSF action listeners, and as backing beans to provide properties to JSF components for display or form submission.
By default, stateful session beans are bound to the conversation context. They may never be bound to the page, or to stateless contexts.
Seam serializes concurrent requests to session-scoped stateful session beans while Seam interceptors are enabled.
Seam stateful session bean components are instantiated with either
Component.getInstance()
or @In(create=true)
. They should not be directly instantiated via JNDI lookup or the new
operator.