Class AsyncExecutorConfiguration
- java.lang.Object
-
- org.hawaiiframework.async.AsyncExecutorConfiguration
-
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.config.BeanFactoryPostProcessor
,org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
,org.springframework.context.EnvironmentAware
,org.springframework.scheduling.annotation.AsyncConfigurer
@Configuration @EnableAsync public class AsyncExecutorConfiguration extends Object implements org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor, org.springframework.scheduling.annotation.AsyncConfigurer, org.springframework.context.EnvironmentAware
Configuration class to set up asynchronous executors.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 theDelegatingExecutor
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.
- Since:
- 2.0.0
- Author:
- Rutger Lubbers, Paul Klos
-
-
Field Summary
Fields Modifier and Type Field Description static String
ASYNC_TIMEOUT_EXECUTOR
Async (task) timeout executor bean name.
-
Constructor Summary
Constructors Constructor Description AsyncExecutorConfiguration()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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)
-
-
-
Field Detail
-
ASYNC_TIMEOUT_EXECUTOR
public static final String ASYNC_TIMEOUT_EXECUTOR
Async (task) timeout executor bean name.- See Also:
- Constant Field Values
-
-
Method Detail
-
postProcessBeanDefinitionRegistry
public void postProcessBeanDefinitionRegistry(@NonNull org.springframework.beans.factory.support.BeanDefinitionRegistry registry) throws org.springframework.beans.BeansException
- Specified by:
postProcessBeanDefinitionRegistry
in interfaceorg.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
- Throws:
org.springframework.beans.BeansException
-
postProcessBeanFactory
public void postProcessBeanFactory(@NonNull 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.
- Specified by:
postProcessBeanFactory
in interfaceorg.springframework.beans.factory.config.BeanFactoryPostProcessor
- Throws:
org.springframework.beans.BeansException
-
getAsyncExecutor
public Executor getAsyncExecutor()
- Specified by:
getAsyncExecutor
in interfaceorg.springframework.scheduling.annotation.AsyncConfigurer
- Returns:
- the default executor.
-
getAsyncUncaughtExceptionHandler
public org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler()
- Specified by:
getAsyncUncaughtExceptionHandler
in interfaceorg.springframework.scheduling.annotation.AsyncConfigurer
- Returns:
- null, i.e. use the Spring default
-
setEnvironment
public void setEnvironment(@NonNull org.springframework.core.env.Environment environment)
Use the environment to obtain the location of the configuration file.
- Specified by:
setEnvironment
in interfaceorg.springframework.context.EnvironmentAware
-
setAsyncPropertiesLoader
public void setAsyncPropertiesLoader(AsyncPropertiesLoader asyncPropertiesLoader)
Setter for the properties loaded.Added for testability.
- Parameters:
asyncPropertiesLoader
- the loader
-
-