Introduced support for @Lazy on injection points

This turned into a rather huge affair since it led to the introduction of a new AutowireCandidateResolver implementation in the spring-context module. That ACR impl is now being set through AnnotationConfigUtils; GenericApplicationContext and co do not set a default QualifierAnnotationAutowireCandidateResolver anymore (which has always been a smell anyway).  At the same time, dependency ordering has moved from AutowiredAnnotationBeanPostProcessor to DefaultListableBeanFactory itself through a "dependencyComparator" strategy, applying to constructor dependencies and lazy resolution proxies as well.

Issue: SPR-10353
This commit is contained in:
Juergen Hoeller
2013-08-28 00:14:39 +02:00
parent 01b8d9327d
commit 4447248a83
16 changed files with 554 additions and 49 deletions

View File

@@ -164,7 +164,7 @@ public class MethodParameter {
* Returns the wrapped member.
* @return the Method or Constructor as Member
*/
private Member getMember() {
public Member getMember() {
// NOTE: no ternary expression to retain JDK <8 compatibility even when using
// the JDK 8 compiler (potentially selecting java.lang.reflect.Executable
// as common type, with that new base class not available on older JDKs)
@@ -180,7 +180,7 @@ public class MethodParameter {
* Returns the wrapped annotated element.
* @return the Method or Constructor as AnnotatedElement
*/
private AnnotatedElement getAnnotatedElement() {
public AnnotatedElement getAnnotatedElement() {
// NOTE: no ternary expression to retain JDK <8 compatibility even when using
// the JDK 8 compiler (potentially selecting java.lang.reflect.Executable
// as common type, with that new base class not available on older JDKs)

View File

@@ -55,6 +55,22 @@ public abstract class AnnotationUtils {
private static final Map<Class<?>, Boolean> annotatedInterfaceCache = new WeakHashMap<Class<?>, Boolean>();
/**
* Get a single {@link Annotation} of {@code annotationType} from the supplied
* annotation: either the given annotation itself or a meta-annotation thereof.
* @param ann the Annotation to check
* @param annotationType the annotation class to look for, both locally and as a meta-annotation
* @return the matching annotation or {@code null} if not found
* @since 4.0
*/
@SuppressWarnings("unchecked")
public static <T extends Annotation> T getAnnotation(Annotation ann, Class<T> annotationType) {
if (annotationType.isInstance(ann)) {
return (T) ann;
}
return ann.annotationType().getAnnotation(annotationType);
}
/**
* Get a single {@link Annotation} of {@code annotationType} from the supplied
* Method, Constructor or Field. Meta-annotations will be searched if the annotation
@@ -98,16 +114,7 @@ public abstract class AnnotationUtils {
*/
public static <A extends Annotation> A getAnnotation(Method method, Class<A> annotationType) {
Method resolvedMethod = BridgeMethodResolver.findBridgedMethod(method);
A ann = resolvedMethod.getAnnotation(annotationType);
if (ann == null) {
for (Annotation metaAnn : resolvedMethod.getAnnotations()) {
ann = metaAnn.annotationType().getAnnotation(annotationType);
if (ann != null) {
break;
}
}
}
return ann;
return getAnnotation((AnnotatedElement) resolvedMethod, annotationType);
}
/**