@Configuration
@EnableAsync
public class AsyncExecutorConfiguration
extends java.lang.Object
implements org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor, org.springframework.scheduling.annotation.AsyncConfigurer, org.springframework.context.EnvironmentAware
The loaded configuration properties are themselves registered as a bean, so they may be in other classes
needing them, see EXECUTOR_CONFIGURATION_PROPERTIES
.
For each configured task a bean DelegatingExecutor
with the name {system_name}.{task_name}
is created. The
task's configured executor is set in the DelegatingExecutor
as it's delegate.
A method annotated with Async
can specify its full task name,
i.e. {system_name}.{task_name}
as the annotation value. The corresponding delegating executor bean will be retrieved by this
name.
NOTE: each async task MUST be specified in the configuration, otherwise an exception will be raised.
Constructor and Description |
---|
AsyncExecutorConfiguration() |
Modifier and Type | Method and Description |
---|---|
java.util.concurrent.Executor |
getAsyncExecutor() |
org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler |
getAsyncUncaughtExceptionHandler() |
void |
postProcessBeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) |
void |
postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) |
void |
setAsyncPropertiesLoader(AsyncPropertiesLoader asyncPropertiesLoader)
Setter for the properties loaded.
|
void |
setEnvironment(org.springframework.core.env.Environment environment) |
public void postProcessBeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) throws org.springframework.beans.BeansException
postProcessBeanDefinitionRegistry
in interface org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
org.springframework.beans.BeansException
public void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) throws org.springframework.beans.BeansException
Configured method names are aliased to their corresponding executor, such that bean lookup works.
postProcessBeanFactory
in interface org.springframework.beans.factory.config.BeanFactoryPostProcessor
org.springframework.beans.BeansException
public java.util.concurrent.Executor getAsyncExecutor()
getAsyncExecutor
in interface org.springframework.scheduling.annotation.AsyncConfigurer
isDefaultExecutor(ExecutorProperties)
public org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler()
getAsyncUncaughtExceptionHandler
in interface org.springframework.scheduling.annotation.AsyncConfigurer
public void setEnvironment(org.springframework.core.env.Environment environment)
Use the environment to obtain the location of the configuration file.
setEnvironment
in interface org.springframework.context.EnvironmentAware
public void setAsyncPropertiesLoader(AsyncPropertiesLoader asyncPropertiesLoader)
asyncPropertiesLoader
- the loader