Package org.eclipse.jetty.server.session
Class SessionData
- java.lang.Object
-
- org.eclipse.jetty.server.session.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 Summary
Fields Modifier and Type Field Description protected long
_accessed
protected java.util.Map<java.lang.String,java.lang.Object>
_attributes
protected java.lang.String
_contextPath
protected long
_cookieSet
protected long
_created
protected boolean
_dirty
protected long
_expiry
protected java.lang.String
_id
protected long
_lastAccessed
protected java.lang.String
_lastNode
protected long
_lastSaved
protected long
_maxInactiveMs
protected boolean
_metaDataDirty
protected java.lang.String
_vhost
-
Constructor Summary
Constructors Constructor Description SessionData(java.lang.String id, java.lang.String cpath, java.lang.String vhost, long created, long accessed, long lastAccessed, long maxInactiveMs)
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 Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
calcAndSetExpiry()
void
calcAndSetExpiry(long time)
long
calcExpiry()
long
calcExpiry(long time)
void
clean()
Clear all dirty flags.void
clearAllAttributes()
Remove all attributesvoid
copy(SessionData data)
Copy the info from the given sessiondatastatic void
deserializeAttributes(SessionData data, java.io.ObjectInputStream in)
De-serialize the attribute map of a session.long
getAccessed()
java.util.Map<java.lang.String,java.lang.Object>
getAllAttributes()
java.lang.Object
getAttribute(java.lang.String name)
java.lang.String
getContextPath()
long
getCookieSet()
long
getCreated()
long
getExpiry()
java.lang.String
getId()
java.util.Set<java.lang.String>
getKeys()
long
getLastAccessed()
java.lang.String
getLastNode()
long
getLastSaved()
long
getMaxInactiveMs()
java.lang.String
getVhost()
boolean
isDirty()
boolean
isExpiredAt(long time)
boolean
isMetaDataDirty()
void
putAllAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes)
static void
serializeAttributes(SessionData data, java.io.ObjectOutputStream out)
Serialize the attribute map of the session.void
setAccessed(long accessed)
java.lang.Object
setAttribute(java.lang.String name, java.lang.Object value)
void
setContextPath(java.lang.String contextPath)
void
setCookieSet(long cookieSet)
void
setCreated(long created)
void
setDirty(boolean dirty)
void
setDirty(java.lang.String name)
void
setExpiry(long expiry)
void
setId(java.lang.String id)
void
setLastAccessed(long lastAccessed)
void
setLastNode(java.lang.String lastNode)
void
setLastSaved(long lastSaved)
void
setMaxInactiveMs(long maxInactive)
void
setMetaDataDirty(boolean metaDataDirty)
void
setVhost(java.lang.String vhost)
java.lang.String
toString()
-
-
-
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
-
_metaDataDirty
protected boolean _metaDataDirty
-
-
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 attributesout
- 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 mapin
- 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)
-
isMetaDataDirty
public boolean isMetaDataDirty()
- Returns:
- the metaDataDirty
-
setMetaDataDirty
public void setMetaDataDirty(boolean metaDataDirty)
- Parameters:
metaDataDirty
- true means non-attribute data has changed
-
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)
-
clean
public void clean()
Clear all dirty flags.
-
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 classjava.lang.Object
-
-