diff --git a/spring-context/src/main/java/org/springframework/context/event/EventListener.java b/spring-context/src/main/java/org/springframework/context/event/EventListener.java index 5f86890079d..9f4fefb4c54 100644 --- a/spring-context/src/main/java/org/springframework/context/event/EventListener.java +++ b/spring-context/src/main/java/org/springframework/context/event/EventListener.java @@ -30,31 +30,34 @@ import org.springframework.core.annotation.AliasFor; * *
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 {@code classes} - * attribute. See {@link #classes} for further details. + * If an annotated method supports multiple event types, this annotation + * may refer to one or more supported event types using the {@code classes} + * attribute. See the {@link #classes} javadoc for further details. * *
Events can be {@link ApplicationEvent} instances as well as arbitrary * objects. * - *
Processing of {@code @EventListener} annotations is performed via the
- * {@link EventListenerMethodProcessor} which is registered automatically
- * when using Java config or manually via the {@code
Processing of {@code @EventListener} annotations is performed via
+ * the internal {@link EventListenerMethodProcessor} bean which gets
+ * registered automatically when using Java config or manually via the
+ * {@code
Annotated methods may have a non-{@code 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 event. + *
Annotated methods may have a non-{@code 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 invoked. To do so, add Spring's common + *
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 * {@link org.springframework.core.annotation.Order @Order} annotation - * alongside this annotation. + * 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 {@link java.lang.reflect.UndeclaredThrowableException} since - * the caller can only handle runtime exceptions. + *
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 + * {@link java.lang.reflect.UndeclaredThrowableException} + * since the event publisher can only handle runtime exceptions. * * @author Stephane Nicoll * @since 4.2 @@ -73,17 +76,17 @@ public @interface EventListener { /** * The event classes that this listener handles. - *
If this attribute is specified with a single value, the annotated - * method may optionally accept a single parameter. However, if this - * attribute is specified with multiple values, the annotated method - * must not declare any parameters. + *
If this attribute is specified with a single value, the + * annotated method may optionally accept a single parameter. + * However, if this attribute is specified with multiple values, + * the annotated method must not declare any parameters. */ @AliasFor("value") Class>[] classes() default {}; /** - * Spring Expression Language (SpEL) attribute used for making the event - * handling conditional. + * Spring Expression Language (SpEL) attribute used for making the + * event handling conditional. *
Default is "", meaning the event is always handled. */ String condition() default "";