spring-framework / org.springframework.jca.work / SimpleTaskWorkManager

SimpleTaskWorkManager

open class SimpleTaskWorkManager : WorkManager

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

Uses a org.springframework.core.task.SyncTaskExecutor for #doWork calls and a org.springframework.core.task.SimpleAsyncTaskExecutor for #startWork and #scheduleWork calls, by default. These default task executors can be overridden through configuration.

NOTE: This WorkManager does not provide thread pooling by default! Specify a org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor (or any other thread-pooling TaskExecutor) as "asyncTaskExecutor" in order to achieve actual thread pooling.

This WorkManager automatically detects a specified org.springframework.core.task.AsyncTaskExecutor implementation and uses its extended timeout functionality where appropriate. JCA WorkListeners are fully supported in any case.

Author
Juergen Hoeller

Since
2.0.3

See Also
#setSyncTaskExecutor#setAsyncTaskExecutor

Constructors

<init>

SimpleTaskWorkManager()

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

Uses a org.springframework.core.task.SyncTaskExecutor for #doWork calls and a org.springframework.core.task.SimpleAsyncTaskExecutor for #startWork and #scheduleWork calls, by default. These default task executors can be overridden through configuration.

NOTE: This WorkManager does not provide thread pooling by default! Specify a org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor (or any other thread-pooling TaskExecutor) as "asyncTaskExecutor" in order to achieve actual thread pooling.

This WorkManager automatically detects a specified org.springframework.core.task.AsyncTaskExecutor implementation and uses its extended timeout functionality where appropriate. JCA WorkListeners are fully supported in any case.

Functions

doWork

open fun doWork(work: Work): Unit
open fun doWork(work: Work, startTimeout: Long, executionContext: ExecutionContext, workListener: WorkListener): Unit

scheduleWork

open fun scheduleWork(work: Work): Unit
open fun scheduleWork(work: Work, startTimeout: Long, executionContext: ExecutionContext, workListener: WorkListener): Unit

setAsyncTaskExecutor

open fun setAsyncTaskExecutor(asyncTaskExecutor: AsyncTaskExecutor): Unit

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

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

setSyncTaskExecutor

open fun setSyncTaskExecutor(syncTaskExecutor: TaskExecutor): Unit

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

Default is a org.springframework.core.task.SyncTaskExecutor.

startWork

open fun startWork(work: Work): Long
open fun startWork(work: Work, startTimeout: Long, executionContext: ExecutionContext, workListener: WorkListener): Long