@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2015 the original author or authors .
* Copyright 2002 - 2016 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -41,6 +41,7 @@ import org.springframework.core.MethodIntrospector;
@@ -41,6 +41,7 @@ import org.springframework.core.MethodIntrospector;
import org.springframework.core.annotation.AnnotationAwareOrderComparator ;
import org.springframework.core.annotation.AnnotationUtils ;
import org.springframework.util.Assert ;
import org.springframework.util.CollectionUtils ;
/ * *
* Register { @link EventListener } annotated method as individual { @link ApplicationListener }
@ -124,14 +125,23 @@ public class EventListenerMethodProcessor implements SmartInitializingSingleton,
@@ -124,14 +125,23 @@ public class EventListenerMethodProcessor implements SmartInitializingSingleton,
protected void processBean ( final List < EventListenerFactory > factories , final String beanName , final Class < ? > targetType ) {
if ( ! this . nonAnnotatedClasses . contains ( targetType ) ) {
Map < Method , EventListener > annotatedMethods = MethodIntrospector . selectMethods ( targetType ,
new MethodIntrospector . MetadataLookup < EventListener > ( ) {
@Override
public EventListener inspect ( Method method ) {
return AnnotationUtils . findAnnotation ( method , EventListener . class ) ;
}
} ) ;
if ( annotatedMethods . isEmpty ( ) ) {
Map < Method , EventListener > annotatedMethods = null ;
try {
annotatedMethods = MethodIntrospector . selectMethods ( targetType ,
new MethodIntrospector . MetadataLookup < EventListener > ( ) {
@Override
public EventListener inspect ( Method method ) {
return AnnotationUtils . findAnnotation ( method , EventListener . class ) ;
}
} ) ;
}
catch ( Throwable ex ) {
// An unresolvable type in a method signature, probably from a lazy bean - let's ignore it.
if ( logger . isDebugEnabled ( ) ) {
logger . debug ( "Could not resolve methods for bean with name '" + beanName + "'" , ex ) ;
}
}
if ( CollectionUtils . isEmpty ( annotatedMethods ) ) {
this . nonAnnotatedClasses . add ( targetType ) ;
if ( logger . isTraceEnabled ( ) ) {
logger . trace ( "No @EventListener annotations found on bean class: " + targetType ) ;