Package org.apache.maven.api
Interface SessionData
A container for data that is specific to a session.
All components may use this storage to associate arbitrary data with a session.
Unlike a cache, this session data is not subject to purging. For this same reason, session data should also not be abused as a cache (i.e. for storing values that can be re-calculated) to avoid memory exhaustion.
Note: Actual implementations must be thread-safe.
- Since:
- 4.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptioncomputeIfAbsent(Object key, Supplier<Object> supplier) Retrieve of compute the data associated with the specified key.Gets the session data associated with the specified key.voidAssociates the specified session data with the given key.booleanAssociates the specified session data with the given key if the key is currently mapped to the given value.
-
Method Details
-
set
Associates the specified session data with the given key.- Parameters:
key- the key under which to store the session data, must not benullvalue- the data to associate with the key, may benullto remove the mapping
-
set
Associates the specified session data with the given key if the key is currently mapped to the given value. This method provides an atomic compare-and-update of some key's value.- Parameters:
key- the key under which to store the session data, must not benulloldValue- the expected data currently associated with the key, may benullnewValue- the data to associate with the key, may benullto remove the mapping- Returns:
trueif the key mapping was successfully updated from the old value to the new value,falseif the current key mapping didn't match the expected value and was not updated.
-
get
Gets the session data associated with the specified key.- Parameters:
key- the key for which to retrieve the session data, must not benull- Returns:
- the session data associated with the key or
nullif none
-
computeIfAbsent
Retrieve of compute the data associated with the specified key.- Parameters:
key- the key for which to retrieve the session data, must not benullsupplier- the supplier will compute the new value- Returns:
- the session data associated with the key
-