Reliably detect event listener conditions on proxied beans

Issue: SPR-15678
This commit is contained in:
Juergen Hoeller
2017-07-05 13:41:56 +02:00
parent a6d616d844
commit eb928ce456
2 changed files with 35 additions and 4 deletions

View File

@@ -38,6 +38,7 @@ import org.springframework.core.annotation.Order;
import org.springframework.expression.EvaluationContext;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils;
@@ -91,7 +92,9 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
this.targetClass = targetClass;
this.bridgedMethod = BridgeMethodResolver.findBridgedMethod(method);
EventListener ann = AnnotatedElementUtils.findMergedAnnotation(method, EventListener.class);
Method targetMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
EventListener ann = AnnotatedElementUtils.findMergedAnnotation(targetMethod, EventListener.class);
this.declaredEventTypes = resolveDeclaredEventTypes(method, ann);
this.condition = (ann != null ? ann.condition() : null);
this.order = resolveOrder(method);