org.springframework.beans.factory.BeanFactory
implementations in order to expose their singleton management facility
in a uniform manner.
The ConfigurableBeanFactory interface extends this interface.
ConfigurableBeanFactory, org.springframework.beans.factory.support.DefaultSingletonBeanRegistry , org.springframework.beans.factory.support.AbstractBeanFactory
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: if this bean factory contains a singleton instance with the given namethe name of the bean to look for beanName)Check if this registry contains a singleton instance with the given name. |
| public Object | Returns: the registered singleton object, ornull if none foundthe name of the bean to look for beanName)Return the (raw) singleton object registered under the given name. |
| public int | Returns: the number of singleton beansReturn the number of singleton beans registered in this registry. |
| public Object | Returns: the mutex object (nevernull)Return the singleton mutex used by this registry (for external collaborators). |
| public String[] | Returns: the list of names as a String array (nevernull)Return the names of singleton beans registered in this registry. |
| public void | registerSingleton(String
the name of the bean beanName, Object the existing singleton object singletonObject)Register the given existing object as singleton in the bean registry, under the given bean name. |
| containsSingleton | back to summary |
|---|---|
| public boolean containsSingleton(String beanName) Check if this registry contains a singleton instance with the given name. Only checks already instantiated singletons; does not return The main purpose of this method is to check manually registered singletons
(see To check whether a bean factory contains a bean definition with a given name,
use ListableBeanFactory's Use BeanFactory's Note This lookup method is not aware of FactoryBean prefixes or aliases. You need to resolve the canonical bean name first before checking the singleton status.
| |
| getSingleton | back to summary |
|---|---|
| public Object getSingleton(String beanName) Return the (raw) singleton object registered under the given name. Only checks already instantiated singletons; does not return an Object for singleton bean definitions which have not been instantiated yet. The main purpose of this method is to access manually registered singletons
(see Note This lookup method is not aware of FactoryBean prefixes or aliases. You need to resolve the canonical bean name first before obtaining the singleton instance.
| |
| getSingletonCount | back to summary |
|---|---|
| public int getSingletonCount() Return the number of singleton beans registered in this registry. Only checks already instantiated singletons; does not count singleton bean definitions which have not been instantiated yet. The main purpose of this method is to check manually registered singletons
(see
| |
| getSingletonMutex | back to summary |
|---|---|
| public Object getSingletonMutex() Return the singleton mutex used by this registry (for external collaborators).
| |
| getSingletonNames | back to summary |
|---|---|
| public String[] getSingletonNames() Return the names of singleton beans registered in this registry. Only checks already instantiated singletons; does not return names for singleton bean definitions which have not been instantiated yet. The main purpose of this method is to check manually registered singletons
(see
| |
| registerSingleton | back to summary |
|---|---|
| public void registerSingleton(String beanName, Object singletonObject) Register the given existing object as singleton in the bean registry, under the given bean name. The given instance is supposed to be fully initialized; the registry
will not perform any initialization callbacks (in particular, it won't
call InitializingBean's When running within a full BeanFactory: Register a bean definition instead of an existing instance if your bean is supposed to receive initialization and/or destruction callbacks. Typically invoked during registry configuration, but can also be used for runtime registration of singletons. As a consequence, a registry implementation should synchronize singleton access; it will have to do this anyway if it supports a BeanFactory's lazy initialization of singletons. | |