类 SessionScope

所有已实现的接口:
cn.taketoday.beans.factory.config.Scope

public class SessionScope extends AbstractRequestContextScope<WebSession>
Session-backed Scope implementation.

Relies on a thread-bound RequestContext instance

从以下版本开始:
4.0 2022/2/21 11:40
作者:
Rod Johnson, Juergen Hoeller, Rob Harrop, Harry Yang
另请参阅:
  • 字段详细资料

    • DESTRUCTION_CALLBACK_NAME_PREFIX

      public static final String DESTRUCTION_CALLBACK_NAME_PREFIX
      Constant identifying the String prefixed to the name of a destruction callback when it is stored in a WebSession.
    • sessionManagerDiscover

      private final SessionManagerDiscover sessionManagerDiscover
  • 构造器详细资料

    • SessionScope

      public SessionScope(cn.taketoday.beans.factory.BeanFactory beanFactory)
  • 方法详细资料

    • getConversationId

      public String getConversationId()
    • get

      public Object get(String name, Supplier<?> objectFactory)
    • remove

      @Nullable public Object remove(String name)
    • getSession

      private WebSession getSession(RequestContext context)
      Returns the current session associated with this request, or if the request does not have a session, creates one.
      参数:
      context - Current request
      返回:
      the WebSession associated with this request
      另请参阅:
    • getSession

      private WebSession getSession(RequestContext request, boolean create)
      Returns the current WebSession associated with this request or, if there is no current session and create is true, returns a new session.

      If create is false and the request has no valid WebSession, this method returns null.

      To make sure the session is properly maintained, you must call this method before the response is committed. If the container is using cookies to maintain session integrity and is asked to create a new session when the response is committed, an IllegalStateException is thrown.

      参数:
      request - Current request
      create - true to create a new session for this request if necessary; false to return null if there's no current session
      返回:
      the WebSession associated with this request or null if create is false and the request has no valid session
      另请参阅:
    • setAttribute

      protected void setAttribute(WebSession context, String beanName, Object scopedObject)
      指定者:
      setAttribute 在类中 AbstractRequestContextScope<WebSession>
    • getAttribute

      protected Object getAttribute(WebSession context, String beanName)
      指定者:
      getAttribute 在类中 AbstractRequestContextScope<WebSession>
    • removeAttribute

      protected void removeAttribute(WebSession context, String name)
      指定者:
      removeAttribute 在类中 AbstractRequestContextScope<WebSession>
    • resolveContextualObject

      @Nullable public Object resolveContextualObject(String key)
    • registerDestructionCallback

      public void registerDestructionCallback(String name, Runnable callback)
    • getDestructionCallbackName

      private static String getDestructionCallbackName(String name)
    • createDestructionCallback

      public static WebSessionAttributeListener createDestructionCallback()