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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidcalcAndSetExpiry(long time) longlongcalcExpiry(long time) voidclean()Clear all dirty flags.voidRemove all attributesvoidcopy(SessionData data) Copy the info from the given sessiondatastatic voidDe-serialize the attribute map of a session.longgetAttribute(String name) longlonglonggetId()getKeys()longlonglonggetVhost()booleanisDirty()booleanisExpiredAt(long time) booleanvoidputAllAttributes(Map<String, Object> attributes) static voidserializeAttributes(SessionData data, ObjectOutputStream out) Serialize the attribute map of the session.voidsetAccessed(long accessed) setAttribute(String name, Object value) voidsetContextPath(String contextPath) voidsetCookieSet(long cookieSet) voidsetCreated(long created) voidsetDirty(boolean dirty) voidvoidsetExpiry(long expiry) voidvoidsetLastAccessed(long lastAccessed) voidsetLastNode(String lastNode) voidsetLastSaved(long lastSaved) voidsetMaxInactiveMs(long maxInactive) voidsetMetaDataDirty(boolean metaDataDirty) voidtoString()
-
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:
IOExceptionClassNotFoundException
-
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
-