public class DefaultListableBeanFactory extends org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory implements org.springframework.beans.factory.config.ConfigurableListableBeanFactory, org.springframework.beans.factory.support.BeanDefinitionRegistry, Serializable
StaticListableBeanFactory
,
PropertiesBeanDefinitionReader
,
XmlBeanDefinitionReader
,
Serialized Formlogger, NULL_OBJECT
AUTOWIRE_AUTODETECT, AUTOWIRE_BY_NAME, AUTOWIRE_BY_TYPE, AUTOWIRE_CONSTRUCTOR, AUTOWIRE_NO
Constructor and Description |
---|
DefaultListableBeanFactory()
Create a new DefaultListableBeanFactory.
|
DefaultListableBeanFactory(org.springframework.beans.factory.BeanFactory parentBeanFactory)
Create a new DefaultListableBeanFactory with the given parent.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
allowAliasOverriding()
Only allows alias overriding if bean definition overriding is allowed.
|
boolean |
containsBeanDefinition(String beanName) |
void |
copyConfigurationFrom(org.springframework.beans.factory.config.ConfigurableBeanFactory otherFactory) |
void |
destroySingleton(String beanName) |
void |
destroySingletons() |
protected String |
determineAutowireCandidate(Map<String,Object> candidateBeans,
org.springframework.beans.factory.config.DependencyDescriptor descriptor)
Determine the autowire candidate in the given set of beans.
|
protected String |
determineHighestPriorityCandidate(Map<String,Object> candidateBeans,
Class<?> requiredType)
Determine the candidate with the highest priority in the given set of beans.
|
protected String |
determinePrimaryCandidate(Map<String,Object> candidateBeans,
Class<?> requiredType)
Determine the primary candidate in the given set of beans.
|
Object |
doResolveDependency(org.springframework.beans.factory.config.DependencyDescriptor descriptor,
String beanName,
Set<String> autowiredBeanNames,
org.springframework.beans.TypeConverter typeConverter) |
<A extends Annotation> |
findAnnotationOnBean(String beanName,
Class<A> annotationType)
Find a
Annotation of annotationType on the specified
bean, traversing its interfaces and super classes if no annotation can be
found on the given class itself, as well as checking its raw bean class
if not found on the exposed bean reference (e.g. |
protected Map<String,Object> |
findAutowireCandidates(String beanName,
Class<?> requiredType,
org.springframework.beans.factory.config.DependencyDescriptor descriptor)
Find bean instances that match the required type.
|
void |
freezeConfiguration() |
org.springframework.beans.factory.support.AutowireCandidateResolver |
getAutowireCandidateResolver()
Return the autowire candidate resolver for this BeanFactory (never
null ). |
<T> T |
getBean(Class<T> requiredType) |
<T> T |
getBean(Class<T> requiredType,
Object... args) |
org.springframework.beans.factory.config.BeanDefinition |
getBeanDefinition(String beanName) |
int |
getBeanDefinitionCount() |
String[] |
getBeanDefinitionNames() |
String[] |
getBeanNamesForAnnotation(Class<? extends Annotation> annotationType) |
String[] |
getBeanNamesForType(Class<?> type) |
String[] |
getBeanNamesForType(Class<?> type,
boolean includeNonSingletons,
boolean allowEagerInit) |
Iterator<String> |
getBeanNamesIterator() |
<T> Map<String,T> |
getBeansOfType(Class<T> type) |
<T> Map<String,T> |
getBeansOfType(Class<T> type,
boolean includeNonSingletons,
boolean allowEagerInit) |
Map<String,Object> |
getBeansWithAnnotation(Class<? extends Annotation> annotationType) |
Comparator<Object> |
getDependencyComparator()
Return the dependency comparator for this BeanFactory (may be
null . |
protected Integer |
getPriority(Object beanInstance)
Return the priority assigned for the given bean instance by
the
javax.annotation.Priority annotation. |
String |
getSerializationId()
Return an id for serialization purposes, if specified, allowing this BeanFactory
to be deserialized from this id back into the BeanFactory object, if needed.
|
boolean |
isAllowBeanDefinitionOverriding()
Return whether it should be allowed to override bean definitions by registering
a different definition with the same name, automatically replacing the former.
|
boolean |
isAllowEagerClassLoading()
Return whether the factory is allowed to eagerly load bean classes
even for bean definitions that are marked as "lazy-init".
|
boolean |
isAutowireCandidate(String beanName,
org.springframework.beans.factory.config.DependencyDescriptor descriptor) |
protected boolean |
isAutowireCandidate(String beanName,
org.springframework.beans.factory.config.DependencyDescriptor descriptor,
org.springframework.beans.factory.support.AutowireCandidateResolver resolver)
Determine whether the specified bean definition qualifies as an autowire candidate,
to be injected into other beans which declare a dependency of matching type.
|
protected boolean |
isAutowireCandidate(String beanName,
org.springframework.beans.factory.support.RootBeanDefinition mbd,
org.springframework.beans.factory.config.DependencyDescriptor descriptor,
org.springframework.beans.factory.support.AutowireCandidateResolver resolver)
Determine whether the specified bean definition qualifies as an autowire candidate,
to be injected into other beans which declare a dependency of matching type.
|
protected boolean |
isBeanEligibleForMetadataCaching(String beanName)
Considers all beans as eligible for metadata caching
if the factory's configuration has been marked as frozen.
|
boolean |
isConfigurationFrozen() |
protected boolean |
isPrimary(String beanName,
Object beanInstance)
Return whether the bean definition for the given bean name has been
marked as a primary bean.
|
protected boolean |
matchesBeanName(String beanName,
String candidateName)
Determine whether the given candidate name matches the bean name or the aliases
stored in this bean definition.
|
void |
preInstantiateSingletons() |
void |
registerBeanDefinition(String beanName,
org.springframework.beans.factory.config.BeanDefinition beanDefinition) |
void |
registerResolvableDependency(Class<?> dependencyType,
Object autowiredValue) |
void |
registerSingleton(String beanName,
Object singletonObject) |
void |
removeBeanDefinition(String beanName) |
protected void |
resetBeanDefinition(String beanName)
Reset all bean definition caches for the given bean,
including the caches of beans that are derived from it.
|
Object |
resolveDependency(org.springframework.beans.factory.config.DependencyDescriptor descriptor,
String beanName,
Set<String> autowiredBeanNames,
org.springframework.beans.TypeConverter typeConverter) |
void |
setAllowBeanDefinitionOverriding(boolean allowBeanDefinitionOverriding)
Set whether it should be allowed to override bean definitions by registering
a different definition with the same name, automatically replacing the former.
|
void |
setAllowEagerClassLoading(boolean allowEagerClassLoading)
Set whether the factory is allowed to eagerly load bean classes
even for bean definitions that are marked as "lazy-init".
|
void |
setAutowireCandidateResolver(org.springframework.beans.factory.support.AutowireCandidateResolver autowireCandidateResolver)
Set a custom autowire candidate resolver for this BeanFactory to use
when deciding whether a bean definition should be considered as a
candidate for autowiring.
|
void |
setDependencyComparator(Comparator<Object> dependencyComparator)
Set a
Comparator for dependency Lists and arrays. |
void |
setSerializationId(String serializationId)
Specify an id for serialization purposes, allowing this BeanFactory to be
deserialized from this id back into the BeanFactory object, if needed.
|
String |
toString() |
protected Object |
writeReplace() |
applyBeanPostProcessorsAfterInitialization, applyBeanPostProcessorsBeforeInitialization, applyBeanPostProcessorsBeforeInstantiation, applyBeanPropertyValues, applyMergedBeanDefinitionPostProcessors, applyPropertyValues, autowire, autowireBean, autowireBeanProperties, autowireByName, autowireByType, autowireConstructor, checkDependencies, configureBean, createBean, createBean, createBean, createBeanInstance, destroyBean, determineConstructorsFromBeanPostProcessors, determineTargetType, doCreateBean, filterPropertyDescriptorsForDependencyCheck, filterPropertyDescriptorsForDependencyCheck, getEarlyBeanReference, getInstantiationStrategy, getParameterNameDiscoverer, getTypeForFactoryBean, getTypeForFactoryMethod, ignoreDependencyInterface, ignoreDependencyType, initializeBean, initializeBean, instantiateBean, instantiateUsingFactoryMethod, invokeCustomInitMethod, invokeInitMethods, isExcludedFromDependencyCheck, populateBean, postProcessObjectFromFactoryBean, predictBeanType, removeSingleton, resolveBeforeInstantiation, resolveDependency, setAllowCircularReferences, setAllowRawInjectionDespiteWrapping, setInstantiationStrategy, setParameterNameDiscoverer, unsatisfiedNonSimpleProperties
addBeanPostProcessor, addEmbeddedValueResolver, addPropertyEditorRegistrar, afterPrototypeCreation, beforePrototypeCreation, checkMergedBeanDefinition, cleanupAfterBeanCreationFailure, clearMergedBeanDefinition, containsBean, containsLocalBean, copyRegisteredEditorsTo, destroyBean, destroyBean, destroyScopedBean, doGetBean, evaluateBeanDefinitionString, getAccessControlContext, getAliases, getBean, getBean, getBean, getBean, getBeanClassLoader, getBeanExpressionResolver, getBeanPostProcessorCount, getBeanPostProcessors, getConversionService, getCustomEditors, getCustomTypeConverter, getMergedBeanDefinition, getMergedBeanDefinition, getMergedBeanDefinition, getMergedLocalBeanDefinition, getObjectForBeanInstance, getParentBeanFactory, getPropertyEditorRegistrars, getRegisteredScope, getRegisteredScopeNames, getTempClassLoader, getType, getTypeConverter, hasDestructionAwareBeanPostProcessors, hasInstantiationAwareBeanPostProcessors, initBeanWrapper, isActuallyInCreation, isBeanNameInUse, isCacheBeanMetadata, isFactoryBean, isFactoryBean, isPrototype, isPrototypeCurrentlyInCreation, isSingleton, isTypeMatch, markBeanAsCreated, originalBeanName, registerCustomEditor, registerCustomEditors, registerDisposableBeanIfNecessary, registerScope, removeSingletonIfCreatedForTypeCheckOnly, requiresDestruction, resolveBeanClass, resolveEmbeddedValue, setBeanClassLoader, setBeanExpressionResolver, setCacheBeanMetadata, setConversionService, setParentBeanFactory, setSecurityContextProvider, setTempClassLoader, setTypeConverter, transformedBeanName
getCachedObjectForFactoryBean, getFactoryBean, getObjectFromFactoryBean, getTypeForFactoryBean
addSingleton, addSingletonFactory, afterSingletonCreation, beforeSingletonCreation, containsSingleton, destroyBean, getDependenciesForBean, getDependentBeans, getSingleton, getSingleton, getSingleton, getSingletonCount, getSingletonMutex, getSingletonNames, hasDependentBean, isCurrentlyInCreation, isDependent, isSingletonCurrentlyInCreation, onSuppressedException, registerContainedBean, registerDependentBean, registerDisposableBean, setCurrentlyInCreation
canonicalName, checkForAliasCircle, isAlias, registerAlias, removeAlias, resolveAliases
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
ignoreDependencyInterface, ignoreDependencyType
applyBeanPostProcessorsAfterInitialization, applyBeanPostProcessorsBeforeInitialization, applyBeanPropertyValues, autowire, autowireBean, autowireBeanProperties, configureBean, createBean, createBean, destroyBean, initializeBean, resolveDependency
addBeanPostProcessor, addEmbeddedValueResolver, addPropertyEditorRegistrar, copyRegisteredEditorsTo, destroyBean, destroyScopedBean, getAccessControlContext, getBeanClassLoader, getBeanExpressionResolver, getBeanPostProcessorCount, getConversionService, getDependenciesForBean, getDependentBeans, getMergedBeanDefinition, getRegisteredScope, getRegisteredScopeNames, getTempClassLoader, getTypeConverter, isCacheBeanMetadata, isCurrentlyInCreation, isFactoryBean, registerAlias, registerCustomEditor, registerDependentBean, registerScope, resolveAliases, resolveEmbeddedValue, setBeanClassLoader, setBeanExpressionResolver, setCacheBeanMetadata, setConversionService, setCurrentlyInCreation, setParentBeanFactory, setTempClassLoader, setTypeConverter
containsLocalBean, getParentBeanFactory
containsBean, getAliases, getBean, getBean, getBean, getType, isPrototype, isSingleton, isTypeMatch
containsSingleton, getSingleton, getSingletonCount, getSingletonNames
public DefaultListableBeanFactory()
public DefaultListableBeanFactory(org.springframework.beans.factory.BeanFactory parentBeanFactory)
parentBeanFactory
- the parent BeanFactorypublic void setSerializationId(String serializationId)
public String getSerializationId()
public void setAllowBeanDefinitionOverriding(boolean allowBeanDefinitionOverriding)
Default is "true".
public boolean isAllowBeanDefinitionOverriding()
public void setAllowEagerClassLoading(boolean allowEagerClassLoading)
Default is "true". Turn this flag off to suppress class loading for lazy-init beans unless such a bean is explicitly requested. In particular, by-type lookups will then simply ignore bean definitions without resolved class name, instead of loading the bean classes on demand just to perform a type check.
AbstractBeanDefinition.setLazyInit(boolean)
public boolean isAllowEagerClassLoading()
public void setDependencyComparator(Comparator<Object> dependencyComparator)
Comparator
for dependency Lists and arrays.OrderComparator
,
AnnotationAwareOrderComparator
public Comparator<Object> getDependencyComparator()
null
.public void setAutowireCandidateResolver(org.springframework.beans.factory.support.AutowireCandidateResolver autowireCandidateResolver)
public org.springframework.beans.factory.support.AutowireCandidateResolver getAutowireCandidateResolver()
null
).public void copyConfigurationFrom(org.springframework.beans.factory.config.ConfigurableBeanFactory otherFactory)
copyConfigurationFrom
in interface org.springframework.beans.factory.config.ConfigurableBeanFactory
copyConfigurationFrom
in class org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
public <T> T getBean(Class<T> requiredType) throws org.springframework.beans.BeansException
getBean
in interface org.springframework.beans.factory.BeanFactory
org.springframework.beans.BeansException
public <T> T getBean(Class<T> requiredType, Object... args) throws org.springframework.beans.BeansException
getBean
in interface org.springframework.beans.factory.BeanFactory
org.springframework.beans.BeansException
public boolean containsBeanDefinition(String beanName)
containsBeanDefinition
in interface org.springframework.beans.factory.ListableBeanFactory
containsBeanDefinition
in interface org.springframework.beans.factory.support.BeanDefinitionRegistry
containsBeanDefinition
in class org.springframework.beans.factory.support.AbstractBeanFactory
public int getBeanDefinitionCount()
getBeanDefinitionCount
in interface org.springframework.beans.factory.ListableBeanFactory
getBeanDefinitionCount
in interface org.springframework.beans.factory.support.BeanDefinitionRegistry
public String[] getBeanDefinitionNames()
getBeanDefinitionNames
in interface org.springframework.beans.factory.ListableBeanFactory
getBeanDefinitionNames
in interface org.springframework.beans.factory.support.BeanDefinitionRegistry
public String[] getBeanNamesForType(Class<?> type)
getBeanNamesForType
in interface org.springframework.beans.factory.ListableBeanFactory
public String[] getBeanNamesForType(Class<?> type, boolean includeNonSingletons, boolean allowEagerInit)
getBeanNamesForType
in interface org.springframework.beans.factory.ListableBeanFactory
public <T> Map<String,T> getBeansOfType(Class<T> type) throws org.springframework.beans.BeansException
getBeansOfType
in interface org.springframework.beans.factory.ListableBeanFactory
org.springframework.beans.BeansException
public <T> Map<String,T> getBeansOfType(Class<T> type, boolean includeNonSingletons, boolean allowEagerInit) throws org.springframework.beans.BeansException
getBeansOfType
in interface org.springframework.beans.factory.ListableBeanFactory
org.springframework.beans.BeansException
public String[] getBeanNamesForAnnotation(Class<? extends Annotation> annotationType)
getBeanNamesForAnnotation
in interface org.springframework.beans.factory.ListableBeanFactory
public Map<String,Object> getBeansWithAnnotation(Class<? extends Annotation> annotationType)
getBeansWithAnnotation
in interface org.springframework.beans.factory.ListableBeanFactory
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
Annotation
of annotationType
on the specified
bean, traversing its interfaces and super classes if no annotation can be
found on the given class itself, as well as checking its raw bean class
if not found on the exposed bean reference (e.g. in case of a proxy).findAnnotationOnBean
in interface org.springframework.beans.factory.ListableBeanFactory
org.springframework.beans.factory.NoSuchBeanDefinitionException
public void registerResolvableDependency(Class<?> dependencyType, Object autowiredValue)
registerResolvableDependency
in interface org.springframework.beans.factory.config.ConfigurableListableBeanFactory
public boolean isAutowireCandidate(String beanName, org.springframework.beans.factory.config.DependencyDescriptor descriptor) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
isAutowireCandidate
in interface org.springframework.beans.factory.config.ConfigurableListableBeanFactory
org.springframework.beans.factory.NoSuchBeanDefinitionException
protected boolean isAutowireCandidate(String beanName, org.springframework.beans.factory.config.DependencyDescriptor descriptor, org.springframework.beans.factory.support.AutowireCandidateResolver resolver) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
beanName
- the name of the bean definition to checkdescriptor
- the descriptor of the dependency to resolveresolver
- the AutowireCandidateResolver to use for the actual resolution algorithmorg.springframework.beans.factory.NoSuchBeanDefinitionException
protected boolean isAutowireCandidate(String beanName, org.springframework.beans.factory.support.RootBeanDefinition mbd, org.springframework.beans.factory.config.DependencyDescriptor descriptor, org.springframework.beans.factory.support.AutowireCandidateResolver resolver)
beanName
- the name of the bean definition to checkmbd
- the merged bean definition to checkdescriptor
- the descriptor of the dependency to resolveresolver
- the AutowireCandidateResolver to use for the actual resolution algorithmpublic org.springframework.beans.factory.config.BeanDefinition getBeanDefinition(String beanName) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
getBeanDefinition
in interface org.springframework.beans.factory.config.ConfigurableListableBeanFactory
getBeanDefinition
in interface org.springframework.beans.factory.support.BeanDefinitionRegistry
getBeanDefinition
in class org.springframework.beans.factory.support.AbstractBeanFactory
org.springframework.beans.factory.NoSuchBeanDefinitionException
public Iterator<String> getBeanNamesIterator()
getBeanNamesIterator
in interface org.springframework.beans.factory.config.ConfigurableListableBeanFactory
public void freezeConfiguration()
freezeConfiguration
in interface org.springframework.beans.factory.config.ConfigurableListableBeanFactory
public boolean isConfigurationFrozen()
isConfigurationFrozen
in interface org.springframework.beans.factory.config.ConfigurableListableBeanFactory
protected boolean isBeanEligibleForMetadataCaching(String beanName)
isBeanEligibleForMetadataCaching
in class org.springframework.beans.factory.support.AbstractBeanFactory
freezeConfiguration()
public void preInstantiateSingletons() throws org.springframework.beans.BeansException
preInstantiateSingletons
in interface org.springframework.beans.factory.config.ConfigurableListableBeanFactory
org.springframework.beans.BeansException
public void registerBeanDefinition(String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition) throws org.springframework.beans.factory.BeanDefinitionStoreException
registerBeanDefinition
in interface org.springframework.beans.factory.support.BeanDefinitionRegistry
org.springframework.beans.factory.BeanDefinitionStoreException
public void removeBeanDefinition(String beanName) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
removeBeanDefinition
in interface org.springframework.beans.factory.support.BeanDefinitionRegistry
org.springframework.beans.factory.NoSuchBeanDefinitionException
protected void resetBeanDefinition(String beanName)
beanName
- the name of the bean to resetprotected boolean allowAliasOverriding()
allowAliasOverriding
in class org.springframework.core.SimpleAliasRegistry
public void registerSingleton(String beanName, Object singletonObject) throws IllegalStateException
registerSingleton
in interface org.springframework.beans.factory.config.SingletonBeanRegistry
registerSingleton
in class org.springframework.beans.factory.support.DefaultSingletonBeanRegistry
IllegalStateException
public void destroySingleton(String beanName)
destroySingleton
in class org.springframework.beans.factory.support.DefaultSingletonBeanRegistry
public void destroySingletons()
destroySingletons
in interface org.springframework.beans.factory.config.ConfigurableBeanFactory
destroySingletons
in class org.springframework.beans.factory.support.DefaultSingletonBeanRegistry
public Object resolveDependency(org.springframework.beans.factory.config.DependencyDescriptor descriptor, String beanName, Set<String> autowiredBeanNames, org.springframework.beans.TypeConverter typeConverter) throws org.springframework.beans.BeansException
resolveDependency
in interface org.springframework.beans.factory.config.AutowireCapableBeanFactory
org.springframework.beans.BeansException
public Object doResolveDependency(org.springframework.beans.factory.config.DependencyDescriptor descriptor, String beanName, Set<String> autowiredBeanNames, org.springframework.beans.TypeConverter typeConverter) throws org.springframework.beans.BeansException
org.springframework.beans.BeansException
protected Map<String,Object> findAutowireCandidates(String beanName, Class<?> requiredType, org.springframework.beans.factory.config.DependencyDescriptor descriptor)
beanName
- the name of the bean that is about to be wiredrequiredType
- the actual type of bean to look for
(may be an array component type or collection element type)descriptor
- the descriptor of the dependency to resolvenull
)org.springframework.beans.BeansException
- in case of errorsAbstractAutowireCapableBeanFactory.autowireByType(java.lang.String, org.springframework.beans.factory.support.AbstractBeanDefinition, org.springframework.beans.BeanWrapper, org.springframework.beans.MutablePropertyValues)
,
AbstractAutowireCapableBeanFactory.autowireConstructor(java.lang.String, org.springframework.beans.factory.support.RootBeanDefinition, java.lang.reflect.Constructor<?>[], java.lang.Object[])
protected String determineAutowireCandidate(Map<String,Object> candidateBeans, org.springframework.beans.factory.config.DependencyDescriptor descriptor)
Looks for @Primary
and @Priority
(in that order).
candidateBeans
- a Map of candidate names and candidate instances
that match the required type, as returned by findAutowireCandidates(java.lang.String, java.lang.Class<?>, org.springframework.beans.factory.config.DependencyDescriptor)
descriptor
- the target dependency to match againstnull
if none foundprotected String determinePrimaryCandidate(Map<String,Object> candidateBeans, Class<?> requiredType)
candidateBeans
- a Map of candidate names and candidate instances
that match the required typerequiredType
- the target dependency type to match againstnull
if none foundisPrimary(String, Object)
protected String determineHighestPriorityCandidate(Map<String,Object> candidateBeans, Class<?> requiredType)
Ordered
interface, the lowest
value has the highest priority.candidateBeans
- a Map of candidate names and candidate instances
that match the required typerequiredType
- the target dependency type to match againstnull
if none foundgetPriority(Object)
protected boolean isPrimary(String beanName, Object beanInstance)
beanName
- the name of the beanbeanInstance
- the corresponding bean instance (can be null)protected Integer getPriority(Object beanInstance)
javax.annotation.Priority
annotation.
The default implementation delegates to the specified
dependency comparator
, checking its
method
if it is an extension of
Spring's common OrderComparator
- typically, an
AnnotationAwareOrderComparator
.
If no such comparator is present, this implementation returns null
.
beanInstance
- the bean instance to check (can be null
)null
if none is setprotected boolean matchesBeanName(String beanName, String candidateName)
protected Object writeReplace() throws ObjectStreamException
ObjectStreamException
Copyright © 2003–2016 MuleSoft, Inc.. All rights reserved.