diff --git a/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContext.cs b/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContext.cs index 0d23203c..8d9c484d 100644 --- a/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContext.cs +++ b/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContext.cs @@ -29,6 +29,7 @@ using Spring.Objects.Factory.Config; using Spring.Objects.Factory.Support; using Spring.Objects.Factory.Xml; using Spring.Util; +using Spring.Core.IO; #endregion @@ -99,6 +100,24 @@ namespace Spring.Context.Support /// protected abstract string[] ConfigurationLocations { get; } + + /// + /// An array of resources that this context is to be built with. + /// + /// + ///

+ /// Examples of the format of the various strings that would be + /// returned by accessing this property can be found in the overview + /// documentation of with the + /// class. + ///

+ ///
+ /// + /// An array of s, or if none. + /// + protected abstract IResource[] ConfigurationResources { get; } + + /// /// Instantiates and populates the underlying /// with the object @@ -200,16 +219,23 @@ namespace Spring.Context.Support /// /// /// In the case of errors encountered reading any of the resources - /// yielded by the method. + /// yielded by either the or + /// the methods. /// - protected virtual void LoadObjectDefinitions( - XmlObjectDefinitionReader objectDefinitionReader) + protected virtual void LoadObjectDefinitions(XmlObjectDefinitionReader objectDefinitionReader) { string[] locations = ConfigurationLocations; if (locations != null) { - objectDefinitionReader.LoadObjectDefinitions(ConfigurationLocations); + objectDefinitionReader.LoadObjectDefinitions(locations); } + + IResource[] resources = ConfigurationResources; + if (resources != null) + { + objectDefinitionReader.LoadObjectDefinitions(resources); + } + } diff --git a/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContextArgs.cs b/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContextArgs.cs new file mode 100644 index 00000000..fd8c992f --- /dev/null +++ b/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContextArgs.cs @@ -0,0 +1,53 @@ +#region License + +/* + * Copyright © 2002-2005 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + +using System; +using System.Collections.Generic; +using System.Text; +using Spring.Core.IO; + +namespace Spring.Context.Support +{ + public abstract class AbstractXmlApplicationContextArgs + { + + public virtual bool CaseSensitive { get; set; } + + public virtual string[] ConfigurationLocations { get; set; } + + public virtual IResource[] ConfigurationResources { get; set; } + + public virtual string Name { get; set; } + + public virtual IApplicationContext ParentContext { get; set; } + + public virtual bool Refresh { get; set; } + + /// + /// Initializes a new instance of the AbstractXmlApplicationContextArgs class. + /// + public AbstractXmlApplicationContextArgs() + { + ConfigurationLocations = new string[0]; + ConfigurationResources = new IResource[0]; + } + + } +} diff --git a/src/Spring/Spring.Core/Context/Support/XmlApplicationContext.cs b/src/Spring/Spring.Core/Context/Support/XmlApplicationContext.cs index 80cd607e..aa9e82b0 100644 --- a/src/Spring/Spring.Core/Context/Support/XmlApplicationContext.cs +++ b/src/Spring/Spring.Core/Context/Support/XmlApplicationContext.cs @@ -1,237 +1,286 @@ -#region License - -/* - * Copyright © 2002-2005 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#endregion - -using Spring.Util; +#region License -namespace Spring.Context.Support -{ - /// - /// An implementation that - /// reads context definitions from XML based resources. - /// - /// - ///

- /// Currently, the resources that are supported are the file, - /// http, ftp, config and assembly resource - /// types. - ///

- ///

- /// You can provide custom implementations of the - /// interface and and register them - /// with any that inherits - /// from the - /// - /// interface. - ///

- /// - /// In case of multiple config locations, later object definitions will - /// override ones defined in previously loaded resources. This can be - /// leveraged to deliberately override certain object definitions via an - /// extra XML file. - /// - ///
- /// - ///

- /// Find below some examples of instantiating an - /// using a - /// variety of different XML resources. - ///

