public abstract class ExecutorConfigurationSupport extends CustomizableThreadFactory implements org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
java.util.concurrent.ExecutorService
(typically a ThreadPoolExecutor).
Defines common configuration settings and common lifecycle handling.ExecutorService,
Executors,
ThreadPoolExecutor,
Serialized Form| Constructor and Description |
|---|
ExecutorConfigurationSupport() |
| Modifier and Type | Method and Description |
|---|---|
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.
|
protected abstract ExecutorService |
initializeExecutor(ThreadFactory threadFactory,
RejectedExecutionHandler rejectedExecutionHandler)
Create the target
ExecutorService instance. |
void |
setBeanName(String name) |
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) |
void |
setWaitForTasksToCompleteOnShutdown(boolean waitForJobsToCompleteOnShutdown)
Set whether to wait for scheduled tasks to complete on shutdown.
|
void |
shutdown()
Perform a shutdown on the ThreadPoolExecutor.
|
newThreadprotected final Log logger
public void setThreadFactory(ThreadFactory threadFactory)
Executors.defaultThreadFactory()public void setThreadNamePrefix(String threadNamePrefix)
setThreadNamePrefix in class org.springframework.util.CustomizableThreadCreatorpublic void setRejectedExecutionHandler(RejectedExecutionHandler rejectedExecutionHandler)
ThreadPoolExecutor.AbortPolicypublic void setWaitForTasksToCompleteOnShutdown(boolean waitForJobsToCompleteOnShutdown)
Default is "false". Switch this to "true" if you prefer fully completed tasks at the expense of a longer shutdown phase.
public void setBeanName(String name)
setBeanName in interface org.springframework.beans.factory.BeanNameAwarepublic void afterPropertiesSet()
initialize() after the container applied all property values.afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeaninitialize()public void initialize()
protected abstract ExecutorService initializeExecutor(ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler)
ExecutorService instance.
Called by afterPropertiesSet.threadFactory - the ThreadFactory to userejectedExecutionHandler - the RejectedExecutionHandler to useafterPropertiesSet()public void destroy()
shutdown when the BeanFactory destroys
the task executor instance.destroy in interface org.springframework.beans.factory.DisposableBeanshutdown()public void shutdown()
ExecutorService.shutdown()