Class ThreadLocalContext
- java.lang.Object
-
- com.thingworx.webservices.context.ThreadLocalContext
-
@ThingworxExtensionApiClass(since={6,6}, canInstantiate=true) public final class ThreadLocalContext extends java.lang.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:
SecurityContext
,TransactionFactory
-
-
Constructor Summary
Constructors Constructor Description ThreadLocalContext()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
cleanupContext()
static void
clearQueuedEvents()
Removes all queued events (if any) for the current thread.static void
clearQueuedPostCommitEvents()
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
queuePostCommitEvent(ThingworxEvent event)
static void
setSecurityContext(SecurityContext value)
static void
setSession(javax.servlet.http.HttpSession value)
static void
setTransactionSuccess(boolean status)
-
-
-
Method Detail
-
getSecurityContext
@ThingworxExtensionApiMethod(since={6,6}) public static SecurityContext getSecurityContext()
- Returns:
- The security context.
-
setSecurityContext
@ThingworxExtensionApiMethod(since={6,6}) public static void setSecurityContext(SecurityContext value)
-
clearSecurityContext
@ThingworxExtensionApiMethod(since={6,6}) public static SecurityContext clearSecurityContext()
-
isTraceActive
@ThingworxExtensionApiMethod(since={6,6}) public static java.lang.Boolean isTraceActive()
-
getMeContext
@ThingworxExtensionApiMethod(since={6,6}) public static java.lang.Object getMeContext()
- Returns:
-
isImportActive
@ThingworxExtensionApiMethod(since={6,6}) public static java.lang.Boolean isImportActive()
-
setSession
@ThingworxExtensionApiMethod(since={6,6}) public static void setSession(javax.servlet.http.HttpSession value)
-
getSession
@ThingworxExtensionApiMethod(since={6,6}) public static javax.servlet.http.HttpSession getSession()
-
getSessionId
@ThingworxExtensionApiMethod(since={6,6}) public java.lang.String getSessionId()
-
getClientIP
@ThingworxExtensionApiMethod(since={6,6}) public static java.lang.String getClientIP()
-
queueEvent
@ThingworxExtensionApiMethod(since={7,0,1}) public static void queueEvent(ThingworxEvent event)
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 java.lang.Exception
Dispatches the events queued for the current thread. The event queue will be empty after this method completes.- Throws:
java.lang.Exception
- if an exception occurred during event dispatch
-
clearQueuedEvents
@ThingworxExtensionApiMethod(since={7,0,1}) public static void clearQueuedEvents()
Removes all queued events (if any) for the current thread. The events are not dispatched.
-
clearQueuedPostCommitEvents
@ThingworxExtensionApiMethod(since={9,0}) public static void clearQueuedPostCommitEvents()
-
setTransactionSuccess
@ThingworxExtensionApiMethod(since={6,6}) public static void setTransactionSuccess(boolean status)
-
getTransactionSuccessStatus
@ThingworxExtensionApiMethod(since={6,6}) public static java.lang.Boolean getTransactionSuccessStatus()
-
cleanupContext
@ThingworxExtensionApiMethod(since={6,6}) public static void cleanupContext()
-
-