Check if this registry contains a singleton instance with the given name.
Only checks already instantiated singletons; does not return true
for singleton bean definitions which have not been instantiated yet.
The main purpose of this method is to check manually registered singletons (see {@link #registerSingleton}). Can also be used to check whether a singleton defined by a bean definition has already been created.
To check whether a bean factory contains a bean definition with a given name, use ListableBeanFactory's containsBeanDefinition
. Calling both containsBeanDefinition
and containsSingleton
answers whether a specific bean factory contains a local bean instance with the given name.
Use BeanFactory's containsBean
for general checks whether the factory knows about a bean with a given name (whether manually registered singleton instance or created by bean definition), also checking ancestor factories.
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.
@param beanName the name of the bean to look for
@return if this bean factory contains a singleton instance with the given name
@see #registerSingleton
@see org.springframework.beans.factory.ListableBeanFactory#containsBeanDefinition
@see org.springframework.beans.factory.BeanFactory#containsBean