allow for disabling automatic context registration by overriding property

This commit is contained in:
eeichinger
2010-10-31 02:21:51 +00:00
parent 5d07ee043e
commit 8939b2e320

View File

@@ -202,6 +202,15 @@ namespace Spring.Context.Support
get { return true; }
}
/// <summary>
/// Specifies, whether the instantiated context will be automatically registered in the
/// global <see cref="ContextRegistry"/>.
/// </summary>
protected virtual bool AutoRegisterWithContextRegistry
{
get { return true; }
}
/// <summary>
/// Creates an <see cref="Spring.Context.IApplicationContext"/> 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;
}