Spring.NET 1.3.0 RC1 for .NET 2.0 API Reference

ISingletonObjectRegistry.ContainsSingleton Method

Check if this registry contains a singleton instance with the given name.

[Visual Basic]
Public Sub ContainsSingleton( _
   ByVal objectName As String _
)
[C#]
bool ContainsSingleton(
   string objectName
);

Parameters

objectName
Name of the object to look for.

Return Value

true if this bean factory contains a singleton instance with the given name; otherwise, false.

Remarks

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 RegisterSingleton. Can also be used to check whether a singleton defined by an object definition has already been created.

To check whether an object factory contains an object definition with a given name, use ListableBeanFactory's

ContainsObjectDefinition
. Calling both
ContainsObjectDefinition
and
ContainsSingleton
answers whether a specific object factory contains an own object with the given name.

Use IObjectFactory's

ContainsObject
for general checks whether the factory knows about an object with a given name (whether manually registered singleton instance or created by bean definition), also checking ancestor factories.

See Also

ISingletonObjectRegistry Interface | Spring.Objects.Factory.Config Namespace