From 8939b2e3203125058998e159fce1ea13e20b962d Mon Sep 17 00:00:00 2001 From: eeichinger Date: Sun, 31 Oct 2010 02:21:51 +0000 Subject: [PATCH] allow for disabling automatic context registration by overriding property --- .../Context/Support/ContextHandler.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) 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; }