Class SessionData

java.lang.Object
org.eclipse.jetty.server.session.SessionData
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
InfinispanSessionData, NoSqlSessionDataStore.NoSqlSessionData

public class SessionData extends Object implements 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:
  • Field Details

    • _id

      protected String _id
    • _contextPath

      protected String _contextPath
    • _vhost

      protected String _vhost
    • _lastNode

      protected 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 Map<String,Object> _attributes
    • _dirty

      protected boolean _dirty
    • _lastSaved

      protected long _lastSaved
    • _metaDataDirty

      protected boolean _metaDataDirty
  • Constructor Details

    • SessionData

      public SessionData(String id, String cpath, String vhost, long created, long accessed, long lastAccessed, long maxInactiveMs)
    • SessionData

      public SessionData(String id, String cpath, String vhost, long created, long accessed, long lastAccessed, long maxInactiveMs, Map<String,Object> attributes)
  • Method Details

    • serializeAttributes

      public static void serializeAttributes(SessionData data, ObjectOutputStream out) throws 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:
      IOException
    • deserializeAttributes

      public static void deserializeAttributes(SessionData data, ObjectInputStream in) throws IOException, 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:
      IOException
      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)
    • setDirty

      public void setDirty(String name)
    • isMetaDataDirty

      public boolean isMetaDataDirty()
      Returns:
      the metaDataDirty
    • setMetaDataDirty

      public void setMetaDataDirty(boolean metaDataDirty)
      Parameters:
      metaDataDirty - true means non-attribute data has changed
    • getAttribute

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

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

      public Object setAttribute(String name, Object value)
    • clean

      public void clean()
      Clear all dirty flags.
    • putAllAttributes

      public void putAllAttributes(Map<String,Object> attributes)
    • clearAllAttributes

      public void clearAllAttributes()
      Remove all attributes
    • getAllAttributes

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

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

      public void setId(String id)
    • getContextPath

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

      public void setContextPath(String contextPath)
    • getVhost

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

      public void setVhost(String vhost)
    • getLastNode

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

      public void setLastNode(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 String toString()
      Overrides:
      toString in class Object