Interface WrappedSession

  • All Superinterfaces:
    Serializable
    All Known Implementing Classes:
    WrappedHttpSession

    public interface WrappedSession
    extends Serializable
    A generic session, wrapping a more specific session implementation, e.g. HttpSession or PortletSession.
    Since:
    7.0.0
    Version:
    Author:
    Vaadin Ltd
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      Object getAttribute​(String name)
      Gets an attribute from this session.
      Set<String> getAttributeNames()
      Gets the current set of attribute names stored in this session.
      long getCreationTime()
      Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.
      String getId()
      Gets a string with a unique identifier for the session.
      long getLastAccessedTime()
      Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight January 1, 1970 GMT, and marked by the time the container received the request.
      int getMaxInactiveInterval()
      Returns the maximum time interval, in seconds, that this session will be kept open between client accesses.
      void invalidate()
      Invalidates this session then unbinds any objects bound to it.
      boolean isNew()
      Returns true if the client does not yet know about the session or if the client chooses not to join the session.
      void removeAttribute​(String name)
      Removes the object bound with the specified name from this session.
      void setAttribute​(String name, Object value)
      Saves an attribute value in this session.
      void setMaxInactiveInterval​(int interval)
      Specifies the time, in seconds, between client requests before the servlet container will invalidate this session.
    • Method Detail

      • getMaxInactiveInterval

        int getMaxInactiveInterval()
        Returns the maximum time interval, in seconds, that this session will be kept open between client accesses.
        Returns:
        an integer specifying the number of seconds this session remains open between client requests
        See Also:
        HttpSession.getMaxInactiveInterval(), javax.portlet.PortletSession#getMaxInactiveInterval()
      • getAttribute

        Object getAttribute​(String name)
        Gets an attribute from this session.
        Parameters:
        name - the name of the attribute
        Returns:
        the attribute value, or null if the attribute is not defined in the session
        See Also:
        HttpSession.getAttribute(String), javax.portlet.PortletSession#getAttribute(String)
      • setAttribute

        void setAttribute​(String name,
                          Object value)
        Saves an attribute value in this session.
        Parameters:
        name - the name of the attribute
        value - the attribute value
        See Also:
        HttpSession.setAttribute(String, Object), javax.portlet.PortletSession#setAttribute(String, Object)
      • getAttributeNames

        Set<String> getAttributeNames()
        Gets the current set of attribute names stored in this session.
        Returns:
        an unmodifiable set of the current attribute names
        See Also:
        HttpSession.getAttributeNames(), PortletSession#getAttributeNames()
      • invalidate

        void invalidate()
        Invalidates this session then unbinds any objects bound to it.
        See Also:
        HttpSession.invalidate(), PortletSession#invalidate()
      • getId

        String getId()
        Gets a string with a unique identifier for the session.
        Returns:
        a unique session id string
        See Also:
        HttpSession.getId(), PortletSession#getId()
      • getCreationTime

        long getCreationTime()
        Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.
        Returns:
        a long specifying when this session was created, expressed in milliseconds since 1/1/1970 GMT
        Throws:
        IllegalStateException - if this method is called on an invalidated session
        See Also:
        HttpSession.getCreationTime(), PortletSession#getCreationTime()
      • getLastAccessedTime

        long getLastAccessedTime()
        Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight January 1, 1970 GMT, and marked by the time the container received the request.

        Actions that your application takes, such as getting or setting a value associated with the session, do not affect the access time.

        Returns:
        a long representing the last time the client sent a request associated with this session, expressed in milliseconds since 1/1/1970 GMT
        Throws:
        IllegalStateException - if this method is called on an invalidated session
        See Also:
        HttpSession.getLastAccessedTime(), PortletSession#getLastAccessedTime()
      • isNew

        boolean isNew()
        Returns true if the client does not yet know about the session or if the client chooses not to join the session. For example, if the server used only cookie-based sessions, and the client had disabled the use of cookies, then a session would be new on each request.
        Returns:
        true if the server has created a session, but the client has not yet joined
        Throws:
        IllegalStateException - if this method is called on an invalidated session
        See Also:
        HttpSession.isNew(), PortletSession#isNew()
      • removeAttribute

        void removeAttribute​(String name)
        Removes the object bound with the specified name from this session. If the session does not have an object bound with the specified name, this method does nothing.
        Parameters:
        name - the name of the object to remove from this session
        Throws:
        IllegalStateException - if this method is called on an invalidated session
        See Also:
        HttpSession.removeAttribute(String), PortletSession#removeAttribute(String)
      • setMaxInactiveInterval

        void setMaxInactiveInterval​(int interval)
        Specifies the time, in seconds, between client requests before the servlet container will invalidate this session. A negative time indicates the session should never timeout.
        Parameters:
        interval - An integer specifying the number of seconds
        See Also:
        HttpSession.setMaxInactiveInterval(int), PortletSession#setMaxInactiveInterval(int)