Class ThreadLocalContext
java.lang.Object
com.thingworx.webservices.context.ThreadLocalContext
@ThingworxExtensionApiClass(since={6,6},
canInstantiate=true)
public final class ThreadLocalContext
extends Object
A container for all session-managed objects.
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.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
static void
Removes all queued events (if any) for the current thread.static void
static SecurityContext
static void
Dispatches the events queued for the current thread.static String
static Object
static SecurityContext
static javax.servlet.http.HttpSession
static Boolean
static Boolean
static Boolean
static void
queueEvent
(ThingworxEvent event)
Queues an event into the event queue for the current thread.static void
static void
static void
setSession
(javax.servlet.http.HttpSession value) static void
setTransactionSuccess
(boolean status)
-
Constructor Details
-
ThreadLocalContext
public ThreadLocalContext()
-
-
Method Details
-
getSecurityContext
- Returns:
- The security context.
-
setSecurityContext
@ThingworxExtensionApiMethod(since={6,6}) public static void setSecurityContext(SecurityContext value) -
clearSecurityContext
-
isTraceActive
-
getMeContext
- Returns:
-
isImportActive
-
setSession
@ThingworxExtensionApiMethod(since={6,6}) public static void setSession(javax.servlet.http.HttpSession value) -
getSession
-
getSessionId
-
getClientIP
-
queueEvent
Queues an event into the event queue for the current thread. This can be used to support transactional event dispatch along with thedispatchQueuedEvents()
andclearQueuedEvents()
methods.- Parameters:
event
- the event to add to the dispatch queue
-
queuePostCommitEvent
@ThingworxExtensionApiMethod(since={9,0}) public static void queuePostCommitEvent(ThingworxEvent event) -
dispatchQueuedEvents
@ThingworxExtensionApiMethod(since={6,6}) public static void dispatchQueuedEvents() throws Exception
Dispatches the events queued for the current thread. The event queue will be empty after this method completes.- Throws:
Exception
- if an exception occurred during event dispatch
-
clearQueuedEvents
Removes all queued events (if any) for the current thread. The events are not dispatched. -
clearQueuedPostCommitEvents
-
setTransactionSuccess
-
getTransactionSuccessStatus
-
cleanupContext
-