接口 ApplicationListener<E extends ApplicationEvent>

类型参数:
E - the specific event to listen to
所有超级接口:
EventListener
所有已知子接口:
GenericApplicationListener, SmartApplicationListener
所有已知实现类:
ApplicationListenerMethodAdapter, GenericApplicationListenerAdapter, ScheduledAnnotationBeanPostProcessor, SourceFilteringListener
函数接口:
这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。

@FunctionalInterface public interface ApplicationListener<E extends ApplicationEvent> extends EventListener
Interface to be implemented by application event listeners.

Based on the standard java.util.EventListener interface for the Observer design pattern.

As of 4.0, an ApplicationListener can generically declare the event type that it is interested in. When registered with a ApplicationContext, events will be filtered accordingly, with the listener getting invoked for matching event objects only.

作者:
Rod Johnson, Juergen Hoeller, TODAY 2018-09-09 21:23
另请参阅:
  • 方法详细资料

    • onApplicationEvent

      void onApplicationEvent(E event)
      Handle an application event.
      参数:
      event - the event to respond to
    • forPayload

      static <T> ApplicationListener<PayloadApplicationEvent<T>> forPayload(Consumer<T> consumer)
      Create a new ApplicationListener for the given payload consumer.
      类型参数:
      T - the type of the event payload
      参数:
      consumer - the event payload consumer
      返回:
      a corresponding ApplicationListener instance
      从以下版本开始:
      4.0
      另请参阅: