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

WorkManagerTaskExecutor

open class WorkManagerTaskExecutor : JndiLocatorSupport, AsyncListenableTaskExecutor, SchedulingTaskExecutor, WorkManager, BootstrapContextAware, InitializingBean

org.springframework.core.task.TaskExecutor implementation that delegates to a JCA 1.7 WorkManager, implementing the javax.resource.spi.work.WorkManager interface.

This is mainly intended for use within a JCA ResourceAdapter implementation, but may also be used in a standalone environment, delegating to a locally embedded WorkManager implementation (such as Geronimo's).

Also implements the JCA 1.7 WorkManager interface itself, delegating all calls to the target WorkManager. Hence, a caller can choose whether it wants to talk to this executor through the Spring TaskExecutor interface or the WorkManager interface.

This adapter is also capable of obtaining a JCA WorkManager from JNDI. This is for example appropriate on the Geronimo application server, where WorkManager GBeans (e.g. Geronimo's default "DefaultWorkManager" GBean) can be linked into the Java EE environment through "gbean-ref" entries in the geronimo-web.xml deployment descriptor.

Author
Juergen Hoeller

Since
2.0.3

See Also
#setWorkManagerjavax.resource.spi.work.WorkManager#scheduleWork

Constructors

<init>

WorkManagerTaskExecutor()

Create a new WorkManagerTaskExecutor, expecting bean-style configuration.

WorkManagerTaskExecutor(workManager: WorkManager)

Create a new WorkManagerTaskExecutor for the given WorkManager.

Functions

afterPropertiesSet

open fun afterPropertiesSet(): Unit

doWork

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

execute

open fun execute(task: Runnable): Unit
open fun execute(task: Runnable, startTimeout: Long): Unit

prefersShortLivedTasks

open fun prefersShortLivedTasks(): Boolean

This task executor prefers short-lived work units.

scheduleWork

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

setBlockUntilCompleted

open fun setBlockUntilCompleted(blockUntilCompleted: Boolean): Unit

Set whether to let #execute block until the work has been completed.

Uses the JCA doWork operation underneath, instead of the default scheduleWork.

setBlockUntilStarted

open fun setBlockUntilStarted(blockUntilStarted: Boolean): Unit

Set whether to let #execute block until the work has been actually started.

Uses the JCA startWork operation underneath, instead of the default scheduleWork.

setBootstrapContext

open fun setBootstrapContext(bootstrapContext: BootstrapContext): Unit

Specify the JCA BootstrapContext that contains the WorkManager to delegate to.

setTaskDecorator

open fun setTaskDecorator(taskDecorator: TaskDecorator): Unit

Specify a custom TaskDecorator to be applied to any Runnable about to be executed.

Note that such a decorator is not necessarily being applied to the user-supplied Runnable/Callable but rather to the actual execution callback (which may be a wrapper around the user-supplied task).

The primary use case is to set some execution context around the task's invocation, or to provide some monitoring/statistics for task execution.

setWorkListener

open fun setWorkListener(workListener: WorkListener): Unit

Specify a JCA WorkListener to apply, if any.

This shared WorkListener instance will be passed on to the WorkManager by all #execute calls on this TaskExecutor.

setWorkManager

open fun setWorkManager(workManager: WorkManager): Unit

Specify the JCA WorkManager instance to delegate to.

setWorkManagerName

open fun setWorkManagerName(workManagerName: String): Unit

Set the JNDI name of the JCA WorkManager.

This can either be a fully qualified JNDI name, or the JNDI name relative to the current environment naming context if "resourceRef" is set to "true".

startWork

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

submit

open fun submit(task: Runnable): Future<*>
open fun <T : Any> submit(task: Callable<T>): Future<T>

submitListenable

open fun submitListenable(task: Runnable): ListenableFuture<*>
open fun <T : Any> submitListenable(task: Callable<T>): ListenableFuture<T>