Class SessionData

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    InfinispanSessionData, NoSqlSessionDataStore.NoSqlSessionData

    public class SessionData
    extends java.lang.Object
    implements java.io.Serializable
    SessionData The data associated with a session. A Session object has a 1:1 relationship with a SessionData object. The behaviour of sessions is implemented in the Session object (eg calling listeners, keeping timers etc). A Session's associated SessionData is the object which can be persisted, serialized etc.
    See Also:
    Serialized Form
    • Field Detail

      • _id

        protected java.lang.String _id
      • _contextPath

        protected java.lang.String _contextPath
      • _vhost

        protected java.lang.String _vhost
      • _lastNode

        protected java.lang.String _lastNode
      • _expiry

        protected long _expiry
      • _created

        protected long _created
      • _cookieSet

        protected long _cookieSet
      • _accessed

        protected long _accessed
      • _lastAccessed

        protected long _lastAccessed
      • _maxInactiveMs

        protected long _maxInactiveMs
      • _attributes

        protected java.util.Map<java.lang.String,​java.lang.Object> _attributes
      • _dirty

        protected boolean _dirty
      • _lastSaved

        protected long _lastSaved
    • Constructor Detail

      • SessionData

        public SessionData​(java.lang.String id,
                           java.lang.String cpath,
                           java.lang.String vhost,
                           long created,
                           long accessed,
                           long lastAccessed,
                           long maxInactiveMs)
      • SessionData

        public SessionData​(java.lang.String id,
                           java.lang.String cpath,
                           java.lang.String vhost,
                           long created,
                           long accessed,
                           long lastAccessed,
                           long maxInactiveMs,
                           java.util.Map<java.lang.String,​java.lang.Object> attributes)
    • Method Detail

      • serializeAttributes

        public static void serializeAttributes​(SessionData data,
                                               java.io.ObjectOutputStream out)
                                        throws java.io.IOException
        Serialize the attribute map of the session. This special handling allows us to record which classloader should be used to load the value of the attribute: either the container classloader (which could be the application loader ie null, or jetty's startjar loader) or the webapp's classloader.
        Parameters:
        data - the SessionData for which to serialize the attributes
        out - the stream to which to serialize
        Throws:
        java.io.IOException
      • deserializeAttributes

        public static void deserializeAttributes​(SessionData data,
                                                 java.io.ObjectInputStream in)
                                          throws java.io.IOException,
                                                 java.lang.ClassNotFoundException
        De-serialize the attribute map of a session. When the session was serialized, we will have recorded which classloader should be used to recover the attribute value. The classloader could be the container classloader, or the webapp classloader.
        Parameters:
        data - the SessionData for which to deserialize the attribute map
        in - the serialized stream
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • copy

        public void copy​(SessionData data)
        Copy the info from the given sessiondata
        Parameters:
        data - the sessiondata to be copied
      • getLastSaved

        public long getLastSaved()
        Returns:
        time at which session was last written out
      • setLastSaved

        public void setLastSaved​(long lastSaved)
      • isDirty

        public boolean isDirty()
        Returns:
        true if a session needs to be written out
      • setDirty

        public void setDirty​(boolean dirty)
      • getAttribute

        public java.lang.Object getAttribute​(java.lang.String name)
        Parameters:
        name - the name of the attribute
        Returns:
        the value of the attribute named
      • getKeys

        public java.util.Set<java.lang.String> getKeys()
        Returns:
        a Set of attribute names
      • setAttribute

        public java.lang.Object setAttribute​(java.lang.String name,
                                             java.lang.Object value)
      • setDirty

        public void setDirty​(java.lang.String name)
      • putAllAttributes

        public void putAllAttributes​(java.util.Map<java.lang.String,​java.lang.Object> attributes)
      • clearAllAttributes

        public void clearAllAttributes()
        Remove all attributes
      • getAllAttributes

        public java.util.Map<java.lang.String,​java.lang.Object> getAllAttributes()
        Returns:
        an unmodifiable map of the attributes
      • getId

        public java.lang.String getId()
        Returns:
        the id of the session
      • setId

        public void setId​(java.lang.String id)
      • getContextPath

        public java.lang.String getContextPath()
        Returns:
        the context path associated with this session
      • setContextPath

        public void setContextPath​(java.lang.String contextPath)
      • getVhost

        public java.lang.String getVhost()
        Returns:
        virtual host of context associated with session
      • setVhost

        public void setVhost​(java.lang.String vhost)
      • getLastNode

        public java.lang.String getLastNode()
        Returns:
        last node to manage the session
      • setLastNode

        public void setLastNode​(java.lang.String lastNode)
      • getExpiry

        public long getExpiry()
        Returns:
        time at which session expires
      • setExpiry

        public void setExpiry​(long expiry)
      • calcExpiry

        public long calcExpiry()
      • calcExpiry

        public long calcExpiry​(long time)
      • calcAndSetExpiry

        public void calcAndSetExpiry​(long time)
      • calcAndSetExpiry

        public void calcAndSetExpiry()
      • getCreated

        public long getCreated()
      • setCreated

        public void setCreated​(long created)
      • getCookieSet

        public long getCookieSet()
        Returns:
        time cookie was set
      • setCookieSet

        public void setCookieSet​(long cookieSet)
      • getAccessed

        public long getAccessed()
        Returns:
        time session was accessed
      • setAccessed

        public void setAccessed​(long accessed)
      • getLastAccessed

        public long getLastAccessed()
        Returns:
        previous time session was accessed
      • setLastAccessed

        public void setLastAccessed​(long lastAccessed)
      • getMaxInactiveMs

        public long getMaxInactiveMs()
      • setMaxInactiveMs

        public void setMaxInactiveMs​(long maxInactive)
      • isExpiredAt

        public boolean isExpiredAt​(long time)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object