diff --git a/src/Spring/Spring.Core/Context/Support/ContextHandler.cs b/src/Spring/Spring.Core/Context/Support/ContextHandler.cs
index e6ff0fd5..99a3701f 100644
--- a/src/Spring/Spring.Core/Context/Support/ContextHandler.cs
+++ b/src/Spring/Spring.Core/Context/Support/ContextHandler.cs
@@ -202,6 +202,15 @@ namespace Spring.Context.Support
get { return true; }
}
+ ///
+ /// Specifies, whether the instantiated context will be automatically registered in the
+ /// global .
+ ///
+ protected virtual bool AutoRegisterWithContextRegistry
+ {
+ get { return true; }
+ }
+
///
/// Creates an instance
/// using the context definitions supplied in a custom
@@ -277,7 +286,12 @@ namespace Spring.Context.Support
string[] resources = GetResources(contextElement);
// finally create the context instance
- context = InstantiateContext(parentContext, configContext, contextName, contextType, caseSensitive, resources);
+ context = InstantiateContext(parentContext, configContext, contextName, contextType, caseSensitive, resources);
+ // and register with global context registry
+ if (AutoRegisterWithContextRegistry)
+ {
+ ContextRegistry.RegisterContext(context);
+ }
// get and create child context definitions
XmlNode[] childContexts = GetChildContexts(contextElement);
@@ -492,7 +506,6 @@ namespace Spring.Context.Support
throw ConfigurationUtils.CreateConfigurationException(errorMessage);
}
IApplicationContext context = InvokeContextConstructor(ctor);
- ContextRegistry.RegisterContext(context);
return context;
}