|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Extension of the BeanFactory interface to be implemented by bean factories that can enumerate all their bean instances, rather than attempting bean lookup by name one by one as requested by clients. BeanFactory implementations that preload all their beans (for example, DOM-based XML factories) may implement this interface. This interface is discussed in "Expert One-on-One J2EE Design and Development", by Rod Johnson.
If this is a HierarchicalBeanFactory, the return values will not take any BeanFactory hierarchy into account, but will relate only to the beans defined in the current factory. Use the BeanFactoryUtils helper class to get all beans.
The methods in this interface will just respect bean definitions of this factory. They will ignore any singleton beans that have been registered by other means like ConfigurableBeanFactory's registerSingleton. Use BeanFactory's methods to access such beans. In typical scenarios, all beans will be defined by bean definitions anyway.
With the exception of getBeanDefinitionCount(), the methods in this interface are not designed for frequent invocation. Implementations may be slow.
BeanFactoryUtils
,
ConfigurableBeanFactory.registerSingleton(java.lang.String, java.lang.Object)
Field Summary |
Fields inherited from interface org.springframework.beans.factory.BeanFactory |
FACTORY_BEAN_PREFIX |
Method Summary | |
boolean |
containsBeanDefinition(String name)
Check if this bean factory contains a bean definition with the given name. |
int |
getBeanDefinitionCount()
Return the number of beans defined in the factory. |
String[] |
getBeanDefinitionNames()
Return the names of all beans defined in this factory. |
String[] |
getBeanDefinitionNames(Class type)
Return the names of beans matching the given type (including subclasses), judging from the bean definitions. |
Map |
getBeansOfType(Class type)
Return the bean instances that match the given object type (including subclasses), judging from either bean definitions or the value of getObjectType() in the case of FactoryBeans. |
Map |
getBeansOfType(Class type,
boolean includePrototypes,
boolean includeFactoryBeans)
Return the bean instances that match the given object type (including subclasses), judging from either bean definitions or the value of getObjectType() in the case of FactoryBeans. |
Methods inherited from interface org.springframework.beans.factory.BeanFactory |
containsBean, getAliases, getBean, getBean, getType, isSingleton |
Method Detail |
public int getBeanDefinitionCount()
Note: Ignores any singleton beans that have been registered by other means than bean definitions.
BeanFactoryUtils.countBeansIncludingAncestors(org.springframework.beans.factory.ListableBeanFactory)
public String[] getBeanDefinitionNames()
Note: Ignores any singleton beans that have been registered by other means than bean definitions.
BeanFactoryUtils.beanNamesIncludingAncestors(ListableBeanFactory)
public String[] getBeanDefinitionNames(Class type)
Note: Ignores any singleton beans that have been registered by other means than bean definitions.
type
- the class or interface to match, or null for all bean names
BeanFactoryUtils.beanNamesIncludingAncestors(ListableBeanFactory, Class)
public boolean containsBeanDefinition(String name)
Note: Ignores any singleton beans that have been registered by other means than bean definitions.
name
- the name of the bean to look for
BeanFactory.containsBean(java.lang.String)
public Map getBeansOfType(Class type) throws BeansException
If FactoryBean's getObjectType() returns null and the bean is a singleton, the type of the actually created objects should be evaluated. Prototypes without explicit object type specification should be ignored.
Note: Does not ignore singleton beans that have been registered by other means than bean definitions.
This version of getBeansOfType matches all kinds of beans, be it
singletons, prototypes, or FactoryBeans. In most implementations, the
result will be the same as for getBeansOfType(type, true, true)
.
type
- the class or interface to match, or null for all concrete beans
BeansException
- if the beans could not be createdFactoryBean.getObjectType()
,
BeanFactoryUtils.beansOfTypeIncludingAncestors(ListableBeanFactory, Class)
public Map getBeansOfType(Class type, boolean includePrototypes, boolean includeFactoryBeans) throws BeansException
If FactoryBean's getObjectType() returns null and the bean is a singleton, the type of the actually created objects should be evaluated. Prototypes without explicit object type specification should be ignored.
Note: Does not ignore singleton beans that have been registered by other means than bean definitions.
type
- the class or interface to match, or null for all concrete beansincludePrototypes
- whether to include prototype beans too
or just singletons (also applies to FactoryBeans)includeFactoryBeans
- whether to include FactoryBeans too
or just conventional beans
BeansException
- if the beans could not be createdFactoryBean.getObjectType()
,
BeanFactoryUtils.beansOfTypeIncludingAncestors(ListableBeanFactory, Class, boolean, boolean)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |