Package org.springframework.beans.factory.support

# Class SimpleAutowireCandidateResolver

java.lang.Object
org.springframework.beans.factory.support.SimpleAutowireCandidateResolver

All Implemented Interfaces:
  `AutowireCandidateResolver`

Direct Known Subclasses:
  `GenericTypeAwareAutowireCandidateResolver`

public class SimpleAutowireCandidateResolver extends Object implements AutowireCandidateResolver
`AutowireCandidateResolver` implementation to use when no annotation support is available. This implementation checks the bean definition only.

Since:
  2.5
Author:
  Mark Fisher, Juergen Hoeller

## Field Summary

Fields
Modifier and Type
Field
Description
`static final SimpleAutowireCandidateResolver`
`INSTANCE`
Shared instance of `SimpleAutowireCandidateResolver`.

## Constructor Summary

Constructors
Constructor
Description
`SimpleAutowireCandidateResolver()`

## Method Summary

Modifier and Type
Method
Description
`AutowireCandidateResolver`
`cloneIfNecessary()`
This implementation returns `this` as-is.
`static <T> Map<String,T>`
`resolveAutowireCandidates(ConfigurableListableBeanFactory lbf, Class<T> type)`
Resolve a map of all beans of the given type, also picking up beans defined in ancestor bean factories, with the specific condition that each bean actually has autowire candidate status.
`static <T> Map<String,T>`
`resolveAutowireCandidates(ConfigurableListableBeanFactory lbf, Class<T> type, boolean includeNonSingletons, boolean allowEagerInit)`
Resolve a map of all beans of the given type, also picking up beans defined in ancestor bean factories, with the specific condition that each bean actually has autowire candidate status.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.springframework.beans.factory.support.AutowireCandidateResolver

`getLazyResolutionProxyClass, getLazyResolutionProxyIfNecessary, getSuggestedName, getSuggestedValue, hasQualifier, isAutowireCandidate, isRequired`

## Field Details

### INSTANCE

public static final SimpleAutowireCandidateResolver INSTANCE
Shared instance of `SimpleAutowireCandidateResolver`.

Since:
  5.2.7

## Constructor Details

### SimpleAutowireCandidateResolver

public SimpleAutowireCandidateResolver()

## Method Details

### cloneIfNecessary

public AutowireCandidateResolver cloneIfNecessary()
This implementation returns `this` as-is.

Specified by:
  `cloneIfNecessary` in interface `AutowireCandidateResolver`
See Also:
  - `INSTANCE`

### resolveAutowireCandidates

public static <T> Map<String,T> resolveAutowireCandidates(ConfigurableListableBeanFactory lbf, Class<T> type)
Resolve a map of all beans of the given type, also picking up beans defined in ancestor bean factories, with the specific condition that each bean actually has autowire candidate status. This matches simple injection point resolution as implemented by this `AutowireCandidateResolver` strategy, including beans which are not marked as default candidates but excluding beans which are not even marked as autowire candidates.

Parameters:
  `lbf` - the bean factory
  `type` - the type of bean to match
Returns:
  the Map of matching bean instances, or an empty Map if none
Throws:
  `BeansException` - if a bean could not be created
Since:
  6.2.3
See Also:
  - `BeanFactoryUtils.beansOfTypeIncludingAncestors(ListableBeanFactory, Class)`
  - `BeanDefinition.isAutowireCandidate()`
  - `AbstractBeanDefinition.isDefaultCandidate()`

### resolveAutowireCandidates

public static <T> Map<String,T> resolveAutowireCandidates(ConfigurableListableBeanFactory lbf, Class<T> type, boolean includeNonSingletons, boolean allowEagerInit)
Resolve a map of all beans of the given type, also picking up beans defined in ancestor bean factories, with the specific condition that each bean actually has autowire candidate status. This matches simple injection point resolution as implemented by this `AutowireCandidateResolver` strategy, including beans which are not marked as default candidates but excluding beans which are not even marked as autowire candidates.

Parameters:
  `lbf` - the bean factory
  `type` - the type of bean to match
  `includeNonSingletons` - whether to include prototype or scoped beans too or just singletons (also applies to FactoryBeans)
  `allowEagerInit` - whether to initialize lazy-init singletons and objects created by FactoryBeans (or by factory methods with a "factory-bean" reference) for the type check. Note that FactoryBeans need to be eagerly initialized to determine their type: So be aware that passing in "true" for this flag will initialize FactoryBeans and "factory-bean" references.
Returns:
  the Map of matching bean instances, or an empty Map if none
Throws:
  `BeansException` - if a bean could not be created
Since:
  6.2.5
See Also:
  - `BeanFactoryUtils.beansOfTypeIncludingAncestors(ListableBeanFactory, Class, boolean, boolean)`
  - `BeanDefinition.isAutowireCandidate()`
  - `AbstractBeanDefinition.isDefaultCandidate()`