Package ninja.session

Class SessionImpl

    • Method Detail

      • init

        public void init​(Context context)
        Description copied from interface: Session
        Has to be called initially. => maybe in the future as assisted inject.
        Specified by:
        init in interface Session
        Parameters:
        context - The context of this session.
      • shouldExpire

        protected boolean shouldExpire()
      • setExpiryTime

        public void setExpiryTime​(Long expiryTimeMs)
        Description copied from interface: Session
        Use an alternative expiry time, this can be used to implement a longer expiry time for 'remember me' style functionality. The expiry time is persisted in the session.
        Specified by:
        setExpiryTime in interface Session
        Parameters:
        expiryTimeMs - the expiry time in milliseconds, set to null to remove the expiry time from the session and use the application default.
      • getId

        public String getId()
        Specified by:
        getId in interface Session
        Returns:
        id of a session.
      • getData

        public Map<String,​String> getData()
        Specified by:
        getData in interface Session
        Returns:
        complete content of session as immutable copy.
      • getAuthenticityToken

        public String getAuthenticityToken()
        Specified by:
        getAuthenticityToken in interface Session
        Returns:
        a authenticity token (may generate a new one if the session currently does not contain the token).
      • save

        public void save​(Context context)
        Description copied from interface: Session
        To finally send this session to the user this method has to be called. It basically serializes the session into the header of the response.
        Specified by:
        save in interface Session
        Parameters:
        context - The context from where to deduct a potentially existing session.
      • put

        public void put​(String key,
                        String value)
        Description copied from interface: Session
        Puts key / value into the session. PLEASE NOTICE: If value == null the key will be removed!
        Specified by:
        put in interface Session
        Parameters:
        key - Name of the key to store in the session.
        value - The value to store in the session
      • get

        public String get​(String key)
        Description copied from interface: Session
        Returns the value of the key or null.
        Specified by:
        get in interface Session
        Parameters:
        key - Name of the key to retrieve.
        Returns:
        The value of the key or null.
      • remove

        public String remove​(String key)
        Description copied from interface: Session
        Removes the value of the key and returns the value or null.
        Specified by:
        remove in interface Session
        Parameters:
        key - name of the key to remove
        Returns:
        original value of the key we just removed
      • clear

        public void clear()
        Description copied from interface: Session
        Removes all values from the session.
        Specified by:
        clear in interface Session
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: Session
        Returns true if the session is empty, e.g. does not contain anything else than the timestamp key.
        Specified by:
        isEmpty in interface Session
        Returns:
        true if session does not contain any values / false if it contains values.