Package com.aispect.common.context
Class AiSpectContextHolder
java.lang.Object
com.aispect.common.context.AiSpectContextHolder
based on ThreadLocal A context holder for passing implicit parameters throughout the framework chain.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidclear()Clean up the context of the current thread. must be in finally block to prevent memory leaks when using the thread pool.static ObjectGets the value from the current context.Get the entire context mapping dictionary.static voidSets a key-value pair in the current context.static voidsetContext(Map<String, Object> map) Override the entire context mapping dictionary.
-
Method Details
-
set
Sets a key-value pair in the current context.- Parameters:
key- keyvalue- value
-
get
Gets the value from the current context.- Parameters:
key- key- Returns:
- The corresponding value, returned if not found null
-
getContext
Get the entire context mapping dictionary.- Returns:
- context mapping
-
setContext
Override the entire context mapping dictionary.- Parameters:
map- new context mapping
-
clear
public static void clear()Clean up the context of the current thread. must be in finally block to prevent memory leaks when using the thread pool.
-