Class QContext
java.lang.Object
com.kingsrook.qqq.backend.core.context.QContext
A collection of thread-local variables, to define the current context of the
QQQ code that is running. e.g., what QInstance is being used, what QSession
is active, etc.
-
Method Summary
Modifier and TypeMethodDescriptionstatic CapturedContext
capture()
Capture all values from the current thread - meant to be used with the init overload that takes a CapturedContext, for setting up a child thread.static void
clear()
Clear all values in the current thread.static void
static Stack
<AbstractActionInput> static Optional
<AbstractActionInput> static Serializable
get one named object from the Context for the current thread.static <T extends Serializable>
Optional<T> get one named object from the Context for the current thread, cast to the specified type if possible.static Map
<String, Serializable> get the full map of named objects for the current thread (possibly null).static QBackendTransaction
static QInstance
static QSession
static void
init
(CapturedContext capturedContext) Init a new thread with the context captured from a different thread.static void
Most common method to set or init the context - e.g., set the current thread with a QInstance and QSession.static void
init
(QInstance qInstance, QSession qSession, QBackendTransaction transaction, AbstractActionInput actionInput) Full flavor init method - also take a transaction and action input (to seed the stack).static void
static void
pushAction
(AbstractActionInput action) static void
removeObject
(String key) remove a named object from the Context of the current thread.static void
setObject
(String key, Serializable object) put a named object into the Context for the current thread.static void
setObjects
(Map<String, Serializable> objects) fully replace the map of named objets for the current thread.static void
setQInstance
(QInstance qInstance) static void
setQSession
(QSession qSession) static void
setTransaction
(QBackendTransaction transaction) static <T extends Throwable>
voidwithTemporaryContext
(CapturedContext context, UnsafeVoidVoidMethod<T> method)
-
Method Details
-
init
-
init
public static void init(QInstance qInstance, QSession qSession, QBackendTransaction transaction, AbstractActionInput actionInput) Full flavor init method - also take a transaction and action input (to seed the stack). -
withTemporaryContext
public static <T extends Throwable> void withTemporaryContext(CapturedContext context, UnsafeVoidVoidMethod<T> method) throws T - Throws:
T
-
init
Init a new thread with the context captured from a different thread. e.g., when starting some async task. -
capture
Capture all values from the current thread - meant to be used with the init overload that takes a CapturedContext, for setting up a child thread. -
clear
public static void clear()Clear all values in the current thread. -
getQInstance
-
getQSession
-
getQBackendTransaction
-
getActionStack
-
pushAction
-
popAction
public static void popAction() -
setQInstance
-
setQSession
-
setTransaction
-
clearTransaction
public static void clearTransaction() -
getFirstActionInStack
-
getObject
get one named object from the Context for the current thread. may return null. -
getObject
get one named object from the Context for the current thread, cast to the specified type if possible. if not found, or wrong type, empty is returned. -
setObject
put a named object into the Context for the current thread. -
removeObject
remove a named object from the Context of the current thread. -
getObjects
get the full map of named objects for the current thread (possibly null). -
setObjects
fully replace the map of named objets for the current thread.
-