parent
1585a822d6
commit
7a8a9c71b6
|
|
@ -30,31 +30,34 @@ import org.springframework.core.annotation.AliasFor;
|
|||
*
|
||||
* <p>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.
|
||||
*
|
||||
* <p>Events can be {@link ApplicationEvent} instances as well as arbitrary
|
||||
* objects.
|
||||
*
|
||||
* <p>Processing of {@code @EventListener} annotations is performed via the
|
||||
* {@link EventListenerMethodProcessor} which is registered automatically
|
||||
* when using Java config or manually via the {@code <context:annotation-driven/>}
|
||||
* <p>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 <context:annotation-config/>} or {@code <context:component-scan/>}
|
||||
* element when using XML config.
|
||||
*
|
||||
* <p>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.
|
||||
* <p>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.
|
||||
*
|
||||
* <p>It is also possible to define the order in which listeners for a certain
|
||||
* event are invoked. To do so, add Spring's common
|
||||
* <p>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.
|
||||
*
|
||||
* <p>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.
|
||||
* <p>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.
|
||||
* <p>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 <em>not</em> declare any parameters.
|
||||
* <p>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 <em>not</em> 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.
|
||||
* <p>Default is "", meaning the event is always handled.
|
||||
*/
|
||||
String condition() default "";
|
||||
|
|
|
|||
Loading…
Reference in New Issue