@ThingworxExtensionApiClass(since={6,6}, canInstantiate=true) public final class ThreadLocalContext extends java.lang.Object
The ThreadLocalContext
class contains all objects that are tied to a request. This includes but is not limited to the session
data, the authorized account that made the request, the transaction success state, events that have been queued for processing, and the
entity (if any) the current request is being made against.
Security contexts are managed in a stack-like manner. That is, the most recently set security context is returned by
ThreadLocalContext#getSecurityContext()
and clearing a
security context will move the previously set security context to the top.
SecurityContext
,
TransactionFactory
Constructor and Description |
---|
ThreadLocalContext() |
Modifier and Type | Method and Description |
---|---|
static void |
cleanupContext() |
static void |
clearQueuedEvents()
Removes all queued events (if any) for the current thread. |
static SecurityContext |
clearSecurityContext() |
static void |
dispatchQueuedEvents()
Dispatches the events queued for the current thread. |
static java.lang.String |
getClientIP() |
static java.lang.Object |
getMeContext()
|
static SecurityContext |
getSecurityContext()
|
static javax.servlet.http.HttpSession |
getSession() |
java.lang.String |
getSessionId() |
static java.lang.Boolean |
getTransactionSuccessStatus() |
static java.lang.Boolean |
isImportActive() |
static java.lang.Boolean |
isTraceActive() |
static void |
queueEvent(ThingworxEvent event)
Queues an event into the event queue for the current thread. |
static void |
setSecurityContext(SecurityContext value) |
static void |
setSession(javax.servlet.http.HttpSession value) |
static void |
setTransactionSuccess(boolean status) |
@ThingworxExtensionApiMethod(since={6,6}) public static SecurityContext getSecurityContext()
@ThingworxExtensionApiMethod(since={6,6}) public static void setSecurityContext(SecurityContext value)
@ThingworxExtensionApiMethod(since={6,6}) public static SecurityContext clearSecurityContext()
@ThingworxExtensionApiMethod(since={6,6}) public static java.lang.Boolean isTraceActive()
@ThingworxExtensionApiMethod(since={6,6}) public static java.lang.Object getMeContext()
@ThingworxExtensionApiMethod(since={6,6}) public static java.lang.Boolean isImportActive()
@ThingworxExtensionApiMethod(since={6,6}) public static void setSession(javax.servlet.http.HttpSession value)
@ThingworxExtensionApiMethod(since={6,6}) public static javax.servlet.http.HttpSession getSession()
@ThingworxExtensionApiMethod(since={6,6}) public java.lang.String getSessionId()
@ThingworxExtensionApiMethod(since={6,6}) public static java.lang.String getClientIP()
@ThingworxExtensionApiMethod(since={7,0,1}) public static void queueEvent(ThingworxEvent event)
dispatchQueuedEvents()
and clearQueuedEvents()
methods.event
- the event to add to the dispatch queue@ThingworxExtensionApiMethod(since={6,6}) public static void dispatchQueuedEvents() throws java.lang.Exception
java.lang.Exception
- if an exception occurred during event dispatch@ThingworxExtensionApiMethod(since={7,0,1}) public static void clearQueuedEvents()
@ThingworxExtensionApiMethod(since={6,6}) public static void setTransactionSuccess(boolean status)
@ThingworxExtensionApiMethod(since={6,6}) public static java.lang.Boolean getTransactionSuccessStatus()
@ThingworxExtensionApiMethod(since={6,6}) public static void cleanupContext()