Package io.jmix.core.impl.session
Class ThreadLocalSessionData
java.lang.Object
io.jmix.core.impl.session.ThreadLocalSessionData
Provides thread-local storage for session attributes. This utility class facilitates the transfer of HTTP session
data to newly spawned threads that do not inherently have access to the data of the original HTTP session.
Use this class when you need to perform operations in a new thread that require access to the session data from an HTTP request. This is particularly useful in asynchronous processing or when handling requests outside the main request processing thread.
Usage example:
Map<String, Object> sessionAttributes = ThreadLocalSessionData.extractHttpSessionAttributes(); ThreadLocalSessionData.setAttributes(sessionAttributes); // Now, session attributes can be accessed from the new thread using ThreadLocalSessionData.getAttribute(...)
Ensure that you clear the thread-local storage after use. Use clear()
method once the thread-local data is
no longer needed.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
clear()
Returns all attributes stored in HTTP session as a Map.static Object
getAttribute
(String name) static boolean
isSet()
static void
setAttribute
(String name, Object value) static void
setAttributes
(Map<String, Object> attributes)
-
Constructor Details
-
ThreadLocalSessionData
public ThreadLocalSessionData()
-
-
Method Details
-
extractHttpSessionAttributes
Returns all attributes stored in HTTP session as a Map. -
setAttributes
-
getAttribute
-
setAttribute
-
clear
public static void clear() -
isSet
public static boolean isSet()
-