Skip to content

Commit e0d2dbd

Browse files
committed
Polish Javadoc & TODOs in ApplicationListenerMethodAdapter
Issue: SPR-12738
1 parent 8ece1b1 commit e0d2dbd

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@
4545
* {@link GenericApplicationListener} adapter that delegates the processing of
4646
* an event to an {@link EventListener} annotated method.
4747
*
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
5050
* {@link PayloadApplicationEvent} if necessary to allow method declaration
5151
* to define any arbitrary event type. If a condition is defined, it is
5252
* evaluated prior to invoking the underlying method.
5353
*
5454
* @author Stephane Nicoll
55+
* @author Sam Brannen
5556
* @since 4.2
5657
*/
5758
public class ApplicationListenerMethodAdapter implements GenericApplicationListener {
@@ -124,6 +125,7 @@ public void processEvent(ApplicationEvent event) {
124125
protected Object[] resolveArguments(ApplicationEvent event) {
125126
if (!ApplicationEvent.class.isAssignableFrom(this.declaredEventType.getRawClass())
126127
&& event instanceof PayloadApplicationEvent) {
128+
@SuppressWarnings("rawtypes")
127129
Object payload = ((PayloadApplicationEvent) event).getPayload();
128130
if (this.declaredEventType.isAssignableFrom(ResolvableType.forClass(payload.getClass()))) {
129131
return new Object[] {payload};
@@ -240,20 +242,20 @@ protected Object getTargetBean() {
240242
}
241243

242244
/**
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}.
246249
*/
247250
protected String getCondition() {
248251
if (this.condition == null) {
249-
// TODO annotationAttributes are null with proxy
250252
AnnotationAttributes annotationAttributes = AnnotatedElementUtils
251253
.getAnnotationAttributes(this.method, EventListener.class.getName());
252254
if (annotationAttributes != null) {
253255
String value = annotationAttributes.getString("condition");
254256
this.condition = (value != null ? value : "");
255257
}
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)
257259
else {
258260
EventListener eventListener = getMethodAnnotation(EventListener.class);
259261
this.condition = (eventListener != null ? eventListener.condition() : "");

spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ public PayloadTestEvent(Object source, T payload, V something) {
335335
}
336336
}
337337

338-
@SuppressWarnings({"unused", "serial"})
338+
@SuppressWarnings({ "serial" })
339339
static class PayloadStringTestEvent extends PayloadTestEvent<Long, String> {
340340
public PayloadStringTestEvent(Object source, String payload, Long something) {
341341
super(source, payload, something);

0 commit comments

Comments
 (0)