Top Description Constructors Methods
org.springframework.web.context.request

public Class SessionScope

extends AbstractRequestAttributesScope
Class Inheritance
Imports
org.springframework.beans.factory.ObjectFactory, org.springframework.lang.Nullable

Session-backed org.springframework.beans.factory.config.Scope implementation.

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

Authors
Rod Johnson, Juergen Hoeller, Rob Harrop
Since
2.0
See Also
RequestContextHolder#currentRequestAttributes(), RequestAttributes#SCOPE_SESSION, RequestContextListener, org.springframework.web.filter.RequestContextFilter, org.springframework.web.servlet.DispatcherServlet

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Object
get(String
the name of the object to retrieve
name
,
ObjectFactory<?>
the ObjectFactory to use to create the scoped object if it is not present in the underlying storage mechanism
objectFactory
)

Overrides org.springframework.web.context.request.AbstractRequestAttributesScope.get.

Implements org.springframework.beans.factory.config.Scope.get.

Return the object with the given name from the underlying scope, creating it if not found in the underlying storage mechanism.

public String
getConversationId()

Implements org.springframework.beans.factory.config.Scope.getConversationId.

Return the conversation ID for the current underlying scope, if any.

protected int
getScope()

Implements abstract org.springframework.web.context.request.AbstractRequestAttributesScope.getScope.

Template method that determines the actual target scope.

public Object
remove(String
the name of the object to remove
name
)

Overrides org.springframework.web.context.request.AbstractRequestAttributesScope.remove.

Implements org.springframework.beans.factory.config.Scope.remove.

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

Inherited from org.springframework.web.context.request.AbstractRequestAttributesScope:
registerDestructionCallbackresolveContextualObject

Constructor Detail

SessionScopeback to summary
public SessionScope()

Method Detail

getback to summary
public Object get(String name, ObjectFactory<?> objectFactory)

Overrides org.springframework.web.context.request.AbstractRequestAttributesScope.get.

Implements org.springframework.beans.factory.config.Scope.get.

Doc from org.springframework.beans.factory.config.Scope.get.

Return the object with the given name from the underlying scope, creating it if not found in the underlying storage mechanism.

This is the central operation of a Scope, and the only operation that is absolutely required.

Parameters
name:String

the name of the object to retrieve

objectFactory:ObjectFactory<?>

the ObjectFactory to use to create the scoped object if it is not present in the underlying storage mechanism

Returns:Object

the desired object (never null)

Annotations
@Override
getConversationIdback to summary
public String getConversationId()

Implements org.springframework.beans.factory.config.Scope.getConversationId.

Doc from org.springframework.beans.factory.config.Scope.getConversationId.

Return the conversation ID for the current underlying scope, if any.

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 return null in an implementation of this method if the underlying storage mechanism has no obvious candidate for such an ID.

Returns:String

the conversation ID, or null if there is no conversation ID for the current scope

Annotations
@Override
getScopeback to summary
protected int getScope()

Implements abstract org.springframework.web.context.request.AbstractRequestAttributesScope.getScope.

Doc from org.springframework.web.context.request.AbstractRequestAttributesScope.getScope.

Template method that determines the actual target scope.

Returns:int

the target scope, in the form of an appropriate RequestAttributes constant

Annotations
@Override
removeback to summary
public Object remove(String name)

Overrides org.springframework.web.context.request.AbstractRequestAttributesScope.remove.

Implements org.springframework.beans.factory.config.Scope.remove.

Doc from org.springframework.beans.factory.config.Scope.remove.

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:String

the name of the object to remove

Returns:Object

the removed object, or null if no object was present

Annotations
@Override
@Nullable