Package ninja.session

Interface Session

  • All Known Implementing Classes:

    public interface Session
    • Method Detail

      • init

        void init​(Context context)
        Has to be called initially. => maybe in the future as assisted inject.
        context - The context of this session.
      • getId

        String getId()
        id of a session.
      • getData

        Map<String,​String> getData()
        complete content of session as immutable copy.
      • getAuthenticityToken

        String getAuthenticityToken()
        a authenticity token (may generate a new one if the session currently does not contain the token).
      • save

        void save​(Context context)
        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.
        context - The context from where to deduct a potentially existing session.
      • put

        void put​(String key,
                 String value)
        Puts key / value into the session. PLEASE NOTICE: If value == null the key will be removed!
        key - Name of the key to store in the session.
        value - The value to store in the session
      • get

        String get​(String key)
        Returns the value of the key or null.
        key - Name of the key to retrieve.
        The value of the key or null.
      • remove

        String remove​(String key)
        Removes the value of the key and returns the value or null.
        key - name of the key to remove
        original value of the key we just removed
      • clear

        void clear()
        Removes all values from the session.
      • isEmpty

        boolean isEmpty()
        Returns true if the session is empty, e.g. does not contain anything else than the timestamp key.
        true if session does not contain any values / false if it contains values.
      • setExpiryTime

        void setExpiryTime​(Long expiryTimeMs)
        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.
        expiryTimeMs - the expiry time in milliseconds, set to null to remove the expiry time from the session and use the application default.