|
45 | 45 | * {@link GenericApplicationListener} adapter that delegates the processing of
|
46 | 46 | * an event to an {@link EventListener} annotated method.
|
47 | 47 | *
|
48 |
| - * <p>Delegates to {@link #processEvent(ApplicationEvent)} to give a chance to |
49 |
| - * sub-classes to deviate from the default. Unwraps the content of a |
| 48 | + * <p>Delegates to {@link #processEvent(ApplicationEvent)} to give sub-classes |
| 49 | + * a chance to deviate from the default. Unwraps the content of a |
50 | 50 | * {@link PayloadApplicationEvent} if necessary to allow method declaration
|
51 | 51 | * to define any arbitrary event type. If a condition is defined, it is
|
52 | 52 | * evaluated prior to invoking the underlying method.
|
53 | 53 | *
|
54 | 54 | * @author Stephane Nicoll
|
| 55 | + * @author Sam Brannen |
55 | 56 | * @since 4.2
|
56 | 57 | */
|
57 | 58 | public class ApplicationListenerMethodAdapter implements GenericApplicationListener {
|
@@ -124,6 +125,7 @@ public void processEvent(ApplicationEvent event) {
|
124 | 125 | protected Object[] resolveArguments(ApplicationEvent event) {
|
125 | 126 | if (!ApplicationEvent.class.isAssignableFrom(this.declaredEventType.getRawClass())
|
126 | 127 | && event instanceof PayloadApplicationEvent) {
|
| 128 | + @SuppressWarnings("rawtypes") |
127 | 129 | Object payload = ((PayloadApplicationEvent) event).getPayload();
|
128 | 130 | if (this.declaredEventType.isAssignableFrom(ResolvableType.forClass(payload.getClass()))) {
|
129 | 131 | return new Object[] {payload};
|
@@ -240,20 +242,20 @@ protected Object getTargetBean() {
|
240 | 242 | }
|
241 | 243 |
|
242 | 244 | /**
|
243 |
| - * Return the condition to use. Matches the {@code condition} attribute of the |
244 |
| - * {@link EventListener} annotation or any matching attribute on a composed |
245 |
| - * annotation. |
| 245 | + * Return the condition to use. |
| 246 | + * <p>Matches the {@code condition} attribute of the {@link EventListener} |
| 247 | + * annotation or any matching attribute on a composed annotation that |
| 248 | + * is meta-annotated with {@code @EventListener}. |
246 | 249 | */
|
247 | 250 | protected String getCondition() {
|
248 | 251 | if (this.condition == null) {
|
249 |
| - // TODO annotationAttributes are null with proxy |
250 | 252 | AnnotationAttributes annotationAttributes = AnnotatedElementUtils
|
251 | 253 | .getAnnotationAttributes(this.method, EventListener.class.getName());
|
252 | 254 | if (annotationAttributes != null) {
|
253 | 255 | String value = annotationAttributes.getString("condition");
|
254 | 256 | this.condition = (value != null ? value : "");
|
255 | 257 | }
|
256 |
| - // TODO Remove once AnnotatedElementUtils supports annotations on proxies |
| 258 | + // TODO [SPR-12738] Remove once AnnotatedElementUtils finds annotated methods on interfaces (e.g., in dynamic proxies) |
257 | 259 | else {
|
258 | 260 | EventListener eventListener = getMethodAnnotation(EventListener.class);
|
259 | 261 | this.condition = (eventListener != null ? eventListener.condition() : "");
|
|
0 commit comments