|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.util.CustomizableThreadCreator org.springframework.scheduling.concurrent.CustomizableThreadFactory org.springframework.scheduling.concurrent.ExecutorConfigurationSupport
public abstract class ExecutorConfigurationSupport
Base class for classes that are setting up a
java.util.concurrent.ExecutorService
(typically a ThreadPoolExecutor
).
Defines common configuration settings and common lifecycle handling.
ExecutorService
,
Executors
,
ThreadPoolExecutor
,
Serialized FormField Summary | |
---|---|
protected Log |
logger
|
Constructor Summary | |
---|---|
ExecutorConfigurationSupport()
|
Method Summary | |
---|---|
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)
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. |
Methods inherited from class org.springframework.scheduling.concurrent.CustomizableThreadFactory |
---|
newThread |
Methods inherited from class org.springframework.util.CustomizableThreadCreator |
---|
createThread, getDefaultThreadNamePrefix, getThreadGroup, getThreadNamePrefix, getThreadPriority, isDaemon, nextThreadName, setDaemon, setThreadGroup, setThreadGroupName, setThreadPriority |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final Log logger
Constructor Detail |
---|
public ExecutorConfigurationSupport()
Method Detail |
---|
public void setThreadFactory(ThreadFactory threadFactory)
Executors.defaultThreadFactory()
public void setThreadNamePrefix(String threadNamePrefix)
CustomizableThreadCreator
setThreadNamePrefix
in class CustomizableThreadCreator
public void setRejectedExecutionHandler(RejectedExecutionHandler rejectedExecutionHandler)
ThreadPoolExecutor.AbortPolicy
public 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(String name)
BeanNameAware
Invoked after population of normal bean properties but before an
init callback such as InitializingBean.afterPropertiesSet()
or a custom init-method.
setBeanName
in interface BeanNameAware
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 afterPropertiesSet()
initialize()
after the container applied all property values.
afterPropertiesSet
in interface InitializingBean
initialize()
public void initialize()
protected abstract ExecutorService initializeExecutor(ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler)
ExecutorService
instance.
Called by afterPropertiesSet
.
threadFactory
- the ThreadFactory to userejectedExecutionHandler
- the RejectedExecutionHandler to use
afterPropertiesSet()
public void destroy()
shutdown
when the BeanFactory destroys
the task executor instance.
destroy
in interface DisposableBean
shutdown()
public void shutdown()
ExecutorService.shutdown()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |