TARGET_J2EE/JVM fixes
authorEyal Alalouf <eyala@mainsoft.com>
Thu, 1 Sep 2005 11:49:55 +0000 (11:49 -0000)
committerEyal Alalouf <eyala@mainsoft.com>
Thu, 1 Sep 2005 11:49:55 +0000 (11:49 -0000)
svn path=/trunk/mcs/; revision=49259

mcs/class/System.Web/System.Web/ChangeLog
mcs/class/System.Web/System.Web/HttpApplication.cs
mcs/class/System.Web/System.Web/HttpApplicationFactory.cs
mcs/class/System.Web/System.Web/HttpContext.cs
mcs/class/System.Web/System.Web/HttpResponse.cs
mcs/class/System.Web/System.Web/HttpRuntime.cs
mcs/class/System.Web/System.Web/HttpWorkerRequest.cs

index 301188994f93be886878d459c470b9db6df4683d..1e6a03d93cec54389adbef50e5fa7aa30cd1b310 100644 (file)
@@ -1,3 +1,9 @@
+2005-09-01 Eyal Alaluf <eyala@mainsoft.com>
+
+       * HttpContext.cs HttpResponse.cs HttpWorkerRequest.cs HttpRuntime.cs
+         HttpApplicationFactory.cs HttpApplication.cs: TARGET_J2EE/JVM fixes.
+         Mostly workaround limited AppModel in TARGET_J2EE.
+
 2005-08-31 Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * HttpResponse.cs: if the request method is HEAD, that's equivalent to
