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
|
* <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.
|
* declare a single parameter that reflects the event type to listen to.
|
||||||
* If an annotated method supports multiple event types, this annotation may
|
* If an annotated method supports multiple event types, this annotation
|
||||||
* refer to one or more supported event types using the {@code classes}
|
* may refer to one or more supported event types using the {@code classes}
|
||||||
* attribute. See {@link #classes} for further details.
|
* attribute. See the {@link #classes} javadoc for further details.
|
||||||
*
|
*
|
||||||
* <p>Events can be {@link ApplicationEvent} instances as well as arbitrary
|
* <p>Events can be {@link ApplicationEvent} instances as well as arbitrary
|
||||||
* objects.
|
* objects.
|
||||||
*
|
*
|
||||||
* <p>Processing of {@code @EventListener} annotations is performed via the
|
* <p>Processing of {@code @EventListener} annotations is performed via
|
||||||
* {@link EventListenerMethodProcessor} which is registered automatically
|
* the internal {@link EventListenerMethodProcessor} bean which gets
|
||||||
* when using Java config or manually via the {@code <context:annotation-driven/>}
|
* registered automatically when using Java config or manually via the
|
||||||
|
* {@code <context:annotation-config/>} or {@code <context:component-scan/>}
|
||||||
* element when using XML config.
|
* element when using XML config.
|
||||||
*
|
*
|
||||||
* <p>Annotated methods may have a non-{@code void} return type. When they do,
|
* <p>Annotated methods may have a non-{@code void} return type. When they
|
||||||
* the result of the method invocation is sent as a new event. If the return type
|
* do, the result of the method invocation is sent as a new event. If the
|
||||||
* is either an array or a collection, each element is sent as a new event.
|
* 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
|
* <p>It is also possible to define the order in which listeners for a
|
||||||
* event are invoked. To do so, add Spring's common
|
* certain event are to be invoked. To do so, add Spring's common
|
||||||
* {@link org.springframework.core.annotation.Order @Order} annotation
|
* {@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
|
* <p>While it is possible for an event listener to declare that it
|
||||||
* exception types, any checked exceptions thrown from an event listener will be
|
* throws arbitrary exception types, any checked exceptions thrown
|
||||||
* wrapped in an {@link java.lang.reflect.UndeclaredThrowableException} since
|
* from an event listener will be wrapped in an
|
||||||
* the caller can only handle runtime exceptions.
|
* {@link java.lang.reflect.UndeclaredThrowableException}
|
||||||
|
* since the event publisher can only handle runtime exceptions.
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
|
|
@ -73,17 +76,17 @@ public @interface EventListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The event classes that this listener handles.
|
* The event classes that this listener handles.
|
||||||
* <p>If this attribute is specified with a single value, the annotated
|
* <p>If this attribute is specified with a single value, the
|
||||||
* method may optionally accept a single parameter. However, if this
|
* annotated method may optionally accept a single parameter.
|
||||||
* attribute is specified with multiple values, the annotated method
|
* However, if this attribute is specified with multiple values,
|
||||||
* must <em>not</em> declare any parameters.
|
* the annotated method must <em>not</em> declare any parameters.
|
||||||
*/
|
*/
|
||||||
@AliasFor("value")
|
@AliasFor("value")
|
||||||
Class<?>[] classes() default {};
|
Class<?>[] classes() default {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring Expression Language (SpEL) attribute used for making the event
|
* Spring Expression Language (SpEL) attribute used for making the
|
||||||
* handling conditional.
|
* event handling conditional.
|
||||||
* <p>Default is "", meaning the event is always handled.
|
* <p>Default is "", meaning the event is always handled.
|
||||||
*/
|
*/
|
||||||
String condition() default "";
|
String condition() default "";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue