public class

SessionScope

extends AbstractRequestAttributesScope
java.lang.Object
   ↳ org.springframework.web.context.request.AbstractRequestAttributesScope
     ↳ org.springframework.web.context.request.SessionScope

Class Overview

Session-backed Scope implementation.

Relies on a thread-bound RequestAttributes instance, which can be exported through RequestContextListener, RequestContextFilter or DispatcherServlet.

This Scope will also work for Portlet environments, through an alternate RequestAttributes implementation (as exposed out-of-the-box by Spring's DispatcherPortlet.

Summary

Public Constructors
SessionScope()
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).
SessionScope(boolean globalSession)
Create a new SessionScope, specifying whether to store attributes in the global session, provided that such a distinction is available.
Public Methods
Object get(String name, ObjectFactory objectFactory)
String getConversationId()
Object remove(String name)
Remove the object with the given name from the underlying scope.
Protected Methods
int getScope()
Template method that determines the actual target scope.
[Expand]
Inherited Methods
From class org.springframework.web.context.request.AbstractRequestAttributesScope
From class java.lang.Object
From interface org.springframework.beans.factory.config.Scope

Public Constructors

public SessionScope ()

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).

public SessionScope (boolean globalSession)

Create a new SessionScope, specifying whether to store attributes in the global session, provided that such a distinction is available.

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.

Parameters
globalSession true in case of the global session as target; false in case of a component-specific session as target

Public Methods

public Object get (String name, ObjectFactory objectFactory)

public String getConversationId ()

public Object remove (String name)

Remove the object with the given name from the underlying scope.

Returns null if no object was found; otherwise returns the removed Object.

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.

Parameters
name the name of the object to remove
Returns
  • the removed object, or null if no object was present

Protected Methods

protected int getScope ()

Template method that determines the actual target scope.

Returns