Package org.eclipse.jetty.server.session
Class SessionData
- java.lang.Object
-
- org.eclipse.jetty.server.session.SessionData
-
- All Implemented Interfaces:
Serializable
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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected long_accessedprotected Map<String,Object>_attributesprotected String_contextPathprotected long_cookieSetprotected long_createdprotected boolean_dirtyprotected long_expiryprotected String_idprotected long_lastAccessedprotected String_lastNodeprotected long_lastSavedprotected long_maxInactiveMsprotected String_vhost
-
Constructor Summary
Constructors Constructor Description SessionData(String id, String cpath, String vhost, long created, long accessed, long lastAccessed, long maxInactiveMs)SessionData(String id, String cpath, String vhost, long created, long accessed, long lastAccessed, long maxInactiveMs, Map<String,Object> attributes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcalcAndSetExpiry()voidcalcAndSetExpiry(long time)longcalcExpiry()longcalcExpiry(long time)voidclearAllAttributes()Remove all attributesvoidcopy(SessionData data)Copy the info from the given sessiondatastatic voiddeserializeAttributes(SessionData data, ObjectInputStream in)De-serialize the attribute map of a session.longgetAccessed()Map<String,Object>getAllAttributes()ObjectgetAttribute(String name)StringgetContextPath()longgetCookieSet()longgetCreated()longgetExpiry()StringgetId()Set<String>getKeys()longgetLastAccessed()StringgetLastNode()longgetLastSaved()longgetMaxInactiveMs()StringgetVhost()booleanisDirty()booleanisExpiredAt(long time)voidputAllAttributes(Map<String,Object> attributes)static voidserializeAttributes(SessionData data, ObjectOutputStream out)Serialize the attribute map of the session.voidsetAccessed(long accessed)ObjectsetAttribute(String name, Object value)voidsetContextPath(String contextPath)voidsetCookieSet(long cookieSet)voidsetCreated(long created)voidsetDirty(boolean dirty)voidsetDirty(String name)voidsetExpiry(long expiry)voidsetId(String id)voidsetLastAccessed(long lastAccessed)voidsetLastNode(String lastNode)voidsetLastSaved(long lastSaved)voidsetMaxInactiveMs(long maxInactive)voidsetVhost(String vhost)StringtoString()
-
-
-
Field Detail
-
_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
-
_dirty
protected boolean _dirty
-
_lastSaved
protected long _lastSaved
-
-
Method Detail
-
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 attributesout- 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 mapin- the serialized stream- Throws:
IOExceptionClassNotFoundException
-
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 Object getAttribute(String name)
- Parameters:
name- the name of the attribute- Returns:
- the value of the attribute named
-
setDirty
public void setDirty(String name)
-
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)
-
-