Polish ApplicationListenerMethodAdapter
This commit is contained in:
parent
b9b0b78fa1
commit
86733a98da
|
|
@ -46,7 +46,7 @@ import org.springframework.util.StringUtils;
|
||||||
* an event to an {@link EventListener} annotated method.
|
* an event to an {@link EventListener} annotated method.
|
||||||
*
|
*
|
||||||
* <p>Delegates to {@link #processEvent(ApplicationEvent)} to give a chance to
|
* <p>Delegates to {@link #processEvent(ApplicationEvent)} to give a chance to
|
||||||
* sub-classes to deviate from the default. Unwrap the content of a
|
* sub-classes to deviate from the default. Unwraps the content of a
|
||||||
* {@link PayloadApplicationEvent} if necessary to allow method declaration
|
* {@link PayloadApplicationEvent} if necessary to allow method declaration
|
||||||
* to define any arbitrary event type. If a condition is defined, it is
|
* to define any arbitrary event type. If a condition is defined, it is
|
||||||
* evaluated prior to invoking the underlying method.
|
* evaluated prior to invoking the underlying method.
|
||||||
|
|
@ -241,19 +241,22 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the condition to use. Matches the {@code condition} attribute of the
|
* Return the condition to use. Matches the {@code condition} attribute of the
|
||||||
* {@link EventListener} annotation or any matching attribute on a meta-annotation.
|
* {@link EventListener} annotation or any matching attribute on a composed
|
||||||
|
* annotation.
|
||||||
*/
|
*/
|
||||||
protected String getCondition() {
|
protected String getCondition() {
|
||||||
if (this.condition == null) {
|
if (this.condition == null) {
|
||||||
|
// TODO annotationAttributes are null with proxy
|
||||||
AnnotationAttributes annotationAttributes = AnnotatedElementUtils
|
AnnotationAttributes annotationAttributes = AnnotatedElementUtils
|
||||||
.getAnnotationAttributes(this.method, EventListener.class.getName());
|
.getAnnotationAttributes(this.method, EventListener.class.getName());
|
||||||
if (annotationAttributes != null) {
|
if (annotationAttributes != null) {
|
||||||
String value = annotationAttributes.getString("condition");
|
String value = annotationAttributes.getString("condition");
|
||||||
this.condition = (value != null ? value : "");
|
this.condition = (value != null ? value : "");
|
||||||
}
|
}
|
||||||
else { // TODO annotationAttributes null with proxy
|
// TODO Remove once AnnotatedElementUtils supports annotations on proxies
|
||||||
|
else {
|
||||||
EventListener eventListener = getMethodAnnotation(EventListener.class);
|
EventListener eventListener = getMethodAnnotation(EventListener.class);
|
||||||
this.condition = (eventListener != null ? eventListener.condition() : null);
|
this.condition = (eventListener != null ? eventListener.condition() : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.condition;
|
return this.condition;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue