Avoid unnecessary annotation introspection on framework methods
Issue: SPR-16933
This commit is contained in:
@@ -189,8 +189,8 @@ class ConfigurationClassEnhancer {
|
||||
@Override
|
||||
public int accept(Method method) {
|
||||
for (int i = 0; i < this.callbacks.length; i++) {
|
||||
if (!(this.callbacks[i] instanceof ConditionalCallback) ||
|
||||
((ConditionalCallback) this.callbacks[i]).isMatch(method)) {
|
||||
Callback callback = this.callbacks[i];
|
||||
if (!(callback instanceof ConditionalCallback) || ((ConditionalCallback) callback).isMatch(method)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -286,6 +286,10 @@ class ConfigurationClassEnhancer {
|
||||
|
||||
@Override
|
||||
public boolean isMatch(Method candidateMethod) {
|
||||
return isSetBeanFactory(candidateMethod);
|
||||
}
|
||||
|
||||
public static boolean isSetBeanFactory(Method candidateMethod) {
|
||||
return (candidateMethod.getName().equals("setBeanFactory") &&
|
||||
candidateMethod.getParameterCount() == 1 &&
|
||||
BeanFactory.class == candidateMethod.getParameterTypes()[0] &&
|
||||
@@ -432,6 +436,7 @@ class ConfigurationClassEnhancer {
|
||||
@Override
|
||||
public boolean isMatch(Method candidateMethod) {
|
||||
return (candidateMethod.getDeclaringClass() != Object.class &&
|
||||
!BeanFactoryAwareMethodInterceptor.isSetBeanFactory(candidateMethod) &&
|
||||
BeanAnnotationHelper.isBeanAnnotated(candidateMethod));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user