org.springframework.scheduling.annotation

## 类 AsyncAnnotationBeanPostProcessor

- java.lang.Object
- - org.springframework.aop.framework.ProxyConfig
  - - org.springframework.aop.framework.ProxyProcessorSupport
    - - org.springframework.aop.framework.AbstractAdvisingBeanPostProcessor
      - - org.springframework.aop.framework.autoproxy.AbstractBeanFactoryAwareAdvisingPostProcessor
        - - org.springframework.scheduling.annotation.AsyncAnnotationBeanPostProcessor

- 所有已实现的接口:
    Serializable, org.springframework.aop.framework.AopInfrastructureBean, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.config.BeanPostProcessor, org.springframework.core.Ordered

      public class AsyncAnnotationBeanPostProcessor
      extends org.springframework.aop.framework.autoproxy.AbstractBeanFactoryAwareAdvisingPostProcessor

  Bean post-processor that automatically applies asynchronous invocation behavior to any bean that carries the `Async` annotation at class or method-level by adding a corresponding `AsyncAnnotationAdvisor` to the exposed proxy (either an existing AOP proxy or a newly generated proxy that implements all of the target's interfaces).

  The `TaskExecutor` responsible for the asynchronous execution may be provided as well as the annotation type that indicates a method should be invoked asynchronously. If no annotation type is specified, this post- processor will detect both Spring's `@Async` annotation as well as the EJB 3.1 `javax.ejb.Asynchronous` annotation.

  For methods having a `void` return type, any exception thrown during the asynchronous method invocation cannot be accessed by the caller. An `AsyncUncaughtExceptionHandler` can be specified to handle these cases.

  Note: The underlying async advisor applies before existing advisors by default, in order to switch to async execution as early as possible in the invocation chain.

  从以下版本开始:
    3.0
  作者:
    Mark Fisher, Juergen Hoeller, Stephane Nicoll
  另请参阅:
    `Async`, `AsyncAnnotationAdvisor`, `AbstractAdvisingBeanPostProcessor.setBeforeExistingAdvisors(boolean)`, `ScheduledAnnotationBeanPostProcessor`, 序列化表格

- - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `static String` | `DEFAULT_TASK_EXECUTOR_BEAN_NAME` The default name of the `TaskExecutor` bean to pick up: "taskExecutor".
    `protected Log` | `logger`

    - ### 从类继承的字段 org.springframework.aop.framework.AbstractAdvisingBeanPostProcessor

      `advisor, beforeExistingAdvisors`

    - ### 从接口继承的字段 org.springframework.core.Ordered

      `HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

  - ### 构造器概要

    构造器
    构造器和说明
    `AsyncAnnotationBeanPostProcessor()`

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `void` | `setAsyncAnnotationType(Class<? extends Annotation> asyncAnnotationType)` Set the 'async' annotation type to be detected at either class or method level.
    `void` | `setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)`
    `void` | `setExceptionHandler(org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler exceptionHandler)` Set the `AsyncUncaughtExceptionHandler` to use to handle uncaught exceptions thrown by asynchronous method executions.
    `void` | `setExecutor(Executor executor)` Set the `Executor` to use when invoking methods asynchronously.

    - ### 从类继承的方法 org.springframework.aop.framework.autoproxy.AbstractBeanFactoryAwareAdvisingPostProcessor

      `prepareProxyFactory`

    - ### 从类继承的方法 org.springframework.aop.framework.AbstractAdvisingBeanPostProcessor

      `customizeProxyFactory, isEligible, isEligible, postProcessAfterInitialization, postProcessBeforeInitialization, setBeforeExistingAdvisors`

    - ### 从类继承的方法 org.springframework.aop.framework.ProxyProcessorSupport

      `evaluateProxyInterfaces, getOrder, getProxyClassLoader, isConfigurationCallbackInterface, isInternalLanguageInterface, setBeanClassLoader, setOrder, setProxyClassLoader`

    - ### 从类继承的方法 org.springframework.aop.framework.ProxyConfig

      `copyFrom, isExposeProxy, isFrozen, isOpaque, isOptimize, isProxyTargetClass, setExposeProxy, setFrozen, setOpaque, setOptimize, setProxyTargetClass, toString`

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### 字段详细资料

    - #### DEFAULT_TASK_EXECUTOR_BEAN_NAME

          public static final String DEFAULT_TASK_EXECUTOR_BEAN_NAME

      The default name of the `TaskExecutor` bean to pick up: "taskExecutor".

      Note that the initial lookup happens by type; this is just the fallback in case of multiple executor beans found in the context.

      从以下版本开始:
        4.2
      另请参阅:
        `AsyncExecutionAspectSupport.DEFAULT_TASK_EXECUTOR_BEAN_NAME`, 常量字段值

    - #### logger

          protected final Log logger

  - ### 构造器详细资料

    - #### AsyncAnnotationBeanPostProcessor

          public AsyncAnnotationBeanPostProcessor()

  - ### 方法详细资料

    - #### setAsyncAnnotationType

          public void setAsyncAnnotationType(Class<? extends Annotation> asyncAnnotationType)

      Set the 'async' annotation type to be detected at either class or method level. By default, both the `Async` annotation and the EJB 3.1 `javax.ejb.Asynchronous` annotation will be detected.

      This setter property exists so that developers can provide their own (non-Spring-specific) annotation type to indicate that a method (or all methods of a given class) should be invoked asynchronously.

      参数:
        `asyncAnnotationType` - the desired annotation type

    - #### setExecutor

          public void setExecutor(Executor executor)

      Set the `Executor` to use when invoking methods asynchronously.

      If not specified, default executor resolution will apply: searching for a unique `TaskExecutor` bean in the context, or for an `Executor` bean named "taskExecutor" otherwise. If neither of the two is resolvable, a local default executor will be created within the interceptor.

      另请参阅:
        `AsyncAnnotationAdvisor.AsyncAnnotationAdvisor(Executor, AsyncUncaughtExceptionHandler)`, `AsyncExecutionInterceptor.getDefaultExecutor(BeanFactory)`, `DEFAULT_TASK_EXECUTOR_BEAN_NAME`

    - #### setExceptionHandler

          public void setExceptionHandler(org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler exceptionHandler)

      Set the `AsyncUncaughtExceptionHandler` to use to handle uncaught exceptions thrown by asynchronous method executions.
      从以下版本开始:
        4.1

    - #### setBeanFactory

          public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)

      指定者:
        `setBeanFactory` 在接口中 `org.springframework.beans.factory.BeanFactoryAware`
      覆盖:
        `setBeanFactory` 在类中 `org.springframework.aop.framework.autoproxy.AbstractBeanFactoryAwareAdvisingPostProcessor`