Interface AutowireCandidateResolver
- All Known Implementing Classes:
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.
- Since:
- 2.5
- Author:
- Juergen Hoeller, Mark Fisher
-
Method Summary
Modifier and TypeMethodDescriptiondefault AutowireCandidateResolverReturn 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 Class<?>getLazyResolutionProxyClass(DependencyDescriptor descriptor, String beanName) Determine the proxy class for lazy resolution of the dependency target, if demanded by the injection point.default ObjectgetLazyResolutionProxyIfNecessary(DependencyDescriptor descriptor, String beanName) Build a proxy for lazy resolution of the actual dependency target, if demanded by the injection point.default StringgetSuggestedName(DependencyDescriptor descriptor) Determine whether a target bean name is suggested for the given dependency (typically - but not necessarily - declared with a single-value qualifier).default ObjectgetSuggestedValue(DependencyDescriptor descriptor) Determine whether a default value is suggested for the given dependency.default booleanhasQualifier(DependencyDescriptor descriptor) Determine whether the given descriptor declares a qualifier beyond the type (typically - but not necessarily - a specific kind of annotation).default booleanisAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor) Determine whether the given bean definition qualifies as an autowire candidate for the given dependency.default booleanisRequired(DependencyDescriptor descriptor) Determine whether the given descriptor is effectively required.
-
Method Details
-
isAutowireCandidate
Determine whether the given bean definition qualifies as an autowire candidate for the given dependency.The default implementation checks
BeanDefinition.isAutowireCandidate().- Parameters:
bdHolder- the bean definition including bean name and aliasesdescriptor- the descriptor for the target method parameter or field- Returns:
- whether the bean definition qualifies as autowire candidate
- See Also:
-
isRequired
Determine whether the given descriptor is effectively required.The default implementation checks
DependencyDescriptor.isRequired().- Parameters:
descriptor- the descriptor for the target method parameter or field- Returns:
- whether the descriptor is marked as required or possibly indicating non-required status some other way (e.g. through a parameter annotation)
- Since:
- 5.0
- See Also:
-
hasQualifier
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.- Parameters:
descriptor- the descriptor for the target method parameter or field- Returns:
- whether the descriptor declares a qualifier, narrowing the candidate status beyond the type match
- Since:
- 5.1
- See Also:
-
getSuggestedName
Determine whether a target bean name is suggested for the given dependency (typically - but not necessarily - declared with a single-value qualifier).- Parameters:
descriptor- the descriptor for the target method parameter or field- Returns:
- the qualifier value, if any
- Since:
- 6.2
-
getSuggestedValue
Determine whether a default value is suggested for the given dependency.The default implementation simply returns
null.- Parameters:
descriptor- the descriptor for the target method parameter or field- Returns:
- the value suggested (typically an expression String),
or
nullif none found - Since:
- 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.- Parameters:
descriptor- the descriptor for the target method parameter or fieldbeanName- the name of the bean that contains the injection point- Returns:
- the lazy resolution proxy for the actual dependency target,
or
nullif straight resolution is to be performed - Since:
- 4.0
-
getLazyResolutionProxyClass
@Nullable default Class<?> getLazyResolutionProxyClass(DependencyDescriptor descriptor, @Nullable String beanName) Determine the proxy class for lazy resolution of the dependency target, if demanded by the injection point.The default implementation simply returns
null.- Parameters:
descriptor- the descriptor for the target method parameter or fieldbeanName- the name of the bean that contains the injection point- Returns:
- the lazy resolution proxy class for the dependency target, if any
- Since:
- 6.0
-
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
Cloneablesupport (as implemented by Spring's own configurableAutowireCandidateResolvervariants), or simply returnthis(as inSimpleAutowireCandidateResolver).
-