spring-framework / org.springframework.scheduling.commonj / WorkManagerTaskExecutor

WorkManagerTaskExecutor

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

TaskExecutor implementation that delegates to a CommonJ WorkManager, implementing the commonj.work.WorkManager interface, which either needs to be specified as reference or through the JNDI name.

This is the central convenience class for setting up a CommonJ WorkManager in a Spring context.

Also implements the CommonJ 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 CommonJ WorkManager interface.

The CommonJ WorkManager will usually be retrieved from the application server's JNDI environment, as defined in the server's management console.

Note: On the upcoming EE 7 compliant versions of WebLogic and WebSphere, a org.springframework.scheduling.concurrent.DefaultManagedTaskExecutor should be preferred, following JSR-236 support in Java EE 7.

Author
Juergen Hoeller

Since
2.0

Constructors

<init>

WorkManagerTaskExecutor()

TaskExecutor implementation that delegates to a CommonJ WorkManager, implementing the commonj.work.WorkManager interface, which either needs to be specified as reference or through the JNDI name.

This is the central convenience class for setting up a CommonJ WorkManager in a Spring context.

Also implements the CommonJ 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 CommonJ WorkManager interface.

The CommonJ WorkManager will usually be retrieved from the application server's JNDI environment, as defined in the server's management console.

Note: On the upcoming EE 7 compliant versions of WebLogic and WebSphere, a org.springframework.scheduling.concurrent.DefaultManagedTaskExecutor should be preferred, following JSR-236 support in Java EE 7.

Functions

afterPropertiesSet

open fun afterPropertiesSet(): 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.

schedule

open fun schedule(work: Work): WorkItem
open fun schedule(work: Work, workListener: WorkListener): WorkItem

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 CommonJ 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 CommonJ WorkManager to delegate to.

Alternatively, you can also specify the JNDI name of the target WorkManager.

setWorkManagerName

open fun setWorkManagerName(workManagerName: String): Unit

Set the JNDI name of the CommonJ 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".

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>

waitForAll

open fun waitForAll(workItems: MutableCollection<Any?>, timeout: Long): Boolean

waitForAny

open fun waitForAny(workItems: MutableCollection<Any?>, timeout: Long): MutableCollection<Any?>