Spring.NET 1.3.0 RC1 for .NET 2.0 API Reference

ISingletonObjectRegistry.RegisterSingleton Method

Registers the given existing object as singleton in the object registry, under the given object name.

[Visual Basic]
Public Sub RegisterSingleton( _
   ByVal objectName As String, _
   ByVal singletonObject As Object _
)
[C#]
void RegisterSingleton(
   string objectName,
   object singletonObject
);

Parameters

objectName
Name of the object.
singletonObject
The singleton object.

Remarks

The given instance is supposed to be fully initialized; the registry will not perform any initialization callbacks (in particular, it won't call IInitializingObject's

AfterPropertiesSet
method). The given instance will not receive any destruction callbacks (like IDisposable's
Dispose
method) either.

If running within a full IObjectFactory: Register an object definition instead of an existing instance if your object 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.

See Also

ISingletonObjectRegistry Interface | Spring.Objects.Factory.Config Namespace