Class SharedTaskContextHolder
- java.lang.Object
- 
- org.hawaiiframework.async.timeout.SharedTaskContextHolder
 
- 
 public final class SharedTaskContextHolder extends Object Is used by the guarded task to register it's task abort command (if applicable).- Since:
- 2.0.0
- Author:
- Rutger Lubbers, Paul Klos
 
- 
- 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static SharedTaskContextget()Getter for #sharedTaskAbortStrategy.static StringgetTaskId()Return the task id for the current thread's task.static voidregister(SharedTaskContext sharedTaskContext)Initialize theSharedTaskContextHolderwith thesharedTaskContext.static voidremove()Removes the currentSharedTaskContextfrom the ThreadLocal store.static voidsetTaskAbortStrategy(TaskAbortStrategy taskAbortStrategy)Set the current thread'staskAbortStrategy.
 
- 
- 
- 
Method Detail- 
registerpublic static void register(SharedTaskContext sharedTaskContext) Initialize theSharedTaskContextHolderwith thesharedTaskContext.By registering the sharedTaskContextthe strategy is made available for other code within the executing thread. This allows the guard task to abort the task being executed without knowing how.The task itself is responsible to register a TaskAbortStrategyin thesharedTaskContext. This can be done by calling thesetTaskAbortStrategy(TaskAbortStrategy).As an example, see the HawaiiHttpComponentsClientHttpRequestFactory.- Parameters:
- sharedTaskContext- the shared strategy to hold for the current thread.
 
 - 
removepublic static void remove() Removes the currentSharedTaskContextfrom the ThreadLocal store.
 - 
setTaskAbortStrategypublic static void setTaskAbortStrategy(TaskAbortStrategy taskAbortStrategy) Set the current thread'staskAbortStrategy.This sets the taskAbortStrategyinto the thread'sSharedTaskContext.- Parameters:
- taskAbortStrategy- The strategy to set.
 
 - 
getpublic static SharedTaskContext get() Getter for #sharedTaskAbortStrategy.- Returns:
- the shared task abort strategy
 
 - 
getTaskIdpublic static String getTaskId() Return the task id for the current thread's task. It delegates to the thread localSharedTaskContext.getTaskId().- Returns:
- The task's id.
 
 
- 
 
-