Introduce getLazyResolutionProxyClass mechanism in AutowireCandidateResolver SPI

See gh-28980
This commit is contained in:
Juergen Hoeller
2022-08-22 16:24:37 +02:00
parent 8a51e31069
commit 4eb84a0537
3 changed files with 38 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 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.
@@ -100,6 +100,20 @@ public interface AutowireCandidateResolver {
return null;
}
/**
* Determine the proxy class for lazy resolution of the dependency target,
* if demanded by the injection point.
* <p>The default implementation simply returns {@code null}.
* @param descriptor the descriptor for the target method parameter or field
* @param beanName the name of the bean that contains the injection point
* @return the lazy resolution proxy class for the dependency target, if any
* @since 6.0
*/
@Nullable
default Class<?> getLazyResolutionProxyClass(DependencyDescriptor descriptor, @Nullable String beanName) {
return null;
}
/**
* Return a clone of this resolver instance if necessary, retaining its local
* configuration and allowing for the cloned instance to get associated with

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 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.
@@ -64,6 +64,12 @@ public class SimpleAutowireCandidateResolver implements AutowireCandidateResolve
return null;
}
@Override
@Nullable
public Class<?> getLazyResolutionProxyClass(DependencyDescriptor descriptor, @Nullable String beanName) {
return null;
}
/**
* This implementation returns {@code this} as-is.
* @see #INSTANCE