spring-framework / org.springframework.scheduling.concurrent / DefaultManagedTaskExecutor

DefaultManagedTaskExecutor

open class DefaultManagedTaskExecutor : ConcurrentTaskExecutor, InitializingBean

JNDI-based variant of ConcurrentTaskExecutor, performing a default lookup for JSR-236's "java:comp/DefaultManagedExecutorService" in a Java EE 7 environment.

Note: This class is not strictly JSR-236 based; it can work with any regular java.util.concurrent.Executor that can be found in JNDI. The actual adapting to javax.enterprise.concurrent.ManagedExecutorService happens in the base class ConcurrentTaskExecutor itself.

Author
Juergen Hoeller

Since
4.0

Constructors

<init>

DefaultManagedTaskExecutor()

JNDI-based variant of ConcurrentTaskExecutor, performing a default lookup for JSR-236's "java:comp/DefaultManagedExecutorService" in a Java EE 7 environment.

Note: This class is not strictly JSR-236 based; it can work with any regular java.util.concurrent.Executor that can be found in JNDI. The actual adapting to javax.enterprise.concurrent.ManagedExecutorService happens in the base class ConcurrentTaskExecutor itself.

Functions

afterPropertiesSet

open fun afterPropertiesSet(): Unit

setJndiEnvironment

open fun setJndiEnvironment(jndiEnvironment: Properties): Unit

Set the JNDI environment to use for JNDI lookups.

setJndiName

open fun setJndiName(jndiName: String): Unit

Specify a JNDI name of the java.util.concurrent.Executor to delegate to, replacing the default JNDI name "java:comp/DefaultManagedExecutorService".

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".

setJndiTemplate

open fun setJndiTemplate(jndiTemplate: JndiTemplate): Unit

Set the JNDI template to use for JNDI lookups.

setResourceRef

open fun setResourceRef(resourceRef: Boolean): Unit

Set whether the lookup occurs in a Java EE container, i.e. if the prefix "java:comp/env/" needs to be added if the JNDI name doesn't already contain it. PersistenceAnnotationBeanPostProcessor's default is "true".

Inherited Functions

execute

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

getConcurrentExecutor

fun getConcurrentExecutor(): Executor

Return the java.util.concurrent.Executor that this adapter delegates to.

prefersShortLivedTasks

open fun prefersShortLivedTasks(): Boolean

This task executor prefers short-lived work units.

setConcurrentExecutor

fun setConcurrentExecutor(executor: Executor): Unit

Specify the java.util.concurrent.Executor to delegate to.

Autodetects a JSR-236 javax.enterprise.concurrent.ManagedExecutorService in order to expose javax.enterprise.concurrent.ManagedTask adapters for it.

setTaskDecorator

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.

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>