- /// - /// // an XmlApplicationContext that reads its object definitions from an - /// // XML file that has been embedded in an assembly... - /// IApplicationContext context = new XmlApplicationContext - /// ( - /// "assembly://AssemblyName/NameSpace/ResourceName" - /// ); - /// - /// // an XmlApplicationContext that reads its object definitions from a - /// // number of disparate XML resources... - /// IApplicationContext context = new XmlApplicationContext - /// ( - /// // from an XML file that has been embedded in an assembly... - /// "assembly://AssemblyName/NameSpace/ResourceName", - /// // and from a (relative) filesystem-based resource... - /// "file://Objects/services.xml", - /// // and from an App.config / Web.config resource... - /// "config://spring/objects" - /// ); - /// - ///
- /// Rod Johnson - /// Juergen Hoeller - /// Griffin Caprio (.NET) - /// - /// - /// - public class XmlApplicationContext : AbstractXmlApplicationContext - { - private readonly string[] _configurationLocations; - - /// - /// Creates a new instance of the - /// class, - /// loading the definitions from the supplied XML resource locations. - /// - /// The created context will be case sensitive. - /// - /// Any number of XML based object definition resource locations. - /// - public XmlApplicationContext(params string[] configurationLocations) - : this(true, null, true, null, configurationLocations) - { } - - /// - /// Creates a new instance of the - /// class, - /// loading the definitions from the supplied XML resource locations. - /// - /// Flag specifying whether to make this context case sensitive or not. - /// - /// Any number of XML based object definition resource locations. - /// - public XmlApplicationContext(bool caseSensitive, - params string[] configurationLocations) - : this(true, null, caseSensitive, null, configurationLocations) - { } - - /// - /// Creates a new instance of the - /// class, - /// loading the definitions from the supplied XML resource locations. - /// - /// The application context name. - /// Flag specifying whether to make this context case sensitive or not. - /// - /// Any number of XML based object definition resource locations. - /// - public XmlApplicationContext(string name, bool caseSensitive, - params string[] configurationLocations) - : this(true, name, caseSensitive, null, configurationLocations) - { } - - /// - /// Creates a new instance of the - /// class, - /// loading the definitions from the supplied XML resource locations, - /// with the given . - /// - /// - /// The parent context (may be ). - /// - /// - /// Any number of XML based object definition resource locations. - /// - public XmlApplicationContext( - IApplicationContext parentContext, - params string[] configurationLocations) - : this(true, null, true, parentContext, configurationLocations) - { } - - /// - /// Creates a new instance of the - /// class, - /// loading the definitions from the supplied XML resource locations, - /// with the given . - /// - /// Flag specifying whether to make this context case sensitive or not. - /// - /// The parent context (may be ). - /// - /// - /// Any number of XML based object definition resource locations. - /// - public XmlApplicationContext( - bool caseSensitive, - IApplicationContext parentContext, - params string[] configurationLocations) - : this(true, null, caseSensitive, parentContext, configurationLocations) - { } - - /// - /// Creates a new instance of the - /// class, - /// loading the definitions from the supplied XML resource locations, - /// with the given . - /// - /// The application context name. - /// Flag specifying whether to make this context case sensitive or not. - /// - /// The parent context (may be ). - /// - /// - /// Any number of XML based object definition resource locations. - /// - public XmlApplicationContext( - string name, - bool caseSensitive, - IApplicationContext parentContext, - params string[] configurationLocations) - : this(true, name, caseSensitive, parentContext, configurationLocations) - {} - - /// - /// Creates a new instance of the - /// class, - /// loading the definitions from the supplied XML resource locations, - /// with the given . - /// - /// - /// This constructor is meant to be used by derived classes. By passing =false, it is - /// the responsibility of the deriving class to call to initialize the context instance. - /// - /// if true, is called automatically. - /// The application context name. - /// Flag specifying whether to make this context case sensitive or not. - /// - /// The parent context (may be ). - /// - /// - /// Any number of XML based object definition resource locations. - /// - public XmlApplicationContext( - bool refresh, - string name, - bool caseSensitive, - IApplicationContext parentContext, - params string[] configurationLocations) - : base(name, caseSensitive, parentContext ) - { - _configurationLocations = configurationLocations; - if (refresh) - { - AssertUtils.ArgumentHasElements(configurationLocations, "configurationLocations"); - Refresh(); - } - } - - /// - /// An array of resource locations, referring to the XML object - /// definition files that this context is to be built with. - /// - /// - /// An array of resource locations, or if none. - /// - /// - protected override string[] ConfigurationLocations - { - get { return _configurationLocations; } - } - } +/* + * Copyright © 2002-2005 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + +using Spring.Util; +using Spring.Core.IO; +using System; + +namespace Spring.Context.Support +{ + /// + /// An implementation that + /// reads context definitions from XML based resources. + /// + /// + ///

