org.springframework.context.event

## 类 ApplicationListenerMethodAdapter

- java.lang.Object
- - org.springframework.context.event.ApplicationListenerMethodAdapter

- 所有已实现的接口:
    EventListener, ApplicationListener<ApplicationEvent>, GenericApplicationListener, org.springframework.core.Ordered

      public class ApplicationListenerMethodAdapter
      extends Object
      implements GenericApplicationListener

  `GenericApplicationListener` adapter that delegates the processing of an event to an `EventListener` annotated method.

  Delegates to `processEvent(ApplicationEvent)` to give sub-classes a chance to deviate from the default. Unwraps the content of a `PayloadApplicationEvent` if necessary to allow method declaration to define any arbitrary event type. If a condition is defined, it is evaluated prior to invoking the underlying method.

  从以下版本开始:
    4.2
  作者:
    Stephane Nicoll, Juergen Hoeller, Sam Brannen

- - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `protected Log` | `logger`

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

      `HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

  - ### 构造器概要

    构造器
    构造器和说明
    `ApplicationListenerMethodAdapter(String beanName, Class<?> targetClass, Method method)`

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `protected Object` | `doInvoke(Object... args)` Invoke the event listener method with the given argument values.
    `protected String` | `getCondition()` Return the condition to use.
    `protected String` | `getDetailedErrorMessage(Object bean, String message)` Add additional details such as the bean type and method signature to the given error message.
    `int` | `getOrder()`
    `protected Object` | `getTargetBean()` Return the target bean instance to use.
    `protected void` | `handleResult(Object result)`
    `void` | `onApplicationEvent(ApplicationEvent event)` Handle an application event.
    `void` | `processEvent(ApplicationEvent event)` Process the specified `ApplicationEvent`, checking if the condition match and handling non-null result, if any.
    `protected Object[]` | `resolveArguments(ApplicationEvent event)` Resolve the method arguments to use for the specified `ApplicationEvent`.
    `boolean` | `supportsEventType(org.springframework.core.ResolvableType eventType)` Determine whether this listener actually supports the given event type.
    `boolean` | `supportsSourceType(Class<?> sourceType)` Determine whether this listener actually supports the given source type.
    `String` | `toString()`

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

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

- - ### 字段详细资料

    - #### logger

          protected final Log logger

  - ### 构造器详细资料

    - #### ApplicationListenerMethodAdapter

          public ApplicationListenerMethodAdapter(String beanName,
                                                  Class<?> targetClass,
                                                  Method method)

  - ### 方法详细资料

    - #### onApplicationEvent

          public void onApplicationEvent(ApplicationEvent event)

      从接口复制的说明: `ApplicationListener`
      Handle an application event.
      指定者:
        `onApplicationEvent` 在接口中 `ApplicationListener<ApplicationEvent>`
      参数:
        `event` - the event to respond to

    - #### supportsEventType

          public boolean supportsEventType(org.springframework.core.ResolvableType eventType)

      从接口复制的说明: `GenericApplicationListener`
      Determine whether this listener actually supports the given event type.
      指定者:
        `supportsEventType` 在接口中 `GenericApplicationListener`
      参数:
        `eventType` - the event type (never `null`)

    - #### supportsSourceType

          public boolean supportsSourceType(@Nullable
                                            Class<?> sourceType)

      从接口复制的说明: `GenericApplicationListener`
      Determine whether this listener actually supports the given source type.
      指定者:
        `supportsSourceType` 在接口中 `GenericApplicationListener`
      参数:
        `sourceType` - the source type, or `null` if no source

    - #### getOrder

          public int getOrder()

      指定者:
        `getOrder` 在接口中 `org.springframework.core.Ordered`

    - #### processEvent

          public void processEvent(ApplicationEvent event)

      Process the specified `ApplicationEvent`, checking if the condition match and handling non-null result, if any.

    - #### resolveArguments

          @Nullable
          protected Object[] resolveArguments(ApplicationEvent event)

      Resolve the method arguments to use for the specified `ApplicationEvent`.

      These arguments will be used to invoke the method handled by this instance. Can return `null` to indicate that no suitable arguments could be resolved and therefore the method should not be invoked at all for the specified event.

    - #### handleResult

          protected void handleResult(Object result)

    - #### doInvoke

          @Nullable
          protected Object doInvoke(Object... args)

      Invoke the event listener method with the given argument values.

    - #### getTargetBean

          protected Object getTargetBean()

      Return the target bean instance to use.

    - #### getCondition

          @Nullable
          protected String getCondition()

      Return the condition to use.

      Matches the `condition` attribute of the `EventListener` annotation or any matching attribute on a composed annotation that is meta-annotated with `@EventListener`.

    - #### getDetailedErrorMessage

          protected String getDetailedErrorMessage(Object bean,
                                                   String message)

      Add additional details such as the bean type and method signature to the given error message.
      参数:
        `message` - error message to append the HandlerMethod details to

    - #### toString

          public String toString()

      覆盖:
        `toString` 在类中 `Object`