Package org.infinispan.tasks
Interface ServerTask<V>
- All Superinterfaces:
Callable<V>
,JsonSerialization
,Task
An interface representing a deployed server task.
The task will be accessible by the name returned by
Task.getName()
Before the execution, TaskContext
is injected into the task to provide
EmbeddedCacheManager
, Cache
,
Marshaller
and parameters.- Author:
- Michal Szynkiewicz <michal.l.szynkiewicz@gmail.com>
-
Method Summary
Modifier and TypeMethodDescriptiondefault String
getType()
Returns the type of task.void
setTaskContext
(TaskContext taskContext) Sets the task context Store the value in your task implementation to be able to access caches and other resources in the task Note that, ifTask.getInstantiationMode()
isTaskInstantiationMode.SHARED
there will be single instance of each ServerTask on each server so, if you expect concurrent invocations of a task, theTaskContext
should be stored in aThreadLocal
static field in your task.Methods inherited from interface org.infinispan.tasks.Task
getAllowedRole, getExecutionMode, getInstantiationMode, getName, getParameters, toJson
-
Method Details
-
setTaskContext
Sets the task context Store the value in your task implementation to be able to access caches and other resources in the task Note that, ifTask.getInstantiationMode()
isTaskInstantiationMode.SHARED
there will be single instance of each ServerTask on each server so, if you expect concurrent invocations of a task, theTaskContext
should be stored in aThreadLocal
static field in your task. The TaskContext should then be obtained during the task'sCallable.call()
method and removed from the ThreadLocal. Alternatively useTaskInstantiationMode.ISOLATED
.- Parameters:
taskContext
- task execution context
-
getType
Description copied from interface:Task
Returns the type of task. This is dependent on the specific implementation.
-