public class

SimpleThreadPoolTaskExecutor

extends SimpleThreadPool
implements DisposableBean InitializingBean SchedulingTaskExecutor
java.lang.Object
   ↳ SimpleThreadPool
     ↳ org.springframework.scheduling.quartz.SimpleThreadPoolTaskExecutor

Class Overview

Subclass of Quartz's SimpleThreadPool that implements Spring's TaskExecutor interface and listens to Spring lifecycle callbacks.

Can be shared between a Quartz Scheduler (specified as "taskExecutor") and other TaskExecutor users, or even used completely independent of a Quartz Scheduler (as plain TaskExecutor backend).

See Also

Summary

[Expand]
Inherited Constants
From interface org.springframework.core.task.AsyncTaskExecutor
Public Constructors
SimpleThreadPoolTaskExecutor()
Public Methods
void afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
void destroy()
Invoked by a BeanFactory on destruction of a singleton.
void execute(Runnable task, long startTimeout)
Execute the given task.
void execute(Runnable task)
Execute the given task.
boolean prefersShortLivedTasks()
This task executor prefers short-lived work units.
void setWaitForJobsToCompleteOnShutdown(boolean waitForJobsToCompleteOnShutdown)
Set whether to wait for running jobs to complete on shutdown.
<T> Future<T> submit(Callable<T> task)
Submit a Callable task for execution, receiving a Future representing that task.
Future<?> submit(Runnable task)
Submit a Runnable task for execution, receiving a Future representing that task.
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.util.concurrent.Executor
From interface org.springframework.beans.factory.DisposableBean
From interface org.springframework.beans.factory.InitializingBean
From interface org.springframework.core.task.AsyncTaskExecutor
From interface org.springframework.core.task.TaskExecutor
From interface org.springframework.scheduling.SchedulingTaskExecutor

Public Constructors

public SimpleThreadPoolTaskExecutor ()

Public Methods

public void afterPropertiesSet ()

Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).

This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.

Throws
SchedulerConfigException

public void destroy ()

Invoked by a BeanFactory on destruction of a singleton.

public void execute (Runnable task, long startTimeout)

Execute the given task.

Parameters
task the Runnable to execute (never null)
startTimeout the time duration (milliseconds) within which the task is supposed to start. This is intended as a hint to the executor, allowing for preferred handling of immediate tasks. Typical values are TIMEOUT_IMMEDIATE or TIMEOUT_INDEFINITE (the default as used by execute(Runnable)).

public void execute (Runnable task)

Execute the given task.

The call might return immediately if the implementation uses an asynchronous execution strategy, or might block in the case of synchronous execution.

Parameters
task the Runnable to execute (never null)

public boolean prefersShortLivedTasks ()

This task executor prefers short-lived work units.

Returns
  • true if this TaskExecutor prefers short-lived tasks

public void setWaitForJobsToCompleteOnShutdown (boolean waitForJobsToCompleteOnShutdown)

Set whether to wait for running jobs to complete on shutdown. Default is "false".

See Also
  • org.quartz.simpl.SimpleThreadPool#shutdown(boolean)

public Future<T> submit (Callable<T> task)

Submit a Callable task for execution, receiving a Future representing that task. The Future will return the Callable's result upon completion.

Parameters
task the Callable to execute (never null)
Returns
  • a Future representing pending completion of the task

public Future<?> submit (Runnable task)

Submit a Runnable task for execution, receiving a Future representing that task. The Future will return a null result upon completion.

Parameters
task the Runnable to execute (never null)
Returns
  • a Future representing pending completion of the task