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_OBJECTAUTOWIRE_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, unsatisfiedNonSimplePropertiesaddBeanPostProcessor, 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, transformedBeanNamegetCachedObjectForFactoryBean, getFactoryBean, getObjectFromFactoryBean, getTypeForFactoryBeanaddSingleton, addSingletonFactory, afterSingletonCreation, beforeSingletonCreation, containsSingleton, destroyBean, getDependenciesForBean, getDependentBeans, getSingleton, getSingleton, getSingleton, getSingletonCount, getSingletonMutex, getSingletonNames, hasDependentBean, isCurrentlyInCreation, isDependent, isSingletonCurrentlyInCreation, onSuppressedException, registerContainedBean, registerDependentBean, registerDisposableBean, setCurrentlyInCreationcanonicalName, checkForAliasCircle, isAlias, registerAlias, removeAlias, resolveAliasesclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitignoreDependencyInterface, ignoreDependencyTypeapplyBeanPostProcessorsAfterInitialization, applyBeanPostProcessorsBeforeInitialization, applyBeanPropertyValues, autowire, autowireBean, autowireBeanProperties, configureBean, createBean, createBean, destroyBean, initializeBean, resolveDependencyaddBeanPostProcessor, 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, setTypeConvertercontainsLocalBean, getParentBeanFactorycontainsBean, getAliases, getBean, getBean, getBean, getType, isPrototype, isSingleton, isTypeMatchcontainsSingleton, getSingleton, getSingletonCount, getSingletonNamespublic 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,
AnnotationAwareOrderComparatorpublic 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.ConfigurableBeanFactorycopyConfigurationFrom in class org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactorypublic <T> T getBean(Class<T> requiredType) throws org.springframework.beans.BeansException
getBean in interface org.springframework.beans.factory.BeanFactoryorg.springframework.beans.BeansExceptionpublic <T> T getBean(Class<T> requiredType, Object... args) throws org.springframework.beans.BeansException
getBean in interface org.springframework.beans.factory.BeanFactoryorg.springframework.beans.BeansExceptionpublic boolean containsBeanDefinition(String beanName)
containsBeanDefinition in interface org.springframework.beans.factory.ListableBeanFactorycontainsBeanDefinition in interface org.springframework.beans.factory.support.BeanDefinitionRegistrycontainsBeanDefinition in class org.springframework.beans.factory.support.AbstractBeanFactorypublic int getBeanDefinitionCount()
getBeanDefinitionCount in interface org.springframework.beans.factory.ListableBeanFactorygetBeanDefinitionCount in interface org.springframework.beans.factory.support.BeanDefinitionRegistrypublic String[] getBeanDefinitionNames()
getBeanDefinitionNames in interface org.springframework.beans.factory.ListableBeanFactorygetBeanDefinitionNames in interface org.springframework.beans.factory.support.BeanDefinitionRegistrypublic String[] getBeanNamesForType(Class<?> type)
getBeanNamesForType in interface org.springframework.beans.factory.ListableBeanFactorypublic String[] getBeanNamesForType(Class<?> type, boolean includeNonSingletons, boolean allowEagerInit)
getBeanNamesForType in interface org.springframework.beans.factory.ListableBeanFactorypublic <T> Map<String,T> getBeansOfType(Class<T> type) throws org.springframework.beans.BeansException
getBeansOfType in interface org.springframework.beans.factory.ListableBeanFactoryorg.springframework.beans.BeansExceptionpublic <T> Map<String,T> getBeansOfType(Class<T> type, boolean includeNonSingletons, boolean allowEagerInit) throws org.springframework.beans.BeansException
getBeansOfType in interface org.springframework.beans.factory.ListableBeanFactoryorg.springframework.beans.BeansExceptionpublic String[] getBeanNamesForAnnotation(Class<? extends Annotation> annotationType)
getBeanNamesForAnnotation in interface org.springframework.beans.factory.ListableBeanFactorypublic Map<String,Object> getBeansWithAnnotation(Class<? extends Annotation> annotationType)
getBeansWithAnnotation in interface org.springframework.beans.factory.ListableBeanFactorypublic <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.ListableBeanFactoryorg.springframework.beans.factory.NoSuchBeanDefinitionExceptionpublic void registerResolvableDependency(Class<?> dependencyType, Object autowiredValue)
registerResolvableDependency in interface org.springframework.beans.factory.config.ConfigurableListableBeanFactorypublic 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.ConfigurableListableBeanFactoryorg.springframework.beans.factory.NoSuchBeanDefinitionExceptionprotected 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.NoSuchBeanDefinitionExceptionprotected 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.ConfigurableListableBeanFactorygetBeanDefinition in interface org.springframework.beans.factory.support.BeanDefinitionRegistrygetBeanDefinition in class org.springframework.beans.factory.support.AbstractBeanFactoryorg.springframework.beans.factory.NoSuchBeanDefinitionExceptionpublic Iterator<String> getBeanNamesIterator()
getBeanNamesIterator in interface org.springframework.beans.factory.config.ConfigurableListableBeanFactorypublic void freezeConfiguration()
freezeConfiguration in interface org.springframework.beans.factory.config.ConfigurableListableBeanFactorypublic boolean isConfigurationFrozen()
isConfigurationFrozen in interface org.springframework.beans.factory.config.ConfigurableListableBeanFactoryprotected boolean isBeanEligibleForMetadataCaching(String beanName)
isBeanEligibleForMetadataCaching in class org.springframework.beans.factory.support.AbstractBeanFactoryfreezeConfiguration()public void preInstantiateSingletons()
throws org.springframework.beans.BeansException
preInstantiateSingletons in interface org.springframework.beans.factory.config.ConfigurableListableBeanFactoryorg.springframework.beans.BeansExceptionpublic 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.BeanDefinitionRegistryorg.springframework.beans.factory.BeanDefinitionStoreExceptionpublic void removeBeanDefinition(String beanName) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
removeBeanDefinition in interface org.springframework.beans.factory.support.BeanDefinitionRegistryorg.springframework.beans.factory.NoSuchBeanDefinitionExceptionprotected void resetBeanDefinition(String beanName)
beanName - the name of the bean to resetprotected boolean allowAliasOverriding()
allowAliasOverriding in class org.springframework.core.SimpleAliasRegistrypublic void registerSingleton(String beanName, Object singletonObject) throws IllegalStateException
registerSingleton in interface org.springframework.beans.factory.config.SingletonBeanRegistryregisterSingleton in class org.springframework.beans.factory.support.DefaultSingletonBeanRegistryIllegalStateExceptionpublic void destroySingleton(String beanName)
destroySingleton in class org.springframework.beans.factory.support.DefaultSingletonBeanRegistrypublic void destroySingletons()
destroySingletons in interface org.springframework.beans.factory.config.ConfigurableBeanFactorydestroySingletons in class org.springframework.beans.factory.support.DefaultSingletonBeanRegistrypublic 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.AutowireCapableBeanFactoryorg.springframework.beans.BeansExceptionpublic 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.BeansExceptionprotected 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
ObjectStreamExceptionCopyright © 2003–2015 MuleSoft, Inc.. All rights reserved.