+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
void PreStart ()
{
+#if !TARGET_J2EE
HttpRuntime.TimeoutManager.Add (context);
+#endif
Thread th = Thread.CurrentThread;
if (app_culture != null) {
prev_app_culture = th.CurrentCulture;
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;
}
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
{
theFactory.FireOnAppEnd ();
}
-
+
+#if !TARGET_JVM
FileSystemWatcher CreateWatcher (string file, FileSystemEventHandler hnd)
{
FileSystemWatcher watcher = new FileSystemWatcher ();
app_file_watcher.EnableRaisingEvents = false;
HttpRuntime.UnloadAppDomain ();
}
+#endif
internal static void AttachEvents (HttpApplication app)
{
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)
{
// 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");
CallContext.SetData ("c", value);
}
}
+#endif
public Exception Error {
get {
Flush ();
}
+#if !TARGET_JVM
public void WriteFile (IntPtr fileHandle, long offset, long size)
{
if (offset < 0)
return;
Flush ();
}
+#endif
public void WriteFile (string filename, long offset, long size)
{
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 ();
cache = new Cache ();
do_RealProcessRequest = new WaitCallback (RealProcessRequest);
}
-
+
public HttpRuntime ()
{
}
+#endif
#region AppDomain handling
//
}
}
+#if !TARGET_JVM
internal static TimeoutManager TimeoutManager {
get {
return timeout_manager;
}
}
+#endif
#if NET_2_0
static ApplicationShutdownReason shutdown_reason = ApplicationShutdownReason.None;
public virtual IntPtr GetUserToken ()
{
- return (IntPtr) 0;
+ return IntPtr.Zero;
}
public bool HasEntityBody ()
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];
SendResponseFromMemory (copy, length);
}
+#endif
public virtual void SetEndOfSendNotification (HttpWorkerRequest.EndOfSendNotification callback, object extraData)
{
public virtual IntPtr GetVirtualPathToken ()
{
- return (IntPtr) 0;
+ return IntPtr.Zero;
}
#endregion