public class

SimpleTaskWorkManager

extends Object
java.lang.Object
   ↳ org.springframework.jca.work.SimpleTaskWorkManager

Class Overview

Simple JCA 1.5 javax.resource.spi.work.WorkManager implementation that delegates to a Spring TaskExecutor. Provides simple task execution including start timeouts, but without support for a JCA ExecutionContext (i.e. without support for imported transactions).

Uses a SyncTaskExecutor for doWork(Work) calls and a SimpleAsyncTaskExecutor for startWork(Work) and scheduleWork(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.

Summary

Public Constructors
SimpleTaskWorkManager()
Public Methods
void doWork(Work work, long startTimeout, ExecutionContext executionContext, WorkListener workListener)
void doWork(Work work)
void scheduleWork(Work work, long startTimeout, ExecutionContext executionContext, WorkListener workListener)
void scheduleWork(Work work)
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)
Protected Methods
long executeWork(TaskExecutor taskExecutor, Work work, long startTimeout, boolean blockUntilStarted, ExecutionContext executionContext, WorkListener workListener)
Execute the given Work on the specified TaskExecutor.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public SimpleTaskWorkManager ()

Public Methods

public void doWork (Work work, long startTimeout, ExecutionContext executionContext, WorkListener workListener)

Throws
WorkException

public void doWork (Work work)

Throws
WorkException

public void scheduleWork (Work work, long startTimeout, ExecutionContext executionContext, WorkListener workListener)

Throws
WorkException

public void scheduleWork (Work work)

Throws
WorkException

public void setAsyncTaskExecutor (AsyncTaskExecutor asyncTaskExecutor)

Specify the TaskExecutor to use for asynchronous work execution (i.e. startWork(Work) and scheduleWork(Work) calls).

This will typically (but not necessarily) be an AsyncTaskExecutor implementation. Default is a SimpleAsyncTaskExecutor.

public void setSyncTaskExecutor (TaskExecutor syncTaskExecutor)

Specify the TaskExecutor to use for synchronous work execution (i.e. doWork(Work) calls).

Default is a SyncTaskExecutor.

public long startWork (Work work)

Throws
WorkException

public long startWork (Work work, long startTimeout, ExecutionContext executionContext, WorkListener workListener)

Throws
WorkException

Protected Methods

protected long executeWork (TaskExecutor taskExecutor, Work work, long startTimeout, boolean blockUntilStarted, ExecutionContext executionContext, WorkListener workListener)

Execute the given Work on the specified TaskExecutor.

Parameters
taskExecutor the TaskExecutor to use
work the Work to execute
startTimeout the time duration within which the Work is supposed to start
blockUntilStarted whether to block until the Work has started
executionContext the JCA ExecutionContext for the given Work
workListener the WorkListener to clal for the given Work
Returns
  • the time elapsed from Work acceptance until start of execution (or -1 if not applicable or not known)
Throws
if the TaskExecutor did not accept the Work
WorkException