Class JEESessionStore

  • All Implemented Interfaces:
    SessionStore

    public class JEESessionStore
    extends java.lang.Object
    implements SessionStore
    Store data in the JEE web session.
    Since:
    1.8.1
    Author:
    Jerome Leleu
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected JEESessionStore()  
      protected JEESessionStore​(javax.servlet.http.HttpSession httpSession)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Optional<SessionStore> buildFromTrackableSession​(WebContext context, java.lang.Object trackableSession)
      Build a new session store from a trackable session.
      boolean destroySession​(WebContext context)
      Destroy the web session.
      java.util.Optional<java.lang.Object> get​(WebContext context, java.lang.String key)
      Get the object from its key in store.
      protected java.util.Optional<javax.servlet.http.HttpSession> getNativeSession​(WebContext context, boolean createSession)  
      java.util.Optional<java.lang.String> getSessionId​(WebContext context, boolean createSession)
      Get or create the session identifier and initialize the session with it if necessary.
      java.util.Optional<java.lang.Object> getTrackableSession​(WebContext context)
      Get the native session as a trackable object.
      boolean renewSession​(WebContext context)
      Renew the native session by copying all data to a new one.
      void set​(WebContext context, java.lang.String key, java.lang.Object value)
      Save an object in the store by its key.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • httpSession

        protected javax.servlet.http.HttpSession httpSession
    • Constructor Detail

      • JEESessionStore

        protected JEESessionStore()
      • JEESessionStore

        protected JEESessionStore​(javax.servlet.http.HttpSession httpSession)
    • Method Detail

      • getNativeSession

        protected java.util.Optional<javax.servlet.http.HttpSession> getNativeSession​(WebContext context,
                                                                                      boolean createSession)
      • getSessionId

        public java.util.Optional<java.lang.String> getSessionId​(WebContext context,
                                                                 boolean createSession)
        Description copied from interface: SessionStore
        Get or create the session identifier and initialize the session with it if necessary.
        Specified by:
        getSessionId in interface SessionStore
        Parameters:
        context - the web context
        Returns:
        the optional session identifier
      • get

        public java.util.Optional<java.lang.Object> get​(WebContext context,
                                                        java.lang.String key)
        Description copied from interface: SessionStore
        Get the object from its key in store.
        Specified by:
        get in interface SessionStore
        Parameters:
        context - the web context
        key - the key of the object
        Returns:
        the optional object in store
      • set

        public void set​(WebContext context,
                        java.lang.String key,
                        java.lang.Object value)
        Description copied from interface: SessionStore
        Save an object in the store by its key.
        Specified by:
        set in interface SessionStore
        Parameters:
        context - the web context
        key - the key of the object
        value - the value to save in store
      • destroySession

        public boolean destroySession​(WebContext context)
        Description copied from interface: SessionStore
        Destroy the web session.
        Specified by:
        destroySession in interface SessionStore
        Parameters:
        context - the web context
        Returns:
        whether the session has been destroyed
      • getTrackableSession

        public java.util.Optional<java.lang.Object> getTrackableSession​(WebContext context)
        Description copied from interface: SessionStore
        Get the native session as a trackable object.
        Specified by:
        getTrackableSession in interface SessionStore
        Parameters:
        context - the web context
        Returns:
        the optional trackable object
      • buildFromTrackableSession

        public java.util.Optional<SessionStore> buildFromTrackableSession​(WebContext context,
                                                                          java.lang.Object trackableSession)
        Description copied from interface: SessionStore
        Build a new session store from a trackable session.
        Specified by:
        buildFromTrackableSession in interface SessionStore
        Parameters:
        context - the web context
        trackableSession - the trackable session
        Returns:
        the optional new session store
      • renewSession

        public boolean renewSession​(WebContext context)
        Description copied from interface: SessionStore
        Renew the native session by copying all data to a new one.
        Specified by:
        renewSession in interface SessionStore
        Parameters:
        context - the web context
        Returns:
        whether the session store has renewed the session