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 @ConditionalOnProperty(prefix="hawaii.async", name="enabled", matchIfMissing=true) @Import({org.hawaiiframework.sql.DataSourceProxyConfiguration.class,TaskListenerFactoryConfiguration.class}) @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 the DelegatingExecutor as its 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
  • Field Details

    • ASYNC_TIMEOUT_EXECUTOR

      public static final String ASYNC_TIMEOUT_EXECUTOR
      Async (task) timeout executor bean name.
      See Also:
  • Constructor Details

    • AsyncExecutorConfiguration

      public AsyncExecutorConfiguration()
  • Method Details

    • postProcessBeanDefinitionRegistry

      public void postProcessBeanDefinitionRegistry(@NonNull org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
      Specified by:
      postProcessBeanDefinitionRegistry in interface org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
    • postProcessBeanFactory

      public void postProcessBeanFactory(@NonNull org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)

      Configured method names are aliased to their corresponding executor, such that bean lookup works.

      Specified by:
      postProcessBeanFactory in interface org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
      Specified by:
      postProcessBeanFactory in interface org.springframework.beans.factory.config.BeanFactoryPostProcessor
    • getAsyncExecutor

      public Executor getAsyncExecutor()
      Specified by:
      getAsyncExecutor in interface org.springframework.scheduling.annotation.AsyncConfigurer
      Returns:
      the default executor.
    • getAsyncUncaughtExceptionHandler

      public org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler()
      Specified by:
      getAsyncUncaughtExceptionHandler in interface org.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 interface org.springframework.context.EnvironmentAware
    • setAsyncPropertiesLoader

      public void setAsyncPropertiesLoader(AsyncPropertiesLoader asyncPropertiesLoader)
      Setter for the properties loaded.

      Added for testability.

      Parameters:
      asyncPropertiesLoader - the loader