public class SessionScope extends AbstractRequestAttributesScope
Scope will also work for Portlet environments,
through an alternate
(as exposed out-of-the-box by Spring's
|Constructor and Description|
Create a new SessionScope, storing attributes in a locally isolated session (or default session, if there is no distinction between a global session and a component-specific session).
Create a new SessionScope, specifying whether to store attributes in the global session, provided that such a distinction is available.
|Modifier and Type||Method and Description|
Return the object with the given name from the underlying scope,
Return the conversation ID for the current underlying scope, if any.
Template method that determines the actual target scope.
Remove the object with the given
public SessionScope(boolean globalSession)
This distinction is important for Portlet environments, where there are two notions of a session: "portlet scope" and "application scope". If this flag is on, objects will be put into the "application scope" session; else they will end up in the "portlet scope" session (the typical default).
In a Servlet environment, this flag is effectively ignored.
protected int getScope()
public java.lang.String getConversationId()
The exact meaning of the conversation ID depends on the underlying
storage mechanism. In the case of session-scoped objects, the
conversation ID would typically be equal to (or derived from) the
session ID; in the
case of a custom conversation that sits within the overall session,
the specific ID for the current conversation would be appropriate.
Note: This is an optional operation. It is perfectly valid to
null in an implementation of this method if the
underlying storage mechanism has no obvious candidate for such an ID.
nullif there is no conversation ID for the current scope
public java.lang.Object get(java.lang.String name, ObjectFactory objectFactory)
creating itif not found in the underlying storage mechanism.
This is the central operation of a Scope, and the only operation that is absolutely required.
name- the name of the object to retrieve
ObjectFactoryto use to create the scoped object if it is not present in the underlying storage mechanism
public java.lang.Object remove(java.lang.String name)
namefrom the underlying scope.
null if no object was found; otherwise
returns the removed
Note that an implementation should also remove a registered destruction callback for the specified object, if any. It does, however, not need to execute a registered destruction callback in this case, since the object will be destroyed by the caller (if appropriate).
Note: This is an optional operation. Implementations may throw
UnsupportedOperationException if they do not support explicitly
removing an object.
name- the name of the object to remove
nullif no object was present