Package org.eclipse.jetty.server.session
Class SessionData
java.lang.Object
org.eclipse.jetty.server.session.SessionData
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
InfinispanSessionData
,NoSqlSessionDataStore.NoSqlSessionData
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 Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
calcAndSetExpiry
(long time) long
long
calcExpiry
(long time) void
clean()
Clear all dirty flags.void
Remove all attributesvoid
copy
(SessionData data) Copy the info from the given sessiondatastatic void
De-serialize the attribute map of a session.long
getAttribute
(String name) long
long
long
getId()
getKeys()
long
long
long
getVhost()
boolean
isDirty()
boolean
isExpiredAt
(long time) boolean
void
putAllAttributes
(Map<String, Object> attributes) static void
serializeAttributes
(SessionData data, ObjectOutputStream out) Serialize the attribute map of the session.void
setAccessed
(long accessed) setAttribute
(String name, Object value) void
setContextPath
(String contextPath) void
setCookieSet
(long cookieSet) void
setCreated
(long created) void
setDirty
(boolean dirty) void
void
setExpiry
(long expiry) void
void
setLastAccessed
(long lastAccessed) void
setLastNode
(String lastNode) void
setLastSaved
(long lastSaved) void
setMaxInactiveMs
(long maxInactive) void
setMetaDataDirty
(boolean metaDataDirty) void
toString()
-
Field Details
-
_id
-
_contextPath
-
_vhost
-
_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
-
_dirty
protected boolean _dirty -
_lastSaved
protected long _lastSaved -
_metaDataDirty
protected boolean _metaDataDirty
-
-
Constructor Details
-
SessionData
-
SessionData
-
-
Method Details
-
serializeAttributes
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:
IOException
ClassNotFoundException
-
copy
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
-
isMetaDataDirty
public boolean isMetaDataDirty()- Returns:
- the metaDataDirty
-
setMetaDataDirty
public void setMetaDataDirty(boolean metaDataDirty) - Parameters:
metaDataDirty
- true means non-attribute data has changed
-
getAttribute
- Parameters:
name
- the name of the attribute- Returns:
- the value of the attribute named
-
getKeys
- Returns:
- a Set of attribute names
-
setAttribute
-
clean
public void clean()Clear all dirty flags. -
putAllAttributes
-
clearAllAttributes
public void clearAllAttributes()Remove all attributes -
getAllAttributes
- Returns:
- an unmodifiable map of the attributes
-
getId
- Returns:
- the id of the session
-
setId
-
getContextPath
- Returns:
- the context path associated with this session
-
setContextPath
-
getVhost
- Returns:
- virtual host of context associated with session
-
setVhost
-
getLastNode
- Returns:
- last node to manage the session
-
setLastNode
-
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
-