接口 ConfigurableListableBeanFactory
- 所有超级接口:
AutowireCapableBeanFactory
,BeanFactory
,ConfigurableBeanFactory
,HierarchicalBeanFactory
,ListableBeanFactory
,SingletonBeanRegistry
- 所有已知实现类:
DefaultListableBeanFactory
,XmlBeanFactory
public interface ConfigurableListableBeanFactory extends ListableBeanFactory, AutowireCapableBeanFactory, ConfigurableBeanFactory
Configuration interface to be implemented by most listable bean factories. In addition toConfigurableBeanFactory
, it provides facilities to analyze and modify bean definitions, and to pre-instantiate singletons.This subinterface of
BeanFactory
is not meant to be used in normal application code: Stick toBeanFactory
orListableBeanFactory
for typical use cases. This interface is just meant to allow for framework-internal plug'n'play even when needing access to bean factory configuration methods.- 从以下版本开始:
- 03.11.2003
- 作者:
- Juergen Hoeller
- 另请参阅:
AbstractApplicationContext.getBeanFactory()
字段概要
从接口继承的字段 org.springframework.beans.factory.config.AutowireCapableBeanFactory
AUTOWIRE_AUTODETECT, AUTOWIRE_BY_NAME, AUTOWIRE_BY_TYPE, AUTOWIRE_CONSTRUCTOR, AUTOWIRE_NO
从接口继承的字段 org.springframework.beans.factory.BeanFactory
FACTORY_BEAN_PREFIX
从接口继承的字段 org.springframework.beans.factory.config.ConfigurableBeanFactory
SCOPE_PROTOTYPE, SCOPE_SINGLETON
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 void
clearMetadataCache()
Clear the merged bean definition cache, removing entries for beans which are not considered eligible for full metadata caching yet.void
freezeConfiguration()
Freeze all bean definitions, signalling that the registered bean definitions will not be modified or post-processed any further.BeanDefinition
getBeanDefinition(String beanName)
Return the registered BeanDefinition for the specified bean, allowing access to its property values and constructor argument value (which can be modified during bean factory post-processing).Iterator<String>
getBeanNamesIterator()
Return a unified view over all bean names managed by this factory.void
ignoreDependencyInterface(Class<?> ifc)
Ignore the given dependency interface for autowiring.void
ignoreDependencyType(Class<?> type)
Ignore the given dependency type for autowiring: for example, String.boolean
isAutowireCandidate(String beanName, DependencyDescriptor descriptor)
Determine whether the specified bean qualifies as an autowire candidate, to be injected into other beans which declare a dependency of matching type.boolean
isConfigurationFrozen()
Return whether this factory's bean definitions are frozen, i.e. are not supposed to be modified or post-processed any further.void
preInstantiateSingletons()
Ensure that all non-lazy-init singletons are instantiated, also consideringFactoryBeans
.void
registerResolvableDependency(Class<?> dependencyType, Object autowiredValue)
Register a special dependency type with corresponding autowired value.从接口继承的方法 org.springframework.beans.factory.config.AutowireCapableBeanFactory
applyBeanPostProcessorsAfterInitialization, applyBeanPostProcessorsBeforeInitialization, applyBeanPropertyValues, autowire, autowireBean, autowireBeanProperties, configureBean, createBean, createBean, destroyBean, initializeBean, resolveDependency, resolveDependency, resolveNamedBean
从接口继承的方法 org.springframework.beans.factory.BeanFactory
containsBean, getAliases, getBean, getBean, getBean, getBean, getBean, getType, isPrototype, isSingleton, isTypeMatch, isTypeMatch
从接口继承的方法 org.springframework.beans.factory.config.ConfigurableBeanFactory
addBeanPostProcessor, addEmbeddedValueResolver, addPropertyEditorRegistrar, copyConfigurationFrom, copyRegisteredEditorsTo, destroyBean, destroyScopedBean, destroySingletons, getAccessControlContext, getBeanClassLoader, getBeanExpressionResolver, getBeanPostProcessorCount, getConversionService, getDependenciesForBean, getDependentBeans, getMergedBeanDefinition, getRegisteredScope, getRegisteredScopeNames, getTempClassLoader, getTypeConverter, hasEmbeddedValueResolver, isCacheBeanMetadata, isCurrentlyInCreation, isFactoryBean, registerAlias, registerCustomEditor, registerDependentBean, registerScope, resolveAliases, resolveEmbeddedValue, setBeanClassLoader, setBeanExpressionResolver, setCacheBeanMetadata, setConversionService, setCurrentlyInCreation, setParentBeanFactory, setTempClassLoader, setTypeConverter
从接口继承的方法 org.springframework.beans.factory.HierarchicalBeanFactory
containsLocalBean, getParentBeanFactory
从接口继承的方法 org.springframework.beans.factory.ListableBeanFactory
containsBeanDefinition, findAnnotationOnBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanNamesForAnnotation, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, getBeansWithAnnotation
从接口继承的方法 org.springframework.beans.factory.config.SingletonBeanRegistry
containsSingleton, getSingleton, getSingletonCount, getSingletonMutex, getSingletonNames, registerSingleton
方法详细资料
ignoreDependencyType
void ignoreDependencyType(Class<?> type)
Ignore the given dependency type for autowiring: for example, String. Default is none.- 参数:
type
- the dependency type to ignore
ignoreDependencyInterface
void ignoreDependencyInterface(Class<?> ifc)
Ignore the given dependency interface for autowiring.This will typically be used by application contexts to register dependencies that are resolved in other ways, like BeanFactory through BeanFactoryAware or ApplicationContext through ApplicationContextAware.
By default, only the BeanFactoryAware interface is ignored. For further types to ignore, invoke this method for each type.
- 参数:
ifc
- the dependency interface to ignore- 另请参阅:
BeanFactoryAware
,ApplicationContextAware
registerResolvableDependency
void registerResolvableDependency(Class<?> dependencyType, Object autowiredValue)
Register a special dependency type with corresponding autowired value.This is intended for factory/context references that are supposed to be autowirable but are not defined as beans in the factory: e.g. a dependency of type ApplicationContext resolved to the ApplicationContext instance that the bean is living in.
Note: There are no such default types registered in a plain BeanFactory, not even for the BeanFactory interface itself.
- 参数:
dependencyType
- the dependency type to register. This will typically be a base interface such as BeanFactory, with extensions of it resolved as well if declared as an autowiring dependency (e.g. ListableBeanFactory), as long as the given value actually implements the extended interface.autowiredValue
- the corresponding autowired value. This may also be an implementation of theObjectFactory
interface, which allows for lazy resolution of the actual target value.
isAutowireCandidate
boolean isAutowireCandidate(String beanName, DependencyDescriptor descriptor) throws NoSuchBeanDefinitionException
Determine whether the specified bean qualifies as an autowire candidate, to be injected into other beans which declare a dependency of matching type.This method checks ancestor factories as well.
- 参数:
beanName
- the name of the bean to checkdescriptor
- the descriptor of the dependency to resolve- 返回:
- whether the bean should be considered as autowire candidate
- 抛出:
NoSuchBeanDefinitionException
- if there is no bean with the given name
getBeanDefinition
BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException
Return the registered BeanDefinition for the specified bean, allowing access to its property values and constructor argument value (which can be modified during bean factory post-processing).A returned BeanDefinition object should not be a copy but the original definition object as registered in the factory. This means that it should be castable to a more specific implementation type, if necessary.
NOTE: This method does not consider ancestor factories. It is only meant for accessing local bean definitions of this factory.
- 参数:
beanName
- the name of the bean- 返回:
- the registered BeanDefinition
- 抛出:
NoSuchBeanDefinitionException
- if there is no bean with the given name defined in this factory
getBeanNamesIterator
Iterator<String> getBeanNamesIterator()
Return a unified view over all bean names managed by this factory.Includes bean definition names as well as names of manually registered singleton instances, with bean definition names consistently coming first, analogous to how type/annotation specific retrieval of bean names works.
- 返回:
- the composite iterator for the bean names view
- 从以下版本开始:
- 4.1.2
- 另请参阅:
ListableBeanFactory.containsBeanDefinition(java.lang.String)
,SingletonBeanRegistry.registerSingleton(java.lang.String, java.lang.Object)
,ListableBeanFactory.getBeanNamesForType(org.springframework.core.ResolvableType)
,ListableBeanFactory.getBeanNamesForAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation>)
clearMetadataCache
void clearMetadataCache()
Clear the merged bean definition cache, removing entries for beans which are not considered eligible for full metadata caching yet.Typically triggered after changes to the original bean definitions, e.g. after applying a
BeanFactoryPostProcessor
. Note that metadata for beans which have already been created at this point will be kept around.
freezeConfiguration
void freezeConfiguration()
Freeze all bean definitions, signalling that the registered bean definitions will not be modified or post-processed any further.This allows the factory to aggressively cache bean definition metadata.
isConfigurationFrozen
boolean isConfigurationFrozen()
Return whether this factory's bean definitions are frozen, i.e. are not supposed to be modified or post-processed any further.- 返回:
true
if the factory's configuration is considered frozen
preInstantiateSingletons
void preInstantiateSingletons() throws BeansException
Ensure that all non-lazy-init singletons are instantiated, also consideringFactoryBeans
. Typically invoked at the end of factory setup, if desired.- 抛出:
BeansException
- if one of the singleton beans could not be created. Note: This may have left the factory with some beans already initialized! CallConfigurableBeanFactory.destroySingletons()
for full cleanup in this case.- 另请参阅:
ConfigurableBeanFactory.destroySingletons()