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| Modifier and Type | Field and Description |
|---|---|
protected org.apache.commons.logging.Log |
logger |
| 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 java.util.concurrent.ExecutorService |
initializeExecutor(java.util.concurrent.ThreadFactory threadFactory,
java.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)
Create the target
ExecutorService instance. |
void |
setBeanName(java.lang.String name) |
void |
setRejectedExecutionHandler(java.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)
Set the RejectedExecutionHandler to use for the ThreadPoolExecutor.
|
void |
setThreadFactory(java.util.concurrent.ThreadFactory threadFactory)
Set the ThreadFactory to use for the ThreadPoolExecutor's thread pool.
|
void |
setThreadNamePrefix(java.lang.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.
|
newThreadpublic void setThreadFactory(java.util.concurrent.ThreadFactory threadFactory)
Executors.defaultThreadFactory()public void setThreadNamePrefix(java.lang.String threadNamePrefix)
setThreadNamePrefix in class org.springframework.util.CustomizableThreadCreatorpublic void setRejectedExecutionHandler(java.util.concurrent.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.
ExecutorService.shutdown(),
ExecutorService.shutdownNow()public void setBeanName(java.lang.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 java.util.concurrent.ExecutorService initializeExecutor(java.util.concurrent.ThreadFactory threadFactory,
java.util.concurrent.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()