spring-web

org.springframework.web.context.request
Class SessionScope

java.lang.Object
  extended by org.springframework.web.context.request.AbstractRequestAttributesScope
      extended by org.springframework.web.context.request.SessionScope
All Implemented Interfaces:
org.springframework.beans.factory.config.Scope

public class SessionScope
extends AbstractRequestAttributesScope

Session-backed Scope implementation.

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

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

Since:
2.0
Author:
Rod Johnson, Juergen Hoeller, Rob Harrop
See Also:
RequestContextHolder.currentRequestAttributes(), RequestAttributes.SCOPE_SESSION, RequestAttributes.SCOPE_GLOBAL_SESSION, RequestContextListener, RequestContextFilter, org.springframework.web.servlet.DispatcherServlet, org.springframework.web.portlet.DispatcherPortlet

Constructor Summary
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.
 
Method Summary
 java.lang.Object get(java.lang.String name, org.springframework.beans.factory.ObjectFactory objectFactory)
           
 java.lang.String getConversationId()
           
protected  int getScope()
          Template method that determines the actual target scope.
 java.lang.Object remove(java.lang.String name)
           
 
Methods inherited from class org.springframework.web.context.request.AbstractRequestAttributesScope
registerDestructionCallback, resolveContextualObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SessionScope

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


SessionScope

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
See Also:
org.springframework.web.portlet.context.PortletRequestAttributes, ServletRequestAttributes
Method Detail

getScope

protected int getScope()
Description copied from class: AbstractRequestAttributesScope
Template method that determines the actual target scope.

Specified by:
getScope in class AbstractRequestAttributesScope
Returns:
the target scope, in the form of an appropriate RequestAttributes constant
See Also:
RequestAttributes.SCOPE_REQUEST, RequestAttributes.SCOPE_SESSION, RequestAttributes.SCOPE_GLOBAL_SESSION

getConversationId

public java.lang.String getConversationId()

get

public java.lang.Object get(java.lang.String name,
                            org.springframework.beans.factory.ObjectFactory objectFactory)
Specified by:
get in interface org.springframework.beans.factory.config.Scope
Overrides:
get in class AbstractRequestAttributesScope

remove

public java.lang.Object remove(java.lang.String name)
Specified by:
remove in interface org.springframework.beans.factory.config.Scope
Overrides:
remove in class AbstractRequestAttributesScope

spring-web