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
DelegatingExecutorwith the name{system_name}.{task_name}is created. The task's configured executor is set in theDelegatingExecutoras it's delegate.A method annotated with
Asynccan 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 StringASYNC_TIMEOUT_EXECUTORAsync (task) timeout executor bean name.
-
Constructor Summary
Constructors Constructor Description AsyncExecutorConfiguration()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ExecutorgetAsyncExecutor()org.springframework.aop.interceptor.AsyncUncaughtExceptionHandlergetAsyncUncaughtExceptionHandler()voidpostProcessBeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)voidpostProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)voidsetAsyncPropertiesLoader(AsyncPropertiesLoader asyncPropertiesLoader)Setter for the properties loaded.voidsetEnvironment(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:
postProcessBeanDefinitionRegistryin 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.BeansExceptionConfigured method names are aliased to their corresponding executor, such that bean lookup works.
- Specified by:
postProcessBeanFactoryin interfaceorg.springframework.beans.factory.config.BeanFactoryPostProcessor- Throws:
org.springframework.beans.BeansException
-
getAsyncExecutor
public Executor getAsyncExecutor()
- Specified by:
getAsyncExecutorin interfaceorg.springframework.scheduling.annotation.AsyncConfigurer- Returns:
- the default executor.
-
getAsyncUncaughtExceptionHandler
public org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler()
- Specified by:
getAsyncUncaughtExceptionHandlerin 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:
setEnvironmentin interfaceorg.springframework.context.EnvironmentAware
-
setAsyncPropertiesLoader
public void setAsyncPropertiesLoader(AsyncPropertiesLoader asyncPropertiesLoader)
Setter for the properties loaded.Added for testability.
- Parameters:
asyncPropertiesLoader- the loader
-
-