+ /// Currently, the resources that are supported are the file, + /// http, ftp, config and assembly resource + /// types. + ///

+ ///

+ /// You can provide custom implementations of the + /// interface and and register them + /// with any that inherits + /// from the + /// + /// interface. + ///

+ /// + /// In case of multiple config locations, later object definitions will + /// override ones defined in previously loaded resources. This can be + /// leveraged to deliberately override certain object definitions via an + /// extra XML file. + /// + ///
+ /// + ///

+ /// Find below some examples of instantiating an + /// using a + /// variety of different XML resources. + ///

+ /// + /// // an XmlApplicationContext that reads its object definitions from an + /// // XML file that has been embedded in an assembly... + /// IApplicationContext context = new XmlApplicationContext + /// ( + /// "assembly://AssemblyName/NameSpace/ResourceName" + /// ); + /// + /// // an XmlApplicationContext that reads its object definitions from a + /// // number of disparate XML resources... + /// IApplicationContext context = new XmlApplicationContext + /// ( + /// // from an XML file that has been embedded in an assembly... + /// "assembly://AssemblyName/NameSpace/ResourceName", + /// // and from a (relative) filesystem-based resource... + /// "file://Objects/services.xml", + /// // and from an App.config / Web.config resource... + /// "config://spring/objects" + /// ); + /// + ///
+ /// Rod Johnson + /// Juergen Hoeller + /// Griffin Caprio (.NET) + /// + /// + /// + public class XmlApplicationContext : AbstractXmlApplicationContext + { + private readonly string[] _configurationLocations; + private readonly IResource[] _configurationResources; + + + + /// + /// Initializes a new instance of the XmlApplicationContext class. + /// + public XmlApplicationContext(XmlApplicationContextArgs args) + : base(args.Name, args.CaseSensitive, args.ParentContext) + { + _configurationLocations = args.ConfigurationLocations; + _configurationResources = args.ConfigurationResources; + + if (args.Refresh) + { + bool hasLocations = args.ConfigurationLocations.Length > 0; + bool hasResources = args.ConfigurationResources.Length > 0; + + if (!hasLocations && !hasResources) + throw new ArgumentException("You must provide either or both Configuration Locations and/or Configuration Resources!"); + + if (hasLocations || hasResources) + { + Refresh(); + } + } + + } + + + + /// + /// Creates a new instance of the + /// class, + /// loading the definitions from the supplied XML resource locations. + /// + /// The created context will be case sensitive. + /// + /// Any number of XML based object definition resource locations. + /// + public XmlApplicationContext(params string[] configurationLocations) + : this(new XmlApplicationContextArgs() { ConfigurationLocations = configurationLocations }) + { } + + /// + /// Creates a new instance of the + /// class, + /// loading the definitions from the supplied XML resource locations. + /// + /// Flag specifying whether to make this context case sensitive or not. + /// + /// Any number of XML based object definition resource locations. + /// + public XmlApplicationContext(bool caseSensitive, + params string[] configurationLocations) + : this(new XmlApplicationContextArgs() { CaseSensitive = caseSensitive, ConfigurationLocations = configurationLocations }) + { } + + /// + /// Creates a new instance of the + /// class, + /// loading the definitions from the supplied XML resource locations. + /// + /// The application context name. + /// Flag specifying whether to make this context case sensitive or not. + /// + /// Any number of XML based object definition resource locations. + /// + public XmlApplicationContext(string name, bool caseSensitive, + params string[] configurationLocations) + : this(new XmlApplicationContextArgs() { Name = name, CaseSensitive = caseSensitive, ConfigurationLocations = configurationLocations }) + { } + + /// + /// Creates a new instance of the + /// class, + /// loading the definitions from the supplied XML resource locations, + /// with the given . + /// + /// + /// The parent context (may be ). + /// + /// + /// Any number of XML based object definition resource locations. + /// + public XmlApplicationContext( + IApplicationContext parentContext, + params string[] configurationLocations) + : this(new XmlApplicationContextArgs() { ParentContext = parentContext, ConfigurationLocations = configurationLocations }) + { } + + /// + /// Creates a new instance of the + /// class, + /// loading the definitions from the supplied XML resource locations, + /// with the given . + /// + /// Flag specifying whether to make this context case sensitive or not. + /// + /// The parent context (may be ). + /// + /// + /// Any number of XML based object definition resource locations. + /// + public XmlApplicationContext( + bool caseSensitive, + IApplicationContext parentContext, + params string[] configurationLocations) + : this(new XmlApplicationContextArgs() { CaseSensitive = caseSensitive, ParentContext = parentContext, ConfigurationLocations = configurationLocations }) + { } + + /// + /// Creates a new instance of the + /// class, + /// loading the definitions from the supplied XML resource locations, + /// with the given . + /// + /// The application context name. + /// Flag specifying whether to make this context case sensitive or not. + /// + /// The parent context (may be ). + /// + /// + /// Any number of XML based object definition resource locations. + /// + public XmlApplicationContext( + string name, + bool caseSensitive, + IApplicationContext parentContext, + params string[] configurationLocations) + : this(new XmlApplicationContextArgs() { Name = name, CaseSensitive = caseSensitive, ParentContext = parentContext, ConfigurationLocations = configurationLocations }) + { } + + /// + /// Creates a new instance of the + /// class, + /// loading the definitions from the supplied XML resource locations, + /// with the given . + /// + /// + /// This constructor is meant to be used by derived classes. By passing =false, it is + /// the responsibility of the deriving class to call to initialize the context instance. + /// + /// if true, is called automatically. + /// The application context name. + /// Flag specifying whether to make this context case sensitive or not. + /// + /// The parent context (may be ). + /// + /// + /// Any number of XML based object definition resource locations. + /// + public XmlApplicationContext( + bool refresh, + string name, + bool caseSensitive, + IApplicationContext parentContext, + params string[] configurationLocations) + : this(new XmlApplicationContextArgs() { Refresh = refresh, Name = name, CaseSensitive = caseSensitive, ParentContext = parentContext, ConfigurationLocations = configurationLocations }) + { } + + + public XmlApplicationContext( + bool refresh, + string name, + bool caseSensitive, + IApplicationContext parentContext, + string[] configurationLocations, + IResource[] configurationResources) + : this(new XmlApplicationContextArgs() { Refresh = refresh, Name = name, CaseSensitive = caseSensitive, ParentContext = parentContext, ConfigurationLocations = configurationLocations, ConfigurationResources = configurationResources }) + { } + + + /// + /// An array of resource locations, referring to the XML object + /// definition files with which this context is to be built. + /// + /// + /// An array of resource locations, or if none. + /// + /// + protected override string[] ConfigurationLocations + { + get { return _configurationLocations; } + } + + /// + /// An array of resources instances with which this context is to be built. + /// + /// + /// An array of s, or if none. + /// + /// + protected override IResource[] ConfigurationResources + { + get { return _configurationResources; } + } + } } \ No newline at end of file diff --git a/src/Spring/Spring.Core/Context/Support/XmlApplicationContextArgs.cs b/src/Spring/Spring.Core/Context/Support/XmlApplicationContextArgs.cs new file mode 100644 index 00000000..7a87b775 --- /dev/null +++ b/src/Spring/Spring.Core/Context/Support/XmlApplicationContextArgs.cs @@ -0,0 +1,39 @@ +#region License + +/* + * Copyright © 2002-2005 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + +using System; +using System.Collections.Generic; +using System.Text; +using Spring.Core.IO; + +namespace Spring.Context.Support +{ + public class XmlApplicationContextArgs : AbstractXmlApplicationContextArgs + { + /// + /// Initializes a new instance of the XmlApplicationContextArgs class. + /// + public XmlApplicationContextArgs() + { + CaseSensitive = true; + Refresh = true; + } + } +} diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs index 3e43d9ee..9623ba27 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs @@ -1324,11 +1324,11 @@ namespace Spring.Objects.Factory.Support } else { - // No singleton instance found -> check bean definition. + // No singleton instance found -> check object definition. IObjectFactory parentFactory = ParentObjectFactory; if (parentFactory != null && !ContainsObjectDefinition(objectName)) { - // No bean definition found in this factory -> delegate to parent. + // No object definition found in this factory -> delegate to parent. return parentFactory.GetType(this.OriginalObjectName(name)); } @@ -1339,7 +1339,7 @@ namespace Spring.Objects.Factory.Support { if (!IsFactoryDereference(name)) { - // If it's a FactoryBean, we want to look at what it creates, not the factory class. + // If it's a FactoryObject, we want to look at what it creates, not the factory class. return GetTypeForFactoryObject(objectName, mod); } else diff --git a/src/Spring/Spring.Core/Spring.Core.2008.csproj b/src/Spring/Spring.Core/Spring.Core.2008.csproj index e780bbd4..eac21748 100644 --- a/src/Spring/Spring.Core/Spring.Core.2008.csproj +++ b/src/Spring/Spring.Core/Spring.Core.2008.csproj @@ -214,6 +214,7 @@ Code + Code @@ -265,6 +266,7 @@ Code + diff --git a/src/Spring/Spring.Web/Context/Support/WebApplicationContext.cs b/src/Spring/Spring.Web/Context/Support/WebApplicationContext.cs index 8e418d57..6678dce0 100644 --- a/src/Spring/Spring.Web/Context/Support/WebApplicationContext.cs +++ b/src/Spring/Spring.Web/Context/Support/WebApplicationContext.cs @@ -36,6 +36,7 @@ using Spring.Objects.Factory.Xml; using Spring.Objects.Support; using Spring.Reflection.Dynamic; using Spring.Util; +using Spring.Core.IO; namespace Spring.Context.Support { @@ -59,6 +60,7 @@ namespace Spring.Context.Support private string _constructionUrl; private readonly string[] _configurationLocations; + private readonly IResource[] _configurationResources; /// /// Create a new WebApplicationContext, loading the definitions @@ -66,7 +68,7 @@ namespace Spring.Context.Support /// /// Names of configuration resources. public WebApplicationContext(params string[] configurationLocations) - : this(null, false, null, configurationLocations) + : this(new WebApplicationContextArgs() { ConfigurationLocations = configurationLocations }) { } @@ -78,7 +80,20 @@ namespace Spring.Context.Support /// Flag specifying whether to make this context case sensitive or not. /// Names of configuration resources. public WebApplicationContext(string name, bool caseSensitive, params string[] configurationLocations) - : this(name, caseSensitive, null, configurationLocations) + : this(new WebApplicationContextArgs() { Name = name, CaseSensitive = caseSensitive, ConfigurationLocations = configurationLocations }) + { + } + + /// + /// Create a new WebApplicationContext, loading the definitions + /// from the given XML resource. + /// + /// The application context name. + /// Flag specifying whether to make this context case sensitive or not. + /// Names of configuration resources. + /// Configuration resources. + public WebApplicationContext(string name, bool caseSensitive, string[] configurationLocations, IResource[] configurationResources) + : this(new WebApplicationContextArgs() { Name = name, CaseSensitive = caseSensitive, ConfigurationLocations = configurationLocations, ConfigurationResources=configurationResources }) { } @@ -91,9 +106,15 @@ namespace Spring.Context.Support /// The parent context. /// Names of configuration resources. public WebApplicationContext(string name, bool caseSensitive, IApplicationContext parentContext, - params string[] configurationLocations) : base(name, caseSensitive, parentContext) + params string[] configurationLocations) + : this(new WebApplicationContextArgs() { Name = name, CaseSensitive = caseSensitive, ParentContext = parentContext, ConfigurationLocations = configurationLocations }) + { } + + + public WebApplicationContext(WebApplicationContextArgs args) + : base(args.Name, args.CaseSensitive, args.ParentContext) { - _configurationLocations = configurationLocations; + _configurationLocations = args.ConfigurationLocations; DefaultResourceProtocol = WebUtils.DEFAULT_RESOURCE_PROTOCOL; Refresh(); @@ -106,6 +127,7 @@ namespace Spring.Context.Support } } + /// /// returns detailed instance information for debugging /// @@ -154,11 +176,11 @@ namespace Spring.Context.Support { string firstRequestPath = HttpRuntime.AppDomainAppVirtualPath.TrimEnd('/') + "/dummy.context"; s_weblog.Info("Forcing first request " + firstRequestPath); - SafeMethod fnProcessRequestNow = new SafeMethod(typeof(HttpRuntime).GetMethod("ProcessRequestNow", BindingFlags.Static|BindingFlags.NonPublic)); + SafeMethod fnProcessRequestNow = new SafeMethod(typeof(HttpRuntime).GetMethod("ProcessRequestNow", BindingFlags.Static | BindingFlags.NonPublic)); SimpleWorkerRequest wr = new SimpleWorkerRequest(firstRequestPath, string.Empty, new StringWriter()); fnProcessRequestNow.Invoke(null, new object[] { wr }); -// HttpRuntime.ProcessRequest( -// wr); + // HttpRuntime.ProcessRequest( + // wr); s_weblog.Info("Successfully processed first request!"); } catch (Exception ex) @@ -192,7 +214,7 @@ namespace Spring.Context.Support ///
public static IApplicationContext GetRootContext() { - return GetContextInternal( ("" + HttpRuntime.AppDomainAppVirtualPath).TrimEnd('/') + "/dummy.context"); + return GetContextInternal(("" + HttpRuntime.AppDomainAppVirtualPath).TrimEnd('/') + "/dummy.context"); } /// @@ -219,7 +241,7 @@ namespace Spring.Context.Support { string virtualDirectory = WebUtils.GetVirtualDirectory(virtualPath); string contextName = virtualDirectory; - if ( 0 == string.Compare( contextName , ("" + HttpRuntime.AppDomainAppVirtualPath).TrimEnd('/') + "/", true) ) + if (0 == string.Compare(contextName, ("" + HttpRuntime.AppDomainAppVirtualPath).TrimEnd('/') + "/", true)) { contextName = DefaultRootContextName; } @@ -234,7 +256,7 @@ namespace Spring.Context.Support s_weblog.Debug(string.Format("looking up web context '{0}' in WebContextCache", contextName)); } // first lookup in our own cache - IApplicationContext context = (IApplicationContext) s_webContextCache[contextName]; + IApplicationContext context = (IApplicationContext)s_webContextCache[contextName]; if (context != null) { // found - nothing to do anymore @@ -347,19 +369,34 @@ namespace Spring.Context.Support /// Reader to initialize. protected override void InitObjectDefinitionReader(XmlObjectDefinitionReader objectDefinitionReader) { -// NamespaceParserRegistry.RegisterParser(typeof(WebObjectsNamespaceParser)); + // NamespaceParserRegistry.RegisterParser(typeof(WebObjectsNamespaceParser)); } /// - /// Return an array of resource locations, referring to the XML object - /// definition files that this context should be built with. + /// An array of resource locations, referring to the XML object + /// definition files with which this context is to be built. /// - /// an array of resource locations, or null if none + /// + /// An array of resource locations, or if none. + /// + /// protected override string[] ConfigurationLocations { get { return _configurationLocations; } } + /// + /// An array of resources instances with which this context is to be built. + /// + /// + /// An array of s, or if none. + /// + /// + protected override IResource[] ConfigurationResources + { + get { return _configurationResources; } + } + /// /// Creates web object factory for this context using parent context's factory as a parent. /// diff --git a/src/Spring/Spring.Web/Context/Support/WebApplicationContextArgs.cs b/src/Spring/Spring.Web/Context/Support/WebApplicationContextArgs.cs new file mode 100644 index 00000000..fffd473f --- /dev/null +++ b/src/Spring/Spring.Web/Context/Support/WebApplicationContextArgs.cs @@ -0,0 +1,40 @@ +#region License + +/* + * Copyright © 2002-2005 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + + +using System; +using System.Collections.Generic; +using System.Text; + +namespace Spring.Context.Support +{ + + public class WebApplicationContextArgs : AbstractXmlApplicationContextArgs + { + /// + /// Initializes a new instance of the WebApplicationContextArgs class. + /// + public WebApplicationContextArgs() + { + CaseSensitive = false; + } + + } +} diff --git a/src/Spring/Spring.Web/Spring.Web.2008.csproj b/src/Spring/Spring.Web/Spring.Web.2008.csproj index 510dba2e..54032d1c 100644 --- a/src/Spring/Spring.Web/Spring.Web.2008.csproj +++ b/src/Spring/Spring.Web/Spring.Web.2008.csproj @@ -110,6 +110,7 @@ Code + diff --git a/test/Spring/Spring.Core.Tests/Context/Support/XmlApplicationContentArgsTests.cs b/test/Spring/Spring.Core.Tests/Context/Support/XmlApplicationContentArgsTests.cs new file mode 100644 index 00000000..6814ea62 --- /dev/null +++ b/test/Spring/Spring.Core.Tests/Context/Support/XmlApplicationContentArgsTests.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; +using NUnit.Framework; + +namespace Spring.Context.Support +{ + [TestFixture] + public class XmlApplicationContentArgsTests + { + [Test] + public void Default_CaseSensitivity_isTrue() + { + XmlApplicationContextArgs args = new XmlApplicationContextArgs(); + Assert.True(args.CaseSensitive); + } + + [Test] + public void Default_AutoRefresh_isTrue() + { + XmlApplicationContextArgs args = new XmlApplicationContextArgs(); + Assert.True(args.Refresh); + } + } +} diff --git a/test/Spring/Spring.Core.Tests/Core/IO/ConfigSectionResourceTests.cs b/test/Spring/Spring.Core.Tests/Core/IO/ConfigSectionResourceTests.cs index 3042fce2..f6ecf487 100644 --- a/test/Spring/Spring.Core.Tests/Core/IO/ConfigSectionResourceTests.cs +++ b/test/Spring/Spring.Core.Tests/Core/IO/ConfigSectionResourceTests.cs @@ -74,15 +74,15 @@ namespace Spring.Core.IO [Test] public void ThrowsIoExceptionIfConfigSectionDoesNotExist() { - IResource res = new ConfigSectionResource("DOES NOT EXIST"); + IResource res = new ConfigSectionResource(Guid.NewGuid().ToString()); + try { Stream istm = res.InputStream; - Assert.Fail(); + Assert.Fail("Did not receive expected IOException!"); } - catch(IOException ioex) - { - Console.WriteLine(ioex); + catch(IOException) + { } } } diff --git a/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2008.csproj b/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2008.csproj index 78ac3611..018e0c24 100644 --- a/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2008.csproj +++ b/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2008.csproj @@ -217,6 +217,7 @@ Code + Code diff --git a/test/Spring/Spring.Data.Tests/Transaction/Config/TxNamespaceParserTests.cs b/test/Spring/Spring.Data.Tests/Transaction/Config/TxNamespaceParserTests.cs index e26329ff..e167536e 100644 --- a/test/Spring/Spring.Data.Tests/Transaction/Config/TxNamespaceParserTests.cs +++ b/test/Spring/Spring.Data.Tests/Transaction/Config/TxNamespaceParserTests.cs @@ -61,6 +61,11 @@ namespace Spring.Transaction.Config { get { return null; } } + + protected override IResource[] ConfigurationResources + { + get { return null; } + } } private const string APPCTXCFG_PROLOG = @""; diff --git a/test/Spring/Spring.Web.Tests/Context/Support/WebApplicationContextArgsTests.cs b/test/Spring/Spring.Web.Tests/Context/Support/WebApplicationContextArgsTests.cs new file mode 100644 index 00000000..923b2382 --- /dev/null +++ b/test/Spring/Spring.Web.Tests/Context/Support/WebApplicationContextArgsTests.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; +using NUnit.Framework; + +namespace Spring.Context.Support +{ + [TestFixture] + public class WebApplicationContextArgsTests + { + [Test] + public void Default_CaseSensitivity_isFalse() + { + WebApplicationContextArgs args = new WebApplicationContextArgs(); + Assert.False(args.CaseSensitive); + } + } +} diff --git a/test/Spring/Spring.Web.Tests/Spring.Web.Tests.2008.csproj b/test/Spring/Spring.Web.Tests/Spring.Web.Tests.2008.csproj index f26b1205..04f037d5 100644 --- a/test/Spring/Spring.Web.Tests/Spring.Web.Tests.2008.csproj +++ b/test/Spring/Spring.Web.Tests/Spring.Web.Tests.2008.csproj @@ -91,6 +91,7 @@ +