public abstract class

ExecutorConfigurationSupport

extends CustomizableThreadFactory
implements BeanNameAware DisposableBean InitializingBean
java.lang.Object
   ↳ org.springframework.util.CustomizableThreadCreator
     ↳ org.springframework.scheduling.concurrent.CustomizableThreadFactory
       ↳ org.springframework.scheduling.concurrent.ExecutorConfigurationSupport
Known Direct Subclasses

Class Overview

Base class for classes that are setting up a java.util.concurrent.ExecutorService (typically a java.util.concurrent.ThreadPoolExecutor). Defines common configuration settings and common lifecycle handling.

See Also

Summary

Fields
protected final Log logger
Public Constructors
ExecutorConfigurationSupport()
Public Methods
void afterPropertiesSet()
Calls initialize() after the container applied all property values.
void destroy()
Calls shutdown when the BeanFactory destroys the task executor instance.
void initialize()
Set up the ExecutorService.
void setBeanName(String name)
Set the name of the bean in the bean factory that created this bean.
void setRejectedExecutionHandler(RejectedExecutionHandler rejectedExecutionHandler)
Set the RejectedExecutionHandler to use for the ThreadPoolExecutor.
void setThreadFactory(ThreadFactory threadFactory)
Set the ThreadFactory to use for the ThreadPoolExecutor's thread pool.
void setThreadNamePrefix(String threadNamePrefix)
Specify the prefix to use for the names of newly created threads.
void setWaitForTasksToCompleteOnShutdown(boolean waitForJobsToCompleteOnShutdown)
Set whether to wait for scheduled tasks to complete on shutdown.
void shutdown()
Perform a shutdown on the ThreadPoolExecutor.
Protected Methods
abstract ExecutorService initializeExecutor(ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler)
Create the target ExecutorService instance.
[Expand]
Inherited Methods
From class org.springframework.scheduling.concurrent.CustomizableThreadFactory
From class org.springframework.util.CustomizableThreadCreator
From class java.lang.Object
From interface java.util.concurrent.ThreadFactory
From interface org.springframework.beans.factory.BeanNameAware
From interface org.springframework.beans.factory.DisposableBean
From interface org.springframework.beans.factory.InitializingBean

Fields

protected final Log logger

Public Constructors

public ExecutorConfigurationSupport ()

Public Methods

public void afterPropertiesSet ()

Calls initialize() after the container applied all property values.

See Also

public void destroy ()

Calls shutdown when the BeanFactory destroys the task executor instance.

See Also

public void initialize ()

Set up the ExecutorService.

public void setBeanName (String name)

Set the name of the bean in the bean factory that created this bean.

Invoked after population of normal bean properties but before an init callback such as afterPropertiesSet() or a custom init-method.

Parameters
name the name of the bean in the factory. Note that this name is the actual bean name used in the factory, which may differ from the originally specified name: in particular for inner bean names, the actual bean name might have been made unique through appending "#..." suffixes. Use the BeanFactoryUtils#originalBeanName(String) method to extract the original bean name (without suffix), if desired.

public void setRejectedExecutionHandler (RejectedExecutionHandler rejectedExecutionHandler)

Set the RejectedExecutionHandler to use for the ThreadPoolExecutor. Default is the ThreadPoolExecutor's default abort policy.

See Also
  • java.util.concurrent.ThreadPoolExecutor.AbortPolicy

public void setThreadFactory (ThreadFactory threadFactory)

Set the ThreadFactory to use for the ThreadPoolExecutor's thread pool. Default is the ThreadPoolExecutor's default thread factory.

public void setThreadNamePrefix (String threadNamePrefix)

Specify the prefix to use for the names of newly created threads. Default is "SimpleAsyncTaskExecutor-".

public void setWaitForTasksToCompleteOnShutdown (boolean waitForJobsToCompleteOnShutdown)

Set whether to wait for scheduled tasks to complete on shutdown.

Default is "false". Switch this to "true" if you prefer fully completed tasks at the expense of a longer shutdown phase.

public void shutdown ()

Perform a shutdown on the ThreadPoolExecutor.

See Also

Protected Methods

protected abstract ExecutorService initializeExecutor (ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler)

Create the target ExecutorService instance. Called by afterPropertiesSet.

Parameters
threadFactory the ThreadFactory to use
rejectedExecutionHandler the RejectedExecutionHandler to use
Returns
  • a new ExecutorService instance