类 SimpleTaskWorkManager
- java.lang.Object
- org.springframework.jca.work.SimpleTaskWorkManager
- 所有已实现的接口:
WorkManager
public class SimpleTaskWorkManager extends Object implements WorkManager
Simple JCA 1.5WorkManager
implementation that delegates to a SpringTaskExecutor
. Provides simple task execution including start timeouts, but without support for a JCA ExecutionContext (i.e. without support for imported transactions).Uses a
SyncTaskExecutor
fordoWork(javax.resource.spi.work.Work)
calls and aSimpleAsyncTaskExecutor
forstartWork(javax.resource.spi.work.Work)
andscheduleWork(javax.resource.spi.work.Work)
calls, by default. These default task executors can be overridden through configuration.NOTE: This WorkManager does not provide thread pooling by default! Specify a
ThreadPoolTaskExecutor
(or any other thread-pooling TaskExecutor) as "asyncTaskExecutor" in order to achieve actual thread pooling.This WorkManager automatically detects a specified
AsyncTaskExecutor
implementation and uses its extended timeout functionality where appropriate. JCA WorkListeners are fully supported in any case.- 从以下版本开始:
- 2.0.3
- 作者:
- Juergen Hoeller
- 另请参阅:
setSyncTaskExecutor(org.springframework.core.task.TaskExecutor)
,setAsyncTaskExecutor(org.springframework.core.task.AsyncTaskExecutor)
字段概要
从接口继承的字段 javax.resource.spi.work.WorkManager
IMMEDIATE, INDEFINITE, UNKNOWN
构造器概要
构造器 构造器 说明 SimpleTaskWorkManager()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
doWork(Work work)
void
doWork(Work work, long startTimeout, ExecutionContext executionContext, WorkListener workListener)
protected long
executeWork(TaskExecutor taskExecutor, Work work, long startTimeout, boolean blockUntilStarted, ExecutionContext executionContext, WorkListener workListener)
Execute the given Work on the specified TaskExecutor.void
scheduleWork(Work work)
void
scheduleWork(Work work, long startTimeout, ExecutionContext executionContext, WorkListener workListener)
void
setAsyncTaskExecutor(AsyncTaskExecutor asyncTaskExecutor)
Specify the TaskExecutor to use for asynchronous work execution (i.e.void
setSyncTaskExecutor(TaskExecutor syncTaskExecutor)
Specify the TaskExecutor to use for synchronous work execution (i.e.long
startWork(Work work)
long
startWork(Work work, long startTimeout, ExecutionContext executionContext, WorkListener workListener)
构造器详细资料
SimpleTaskWorkManager
public SimpleTaskWorkManager()
方法详细资料
setSyncTaskExecutor
public void setSyncTaskExecutor(TaskExecutor syncTaskExecutor)
Specify the TaskExecutor to use for synchronous work execution (i.e.doWork(javax.resource.spi.work.Work)
calls).Default is a
SyncTaskExecutor
.
setAsyncTaskExecutor
public void setAsyncTaskExecutor(AsyncTaskExecutor asyncTaskExecutor)
Specify the TaskExecutor to use for asynchronous work execution (i.e.startWork(javax.resource.spi.work.Work)
andscheduleWork(javax.resource.spi.work.Work)
calls).This will typically (but not necessarily) be an
AsyncTaskExecutor
implementation. Default is aSimpleAsyncTaskExecutor
.
doWork
public void doWork(Work work) throws WorkException
- 指定者:
doWork
在接口中WorkManager
- 抛出:
WorkException
doWork
public void doWork(Work work, long startTimeout, ExecutionContext executionContext, WorkListener workListener) throws WorkException
- 指定者:
doWork
在接口中WorkManager
- 抛出:
WorkException
startWork
public long startWork(Work work) throws WorkException
- 指定者:
startWork
在接口中WorkManager
- 抛出:
WorkException
startWork
public long startWork(Work work, long startTimeout, ExecutionContext executionContext, WorkListener workListener) throws WorkException
- 指定者:
startWork
在接口中WorkManager
- 抛出:
WorkException
scheduleWork
public void scheduleWork(Work work) throws WorkException
- 指定者:
scheduleWork
在接口中WorkManager
- 抛出:
WorkException
scheduleWork
public void scheduleWork(Work work, long startTimeout, ExecutionContext executionContext, WorkListener workListener) throws WorkException
- 指定者:
scheduleWork
在接口中WorkManager
- 抛出:
WorkException
executeWork
protected long executeWork(TaskExecutor taskExecutor, Work work, long startTimeout, boolean blockUntilStarted, ExecutionContext executionContext, WorkListener workListener) throws WorkException
Execute the given Work on the specified TaskExecutor.- 参数:
taskExecutor
- the TaskExecutor to usework
- the Work to executestartTimeout
- the time duration within which the Work is supposed to startblockUntilStarted
- whether to block until the Work has startedexecutionContext
- the JCA ExecutionContext for the given WorkworkListener
- the WorkListener to clal for the given Work- 返回:
- the time elapsed from Work acceptance until start of execution (or -1 if not applicable or not known)
- 抛出:
WorkException
- if the TaskExecutor did not accept the Work