Annotation that marks a method as a listener for application events.
If an annotated method supports a single event type, the method may
declare a single parameter that reflects the event type to listen to.
If an annotated method supports multiple event types, this annotation
may refer to one or more supported event types using the
attribute. See the
classes() javadoc for further details.
Events can be
ApplicationEvent instances as well as arbitrary
@EventListener annotations is performed via
EventListenerMethodProcessor bean which gets
registered automatically when using Java config or manually via the
element when using XML config.
Annotated methods may have a non-
void return type. When they
do, the result of the method invocation is sent as a new event. If the
return type is either an array or a collection, each element is sent
as a new individual event.
It is also possible to define the order in which listeners for a
certain event are to be invoked. To do so, add Spring's common
alongside this event listener annotation.
While it is possible for an event listener to declare that it
throws arbitrary exception types, any checked exceptions thrown
from an event listener will be wrapped in an
since the event publisher can only handle runtime exceptions.