接口 AutowireCandidateResolver
- 所有已知实现类:
ContextAnnotationAutowireCandidateResolver
,GenericTypeAwareAutowireCandidateResolver
,QualifierAnnotationAutowireCandidateResolver
,SimpleAutowireCandidateResolver
public interface AutowireCandidateResolver
Strategy interface for determining whether a specific bean definition qualifies as an autowire candidate for a specific dependency.- 从以下版本开始:
- 2.5
- 作者:
- Juergen Hoeller, Mark Fisher
方法概要
所有方法 实例方法 默认方法 修饰符和类型 方法 说明 default AutowireCandidateResolver
cloneIfNecessary()
Return a clone of this resolver instance if necessary, retaining its local configuration and allowing for the cloned instance to get associated with a new bean factory, or this original instance if there is no such state.default Object
getLazyResolutionProxyIfNecessary(DependencyDescriptor descriptor, String beanName)
Build a proxy for lazy resolution of the actual dependency target, if demanded by the injection point.default Object
getSuggestedValue(DependencyDescriptor descriptor)
Determine whether a default value is suggested for the given dependency.default boolean
hasQualifier(DependencyDescriptor descriptor)
Determine whether the given descriptor declares a qualifier beyond the type (typically - but not necessarily - a specific kind of annotation).default boolean
isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor)
Determine whether the given bean definition qualifies as an autowire candidate for the given dependency.default boolean
isRequired(DependencyDescriptor descriptor)
Determine whether the given descriptor is effectively required.
方法详细资料
isAutowireCandidate
default boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor)
Determine whether the given bean definition qualifies as an autowire candidate for the given dependency.The default implementation checks
BeanDefinition.isAutowireCandidate()
.- 参数:
bdHolder
- the bean definition including bean name and aliasesdescriptor
- the descriptor for the target method parameter or field- 返回:
- whether the bean definition qualifies as autowire candidate
- 另请参阅:
BeanDefinition.isAutowireCandidate()
isRequired
default boolean isRequired(DependencyDescriptor descriptor)
Determine whether the given descriptor is effectively required.The default implementation checks
DependencyDescriptor.isRequired()
.- 参数:
descriptor
- the descriptor for the target method parameter or field- 返回:
- whether the descriptor is marked as required or possibly indicating non-required status some other way (e.g. through a parameter annotation)
- 从以下版本开始:
- 5.0
- 另请参阅:
DependencyDescriptor.isRequired()
hasQualifier
default boolean hasQualifier(DependencyDescriptor descriptor)
Determine whether the given descriptor declares a qualifier beyond the type (typically - but not necessarily - a specific kind of annotation).The default implementation returns
false
.- 参数:
descriptor
- the descriptor for the target method parameter or field- 返回:
- whether the descriptor declares a qualifier, narrowing the candidate status beyond the type match
- 从以下版本开始:
- 5.1
- 另请参阅:
QualifierAnnotationAutowireCandidateResolver.hasQualifier(org.springframework.beans.factory.config.DependencyDescriptor)
getSuggestedValue
@Nullable default Object getSuggestedValue(DependencyDescriptor descriptor)
Determine whether a default value is suggested for the given dependency.The default implementation simply returns
null
.- 参数:
descriptor
- the descriptor for the target method parameter or field- 返回:
- the value suggested (typically an expression String), or
null
if none found - 从以下版本开始:
- 3.0
getLazyResolutionProxyIfNecessary
@Nullable default Object getLazyResolutionProxyIfNecessary(DependencyDescriptor descriptor, @Nullable String beanName)
Build a proxy for lazy resolution of the actual dependency target, if demanded by the injection point.The default implementation simply returns
null
.- 参数:
descriptor
- the descriptor for the target method parameter or fieldbeanName
- the name of the bean that contains the injection point- 返回:
- the lazy resolution proxy for the actual dependency target, or
null
if straight resolution is to be performed - 从以下版本开始:
- 4.0
cloneIfNecessary
default AutowireCandidateResolver cloneIfNecessary()
Return a clone of this resolver instance if necessary, retaining its local configuration and allowing for the cloned instance to get associated with a new bean factory, or this original instance if there is no such state.The default implementation creates a separate instance via the default class constructor, assuming no specific configuration state to copy. Subclasses may override this with custom configuration state handling or with standard
Cloneable
support (as implemented by Spring's own configurableAutowireCandidateResolver
variants), or simply returnthis
(as inSimpleAutowireCandidateResolver
).