类 SessionScope
- java.lang.Object
- org.springframework.web.context.request.AbstractRequestAttributesScope
- org.springframework.web.context.request.SessionScope
- 所有已实现的接口:
Scope
public class SessionScope extends AbstractRequestAttributesScope
Session-backedScopeimplementation.Relies on a thread-bound
RequestAttributesinstance, which can be exported throughRequestContextListener,RequestContextFilterorDispatcherServlet.- 从以下版本开始:
- 2.0
- 作者:
- Rod Johnson, Juergen Hoeller, Rob Harrop
- 另请参阅:
RequestContextHolder.currentRequestAttributes(),RequestAttributes.SCOPE_SESSION,RequestContextListener,RequestContextFilter,DispatcherServlet
构造器概要
构造器 构造器 说明 SessionScope()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 Objectget(String name, ObjectFactory<?> objectFactory)Return the object with the given name from the underlying scope,creating itif not found in the underlying storage mechanism.StringgetConversationId()Return the conversation ID for the current underlying scope, if any.protected intgetScope()Template method that determines the actual target scope.Objectremove(String name)Remove the object with the givennamefrom the underlying scope.从类继承的方法 org.springframework.web.context.request.AbstractRequestAttributesScope
registerDestructionCallback, resolveContextualObject
构造器详细资料
SessionScope
public SessionScope()
方法详细资料
getScope
protected int getScope()
从类复制的说明:AbstractRequestAttributesScopeTemplate method that determines the actual target scope.- 指定者:
getScope在类中AbstractRequestAttributesScope- 返回:
- the target scope, in the form of an appropriate
RequestAttributesconstant - 另请参阅:
RequestAttributes.SCOPE_REQUEST,RequestAttributes.SCOPE_SESSION
getConversationId
public String getConversationId()
从接口复制的说明:ScopeReturn 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
nullin an implementation of this method if the underlying storage mechanism has no obvious candidate for such an ID.- 返回:
- the conversation ID, or
nullif there is no conversation ID for the current scope
get
public Object get(String name, ObjectFactory<?> objectFactory)
从接口复制的说明:ScopeReturn the object with the given name from the underlying scope,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.
- 指定者:
get在接口中Scope- 覆盖:
get在类中AbstractRequestAttributesScope- 参数:
name- the name of the object to retrieveobjectFactory- theObjectFactoryto use to create the scoped object if it is not present in the underlying storage mechanism- 返回:
- the desired object (never
null)
remove
@Nullable public Object remove(String name)
从接口复制的说明:ScopeRemove the object with the givennamefrom the underlying scope.Returns
nullif no object was found; otherwise returns the removedObject.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
UnsupportedOperationExceptionif they do not support explicitly removing an object.- 指定者:
remove在接口中Scope- 覆盖:
remove在类中AbstractRequestAttributesScope- 参数:
name- the name of the object to remove- 返回:
- the removed object, or
nullif no object was present - 另请参阅:
Scope.registerDestructionCallback(java.lang.String, java.lang.Runnable)