index 5ecdfa54cee9a2b62bd81a0b6883abfe5ae09aae..390a6ffbdef2824f2b018d7d67b5ba38a092b295 100644 (file)
@@ -891,7 +891,9 @@ namespace System.Web {
 
                void PreStart ()
                {
+#if !TARGET_J2EE
                        HttpRuntime.TimeoutManager.Add (context);
+#endif
                        Thread th = Thread.CurrentThread;
                        if (app_culture != null) {
                                prev_app_culture = th.CurrentCulture;
@@ -903,20 +905,26 @@ namespace System.Web {
                                th.CurrentCulture = appui_culture;
                        }
 
+#if !TARGET_JVM
                        prev_user = Thread.CurrentPrincipal;
+#endif
                }
 
                void PostDone ()
                {
                        Thread th = Thread.CurrentThread;
+#if !TARGET_JVM
                        if (Thread.CurrentPrincipal != prev_user)
                                Thread.CurrentPrincipal = prev_user;
+#endif
                        if (prev_appui_culture != null && prev_appui_culture != th.CurrentUICulture)
                                th.CurrentUICulture = prev_appui_culture;
                        if (prev_app_culture != null && prev_app_culture != th.CurrentCulture)
                                th.CurrentCulture = prev_app_culture;
 
+#if !TARGET_J2EE
                        HttpRuntime.TimeoutManager.Remove (context);
+#endif
                        context = null;
                        HttpContext.Current = null;
                }
index 8f8ad505f62f28a67df3237f5a7236f10e0d6dae..d57384dd1c87a3be1b9639d43fb3e9defb112b82 100644 (file)
@@ -72,8 +72,10 @@ namespace System.Web {
                bool needs_init = true;
                Type app_type;
                HttpApplicationState app_state;
+#if !TARGET_JVM
                FileSystemWatcher app_file_watcher;
                FileSystemWatcher bin_watcher;
+#endif
                Stack available = new Stack ();
                
                // Watch this thing out when getting an instance
@@ -179,7 +181,8 @@ namespace System.Web {
                {
                        theFactory.FireOnAppEnd ();
                }
-                       
+
+#if !TARGET_JVM
                FileSystemWatcher CreateWatcher (string file, FileSystemEventHandler hnd)
                {
                        FileSystemWatcher watcher = new FileSystemWatcher ();
@@ -202,6 +205,7 @@ namespace System.Web {
                        app_file_watcher.EnableRaisingEvents = false;
                        HttpRuntime.UnloadAppDomain ();
                }
+#endif
 
                internal static void AttachEvents (HttpApplication app)
                {
index a2534d6eb9a9e0aa80b257a5e621ffcf2d0948f3..dac40e93bd9345671f68b3cb682409549fd4b818 100644 (file)
@@ -60,6 +60,9 @@ namespace System.Web {
                object config_timeout;
                int timeout_possible;
                DateTime time_stamp = DateTime.UtcNow;
+#if TARGET_JVM // No remoting support (CallContext) yet in Grasshopper
+               static LocalDataStoreSlot _ContextSlot = Thread.GetNamedDataSlot ("Context");
+#endif
                
                public HttpContext (HttpWorkerRequest wr)
                {
@@ -116,6 +119,14 @@ namespace System.Web {
                // The "Current" property is set just after we have constructed it with 
                // the 'HttpContext (HttpWorkerRequest)' constructor.
                //
+#if TARGET_JVM // No remoting support (CallContext) yet in Grasshopper
+               [MonoTODO("Context - Use System.Remoting.Messaging.CallContext instead of Thread storage")]
+               public static HttpContext Current
+               {
+                       get { return (HttpContext) Thread.GetData (_ContextSlot); }
+                       set { Thread.SetData (_ContextSlot, value); }
+               }
+#else
                public static HttpContext Current {
                        get {
                                return (HttpContext) CallContext.GetData ("c");
@@ -125,6 +136,7 @@ namespace System.Web {
                                CallContext.SetData ("c", value);
                        }
                }
+#endif
 
                public Exception Error {
                        get {
index 991a7234551f4398524b77a95332d4979ae4bf1f..b4fdb94ed5fc5e9be2f3e40bf332cdb52e638fe6 100644 (file)
@@ -788,6 +788,7 @@ namespace System.Web {
                        Flush ();
                }
 
+#if !TARGET_JVM
                public void WriteFile (IntPtr fileHandle, long offset, long size)
                {
                        if (offset < 0)
@@ -805,6 +806,7 @@ namespace System.Web {
                                return;
                        Flush ();
                }
+#endif
 
                public void WriteFile (string filename, long offset, long size)
                {
index 9490ae0b502cac8c0a3da5c983fb452c01bee41b..cc4f6991047ec13f798766d96b52100abb8aee1e 100644 (file)
@@ -42,12 +42,49 @@ using System.Threading;
 namespace System.Web {
        
        public sealed class HttpRuntime {
+#if TARGET_J2EE
+               static QueueManager queue_manager { get { return _runtime._queue_manager; } }
+               static TraceManager trace_manager { get { return _runtime._trace_manager; } }
+               static Cache cache { get { return _runtime._cache; } }
+               static WaitCallback do_RealProcessRequest;
+
+               QueueManager _queue_manager;
+               TraceManager _trace_manager;
+               Cache _cache;
+
+               static HttpRuntime ()
+               {
+                       do_RealProcessRequest = new WaitCallback (RealProcessRequest);
+               }
+
+               public HttpRuntime ()
+               {
+                       _queue_manager = new QueueManager ();
+                       _trace_manager = new TraceManager ();
+                       _cache = new Cache ();
+               }
+
+               static private HttpRuntime _runtime {
+                       get {
+                               HttpRuntime runtime = (HttpRuntime)AppDomain.CurrentDomain.GetData("HttpRuntime");
+                               if (runtime == null)
+                                       lock (typeof(HttpRuntime)) {
+                                               runtime = (HttpRuntime)AppDomain.CurrentDomain.GetData("HttpRuntime");
+                                               if (runtime == null) {
+                                                       runtime = new HttpRuntime();
+                                                       AppDomain.CurrentDomain.SetData("HttpRuntime", runtime);
+                                               }
+                                       }
+                               return runtime;
+                       }
+               }
+#else
                static QueueManager queue_manager;
                static TraceManager trace_manager;
                static TimeoutManager timeout_manager;
                static Cache cache;
                static WaitCallback do_RealProcessRequest;
-               
+
                static HttpRuntime ()
                {
                        queue_manager = new QueueManager ();
@@ -56,10 +93,11 @@ namespace System.Web {
                        cache = new Cache ();
                        do_RealProcessRequest = new WaitCallback (RealProcessRequest);
                }
-               
+
                public HttpRuntime ()
                {
                }
+#endif
 
 #region AppDomain handling
                //
@@ -270,11 +308,13 @@ namespace System.Web {
                        }
                }
 
+#if !TARGET_JVM
                internal static TimeoutManager TimeoutManager {
                        get {
                                return timeout_manager;
                        }
                }
+#endif
 
 #if NET_2_0
                static ApplicationShutdownReason shutdown_reason = ApplicationShutdownReason.None;
index d4da3dae19f3fdb840b7055e7d5d8d3a6cbebd84..de8e38446799666e28affb7a42ebe39b4913f3b9 100644 (file)
@@ -208,7 +208,7 @@ namespace System.Web {
 
                public virtual IntPtr GetUserToken ()
                {
-                       return (IntPtr) 0;
+                       return IntPtr.Zero;
                }
 
                public bool HasEntityBody ()
@@ -253,6 +253,12 @@ namespace System.Web {
                        throw new NotImplementedException ();
                }
 
+#if TARGET_JVM
+               public virtual void SendResponseFromMemory (IntPtr data, int length)
+               {
+                       throw new NotImplementedException("SendResponseFromMemory: unsafe buffers (IntPtr) are not supported");
+               }
+#else
                public virtual void SendResponseFromMemory (IntPtr data, int length)
                {
                        byte [] copy = new byte [length];
@@ -261,6 +267,7 @@ namespace System.Web {
 
                        SendResponseFromMemory (copy, length);
                }
+#endif
 
                public virtual void SetEndOfSendNotification (HttpWorkerRequest.EndOfSendNotification callback, object extraData)
                {
@@ -559,7 +566,7 @@ namespace System.Web {
 
                public virtual IntPtr GetVirtualPathToken ()
                {
-                       return (IntPtr) 0;
+                       return IntPtr.Zero;
                }
 #endregion