|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.beans.factory.support.StaticListableBeanFactory
Static factory that allows to register existing singleton instances programmatically.
Constructor Summary | |
StaticListableBeanFactory()
|
Method Summary | |
void |
addBean(java.lang.String name,
java.lang.Object bean)
Add a new singleton bean. |
boolean |
containsBean(java.lang.String name)
Does this bean factory contain a bean with the given name? |
boolean |
containsBeanDefinition(java.lang.String name)
Check if this bean factory contains a bean definition with the given name. |
java.lang.String[] |
getAliases(java.lang.String name)
Return the aliases for the given bean name, if defined. |
java.lang.Object |
getBean(java.lang.String name)
Return an instance (possibly shared or independent) of the given bean name. |
java.lang.Object |
getBean(java.lang.String name,
java.lang.Class requiredType)
Return an instance (possibly shared or independent) of the given bean name. |
int |
getBeanDefinitionCount()
Return the number of beans defined in the factory. |
java.lang.String[] |
getBeanDefinitionNames()
Return the names of all beans defined in this factory. |
java.lang.String[] |
getBeanDefinitionNames(java.lang.Class type)
Return the names of beans matching the given type (including subclasses), judging from the bean definitions. |
java.util.Map |
getBeansOfType(java.lang.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. |
boolean |
isSingleton(java.lang.String name)
Is this bean a singleton? That is, will getBean() always return the same object? |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public StaticListableBeanFactory()
Method Detail |
public java.lang.Object getBean(java.lang.String name) throws BeansException
BeanFactory
Note that callers should retain references to returned objects. There is no guarantee that this method will be implemented to be efficient. For example, it may be synchronized, or may need to run an RDBMS query.
Will ask the parent factory if the bean cannot be found in this factory instance.
getBean
in interface BeanFactory
name
- name of the bean to return
BeansException
- if the bean could not be createdpublic java.lang.Object getBean(java.lang.String name, java.lang.Class requiredType) throws BeansException
BeanFactory
Note that callers should retain references to returned objects. There is no guarantee that this method will be implemented to be efficient. For example, it may be synchronized, or may need to run an RDBMS query.
Will ask the parent factory if the bean cannot be found in this factory instance.
getBean
in interface BeanFactory
name
- name of the bean to returnrequiredType
- type the bean may match. Can be an interface or superclass
of the actual class. For example, if the value is Object.class, this method will
succeed whatever the class of the returned instance.
BeansException
- if the bean could not be createdpublic boolean containsBean(java.lang.String name)
BeanFactory
Will ask the parent factory if the bean cannot be found in this factory instance.
containsBean
in interface BeanFactory
name
- name of the bean to query
public boolean isSingleton(java.lang.String name) throws NoSuchBeanDefinitionException
BeanFactory
Will ask the parent factory if the bean cannot be found in this factory instance.
isSingleton
in interface BeanFactory
name
- name of the bean to query
NoSuchBeanDefinitionException
- if there is no bean with the given namepublic java.lang.String[] getAliases(java.lang.String name)
BeanFactory
Will ask the parent factory if the bean cannot be found in this factory instance.
getAliases
in interface BeanFactory
name
- the bean name to check for aliases
public int getBeanDefinitionCount()
ListableBeanFactory
Note: Ignores any singleton beans that have been registered by other means than bean definitions.
getBeanDefinitionCount
in interface ListableBeanFactory
public java.lang.String[] getBeanDefinitionNames()
ListableBeanFactory
Note: Ignores any singleton beans that have been registered by other means than bean definitions.
getBeanDefinitionNames
in interface ListableBeanFactory
public java.lang.String[] getBeanDefinitionNames(java.lang.Class type)
ListableBeanFactory
Note: Ignores any singleton beans that have been registered by other means than bean definitions.
getBeanDefinitionNames
in interface ListableBeanFactory
type
- class or interface to match, or null for all bean names
public boolean containsBeanDefinition(java.lang.String name)
ListableBeanFactory
Note: Ignores any singleton beans that have been registered by other means than bean definitions.
containsBeanDefinition
in interface ListableBeanFactory
name
- the name of the bean to look for
public java.util.Map getBeansOfType(java.lang.Class type, boolean includePrototypes, boolean includeFactoryBeans)
ListableBeanFactory
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: Ignores any singleton beans that have been registered by other means than bean definitions.
getBeansOfType
in interface ListableBeanFactory
type
- class or interface to matchincludePrototypes
- whether to include prototype beans too
or just singletons (also applies to FactoryBeans)includeFactoryBeans
- whether to include FactoryBeans too
or just normal beans
public void addBean(java.lang.String name, java.lang.Object bean)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |