Class SessionData
java.lang.Object
com.aspectran.core.component.session.SessionData
- All Implemented Interfaces:
Serializable
The data associated with a session.
Created: 2017. 6. 6.
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
SessionData
(String id, long created, long inactiveInterval) protected
SessionData
(String id, long created, long accessed, long lastAccessed, long inactiveInterval) -
Method Summary
Modifier and TypeMethodDescriptionvoid
calcAndSetExpiry
(long time) protected long
calcExpiry
(long time) void
Removes all attributes.static SessionData
deserialize
(InputStream inputStream) Load session data from an input stream that contains session data.long
Returns an unmodifiable map of the attributes.<T> T
getAttribute
(String name) long
long
protected long
getId()
long
getKeys()
long
long
boolean
isDirty()
boolean
isExpiredAt
(long time) void
putAllAttributes
(Map<String, Object> attributes) Copies all of the mappings from the specified attributes.void
reduceInactiveInterval
(long inactiveInterval) <T> T
removeAttribute
(String name) boolean
static void
serialize
(SessionData data, OutputStream outputStream, Set<String> nonPersistentAttributes) Save the session data.void
setAccessed
(long accessed) <T> T
setAttribute
(String name, Object value) void
setDirty
(boolean dirty) protected void
setExtraInactiveInterval
(long extraInactiveInterval) void
void
setInactiveInterval
(long inactiveInterval) void
setLastAccessed
(long lastAccessed) void
setLastSaved
(long lastSaved) toString()
-
Constructor Details
-
SessionData
-
SessionData
protected SessionData(String id, long created, long accessed, long lastAccessed, long inactiveInterval)
-
-
Method Details
-
getId
-
setId
-
getCreated
public long getCreated() -
getAccessed
public long getAccessed() -
setAccessed
public void setAccessed(long accessed) -
getLastAccessed
public long getLastAccessed() -
setLastAccessed
public void setLastAccessed(long lastAccessed) -
getInactiveInterval
public long getInactiveInterval() -
setInactiveInterval
public void setInactiveInterval(long inactiveInterval) -
getExtraInactiveInterval
protected long getExtraInactiveInterval() -
setExtraInactiveInterval
protected void setExtraInactiveInterval(long extraInactiveInterval) -
reduceInactiveInterval
public void reduceInactiveInterval(long inactiveInterval) -
restoreInactiveInterval
public boolean restoreInactiveInterval() -
getExpiry
public long getExpiry() -
calcExpiry
protected long calcExpiry(long time) -
calcAndSetExpiry
public void calcAndSetExpiry(long time) -
isExpiredAt
public boolean isExpiredAt(long time) -
isDirty
public boolean isDirty()- Returns:
- true if a session needs to be written out
-
setDirty
public void setDirty(boolean dirty) -
getLastSaved
public long getLastSaved() -
setLastSaved
public void setLastSaved(long lastSaved) -
getAttribute
-
setAttribute
-
removeAttribute
-
getKeys
- Returns:
- a Set of attribute names
-
getAllAttributes
Returns an unmodifiable map of the attributes.- Returns:
- an unmodifiable map of the attributes
-
putAllAttributes
Copies all of the mappings from the specified attributes.- Parameters:
attributes
- the specified attributes
-
clearAllAttributes
public void clearAllAttributes()Removes all attributes. -
toString
-
serialize
public static void serialize(@NonNull SessionData data, OutputStream outputStream, Set<String> nonPersistentAttributes) throws IOException Save the session data.- Parameters:
outputStream
- the output stream to save tononPersistentAttributes
- the attribute names to be excluded from serialization- Throws:
IOException
- if an I/O error has occurred
-
deserialize
Load session data from an input stream that contains session data.- Parameters:
inputStream
- the input stream containing session data- Returns:
- the session data
- Throws:
Exception
- if the session data could not be read from the file
-