Fixed loading of web.config for TARGET_J2EE.
authorEyal Alalouf <eyala@mainsoft.com>
Mon, 25 Jul 2005 17:54:50 +0000 (17:54 -0000)
committerEyal Alalouf <eyala@mainsoft.com>
Mon, 25 Jul 2005 17:54:50 +0000 (17:54 -0000)
svn path=/trunk/mcs/; revision=47661

mcs/class/System.Web/System.Web.Configuration/ChangeLog
mcs/class/System.Web/System.Web.Configuration/WebConfigurationSettings.cs

index 92916f80e6709917f418b7b5693885cb3afbe3bb..7702e90ddc4d5e2206954d2e3d19ac6443cae410 100644 (file)
@@ -1,3 +1,7 @@
+2005-07-25  Eyal Alalouf  <eyala@mainsoft.com>
+       * WebConfigurationSettings.cs: Fixed LoadFromFile to find web.config under
+         TARGET_J2EE (case sensitivity).
+
 2005-07-25  Eyal Alalouf  <eyala@mainsoft.com>
        * WebConfigurationSettings.cs: TARGET_J2EE ifdef reorder for readability.
 
index 8e48867a83587336a4fbe84c0d6364a70038e358..9e9af3e2cc7d5d8e6b180ef92fae5ed2b06a496a 100644 (file)
@@ -441,66 +441,32 @@ namespace System.Web.Configuration
                        factories = new Hashtable ();
                }
 
-#if TARGET_J2EE
                public bool LoadFromFile (string fileName)
                {
                        this.fileName = fileName;
-                       if (fileName == null)
-                               return false;
-                       XmlTextReader reader = null;
-                       java.io.InputStream inputStream = null;
-                       try {
-                               IResourceLoader resLoader = (IResourceLoader)AppDomain.CurrentDomain.GetData("GH_ResourceLoader");
-                               if (resLoader == null)
-                                       throw new HttpException("Unexpected exception. Resource loader not initialized under current domain");
-                               if (fileName.StartsWith(IAppDomainConfig.WAR_ROOT_SYMBOL))
-                                       fileName = fileName.Substring(IAppDomainConfig.WAR_ROOT_SYMBOL.Length);
-
-                               inputStream = resLoader.getResourceAsStream(fileName);
-
-                               // patch for machine.config
-                               if (inputStream == null && fileName.EndsWith("machine.config"))
+                       Stream fs = null;
+                       if (fileName == null || !File.Exists (fileName)) {
+#if TARGET_J2EE
+                               if (fileName != null && fileName.EndsWith("machine.config"))
                                {
                                        if (fileName.StartsWith("/"))
                                                fileName = fileName.Substring(1);
                                        java.lang.ClassLoader cl = (java.lang.ClassLoader)AppDomain.CurrentDomain.GetData("GH_ContextClassLoader");
-                                       if (cl != null)
-                                               inputStream = cl.getResourceAsStream(fileName);
+                                       if (cl == null)
+                                               return false;
+                                       java.io.InputStream inputStream = cl.getResourceAsStream(fileName);
+                                       fs = (Stream)IOUtils.getStream(inputStream);
                                }
-                               if (inputStream == null)
+                               else
+#endif
                                        return false;
-
-                               Stream fs = (Stream)IOUtils.getStream(inputStream);
-                               reader = new XmlTextReader (fs);
-                               InitRead (reader);
-                               ReadConfig (reader, false);
-                       } 
-                       catch (ConfigurationException) { throw; }
-                       catch (Exception e)
-                       {
-                               throw new ConfigurationException ("Error reading " + fileName, e);
-                       }
-                       finally
-                       {
-                               if (reader != null)
-                                       reader.Close();
-                               if (inputStream != null)
-                                       inputStream.close();
                        }
 
-                       return true;
-               }
-#else
-               public bool LoadFromFile (string fileName)
-               {
-                       this.fileName = fileName;
-                       if (fileName == null || !File.Exists (fileName))
-                               return false;
-
                        XmlTextReader reader = null;
 
                        try {
-                               FileStream fs = new FileStream (fileName, FileMode.Open, FileAccess.Read);
+                               if (fs == null)
+                                       fs = new FileStream (fileName, FileMode.Open, FileAccess.Read);
                                reader = new XmlTextReader (fs);
                                InitRead (reader);
                                ReadConfig (reader, false);
@@ -515,7 +481,6 @@ namespace System.Web.Configuration
 
                        return true;
                }
-#endif
 
                public void LoadFromReader (XmlTextReader reader, string fakeFileName, bool isLocation)
                {