@@ -656,12 +656,6 @@ public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> an
656
656
return result ;
657
657
}
658
658
659
- /**
660
- * Find a {@link Annotation} of {@code annotationType} on the specified
661
- * bean, traversing its interfaces and super classes if no annotation can be
662
- * found on the given class itself, as well as checking its raw bean class
663
- * if not found on the exposed bean reference (e.g. in case of a proxy).
664
- */
665
659
@ Override
666
660
@ Nullable
667
661
public <A extends Annotation > A findAnnotationOnBean (String beanName , Class <A > annotationType )
@@ -673,14 +667,12 @@ public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> a
673
667
ann = AnnotationUtils .findAnnotation (beanType , annotationType );
674
668
}
675
669
if (ann == null && containsBeanDefinition (beanName )) {
676
- BeanDefinition bd = getMergedBeanDefinition (beanName );
677
- if (bd instanceof AbstractBeanDefinition ) {
678
- AbstractBeanDefinition abd = (AbstractBeanDefinition ) bd ;
679
- if (abd .hasBeanClass ()) {
680
- Class <?> beanClass = abd .getBeanClass ();
681
- if (beanClass != beanType ) {
682
- ann = AnnotationUtils .findAnnotation (beanClass , annotationType );
683
- }
670
+ // Check raw bean class, e.g. in case of a proxy.
671
+ RootBeanDefinition bd = getMergedLocalBeanDefinition (beanName );
672
+ if (bd .hasBeanClass ()) {
673
+ Class <?> beanClass = bd .getBeanClass ();
674
+ if (beanClass != beanType ) {
675
+ ann = AnnotationUtils .findAnnotation (beanClass , annotationType );
684
676
}
685
677
}
686
678
}
@@ -1975,10 +1967,11 @@ public FactoryAwareOrderSourceProvider(Map<Object, String> instancesToBeanNames)
1975
1967
@ Override
1976
1968
@ Nullable
1977
1969
public Object getOrderSource (Object obj ) {
1978
- RootBeanDefinition beanDefinition = getRootBeanDefinition ( this .instancesToBeanNames .get (obj ) );
1979
- if (beanDefinition == null ) {
1970
+ String beanName = this .instancesToBeanNames .get (obj );
1971
+ if (beanName == null || ! containsBeanDefinition ( beanName ) ) {
1980
1972
return null ;
1981
1973
}
1974
+ RootBeanDefinition beanDefinition = getMergedLocalBeanDefinition (beanName );
1982
1975
List <Object > sources = new ArrayList <>(2 );
1983
1976
Method factoryMethod = beanDefinition .getResolvedFactoryMethod ();
1984
1977
if (factoryMethod != null ) {
@@ -1990,17 +1983,6 @@ public Object getOrderSource(Object obj) {
1990
1983
}
1991
1984
return sources .toArray ();
1992
1985
}
1993
-
1994
- @ Nullable
1995
- private RootBeanDefinition getRootBeanDefinition (@ Nullable String beanName ) {
1996
- if (beanName != null && containsBeanDefinition (beanName )) {
1997
- BeanDefinition bd = getMergedBeanDefinition (beanName );
1998
- if (bd instanceof RootBeanDefinition ) {
1999
- return (RootBeanDefinition ) bd ;
2000
- }
2001
- }
2002
- return null ;
2003
- }
2004
1986
}
2005
1987
2006
1988
}
0 commit comments