Author: gonzalo
Date: 2006-08-10 18:06:30 -0400 (Thu, 10 Aug 2006)
New Revision: 63627
Modified:
trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog
trunk/mcs/class/System.Web/System.Web.Compilation/ClientBuildManager.cs
trunk/mcs/class/System.Web/System.Web.Hosting/ApplicationManager.cs
trunk/mcs/class/System.Web/System.Web.Hosting/BareApplicationHost.cs
trunk/mcs/class/System.Web/System.Web.Hosting/ChangeLog
Log:
2006-08-10 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* System.Web.Hosting/BareApplicationHost.cs:
* System.Web.Hosting/ApplicationManager.cs: remove unloaded domains.
* System.Web.Compilation/ClientBuildManager.cs: handle domain shutdown
and unload. Implemented some properties. Commented.
Modified: trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog 2006-08-10
21:41:59 UTC (rev 63626)
+++ trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog 2006-08-10
22:06:30 UTC (rev 63627)
@@ -1,3 +1,8 @@
+2006-08-10 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+ * ClientBuildManager.cs: handle domain shutdown and unload.
+ Implemented some properties. Commented.
+
2006-08-10 Andrew Skiba <[EMAIL PROTECTED]>
* ThemeDirectoryCompiler.cs: render css path as a virtual path.
Modified:
trunk/mcs/class/System.Web/System.Web.Compilation/ClientBuildManager.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Compilation/ClientBuildManager.cs
2006-08-10 21:41:59 UTC (rev 63626)
+++ trunk/mcs/class/System.Web/System.Web.Compilation/ClientBuildManager.cs
2006-08-10 22:06:30 UTC (rev 63627)
@@ -30,11 +30,11 @@
//
#if NET_2_0
-
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections;
+using System.Globalization;
using System.IO;
using System.Web;
using System.Web.Hosting;
@@ -45,17 +45,30 @@
string phys_src_dir;
string phys_target_dir;
ClientBuildManagerParameter build_params;
+ BareApplicationHost host;
+ ApplicationManager manager;
+ string app_id;
+ string cache_path;
public ClientBuildManager (string appVirtualDir, string
appPhysicalSourceDir)
{
+ if (appVirtualDir == null || appVirtualDir == "")
+ throw new ArgumentNullException
("appVirtualDir");
+ if (appPhysicalSourceDir == null ||
appPhysicalSourceDir == "")
+ throw new ArgumentNullException
("appPhysicalSourceDir");
+
virt_dir = appVirtualDir; // TODO: adjust vpath (it
allows 'blah' that turns into '/blah', '////blah', '\\blah'...
phys_src_dir = appPhysicalSourceDir;
+ manager = ApplicationManager.GetApplicationManager ();
}
public ClientBuildManager (string appVirtualDir, string
appPhysicalSourceDir,
string appPhysicalTargetDir)
: this (appVirtualDir, appPhysicalSourceDir)
{
+ if (appPhysicalTargetDir == null ||
appPhysicalTargetDir == "")
+ throw new ArgumentNullException
("appPhysicalTargetDir");
+
phys_target_dir = appPhysicalTargetDir;
}
@@ -66,37 +79,58 @@
build_params = parameter;
}
- string CreateCodeGenDir ()
+ public event BuildManagerHostUnloadEventHandler
AppDomainShutdown;
+ public event EventHandler AppDomainStarted;
+ public event BuildManagerHostUnloadEventHandler
AppDomainUnloaded;
+
+ BareApplicationHost Host {
+ get {
+ if (host != null)
+ return host;
+
+ int hashcode = virt_dir.GetHashCode ();
+ if (app_id != null)
+ hashcode ^= Int32.Parse (app_id);
+
+ app_id = hashcode.ToString
(CultureInfo.InvariantCulture);
+ host = manager.CreateHostWithCheck (app_id,
virt_dir, phys_src_dir);
+ cache_path = "";
+ //cache_path = Path.Combine (Path.GetTempPath
(),
+ //String.Format
("{0}-temp-aspnet-{1:x}", Environment.UserName, i));
+
+ int hash = virt_dir.GetHashCode () << 5 +
phys_src_dir.GetHashCode ();
+ cache_path = Path.Combine (cache_path,
hash.ToString (CultureInfo.InvariantCulture));
+ Directory.CreateDirectory (cache_path);
+ OnAppDomainStarted ();
+ return host;
+ }
+ }
+
+ void OnAppDomainStarted ()
{
- return null;
- /*
- string appname = null;
- if (virt_dir == "/") {
- appname = "root";
- } else {
- appname = virt_dir.Subtring (1).Replace ('/',
'_');
+ if (AppDomainStarted != null)
+ AppDomainStarted (this, EventArgs.Empty);
+ }
+
+ void OnAppDomainShutdown (ApplicationShutdownReason reason)
+ {
+ if (AppDomainShutdown != null) {
+ BuildManagerHostUnloadEventArgs args = new
BuildManagerHostUnloadEventArgs (reason);
+ AppDomainShutdown (this, args);
}
+ }
- string dynamic_dir = null;
- string user = Environment.UserName;
- for (int i = 0; ; i++){
- string d = Path.Combine (Path.GetTempPath (),
- String.Format ("{0}-temp-aspnet-{1:x}",
user, i));
-
- try {
- Directory.CreateDirectory (d);
- string stamp = Path.Combine (d,
"stamp");
- Directory.CreateDirectory (stamp);
- dynamic_dir = d;
- Directory.Delete (stamp);
- break;
- } catch (UnauthorizedAccessException){
- continue;
- }
+ void OnDomainUnload (object sender, EventArgs args)
+ {
+ OnAppDomainUnloaded (0); // FIXME: set a reason?
+ }
+
+ void OnAppDomainUnloaded (ApplicationShutdownReason reason)
+ {
+ if (AppDomainUnloaded != null) {
+ BuildManagerHostUnloadEventArgs args = new
BuildManagerHostUnloadEventArgs (reason);
+ AppDomainUnloaded (this, args);
}
- setup.DynamicBase = dynamic_dir;
- Directory.CreateDirectory (setup.DynamicBase);
- */
}
[MonoTODO]
@@ -113,37 +147,64 @@
[MonoTODO]
public void CompileFile (string virtualPath,
ClientBuildManagerCallback callback)
{
+ // 1. Creates the Host
+ // This creates a .compiled file + an assembly
+ // App_Code reported to be built *before* anything else
(with progress callback)
throw new NotImplementedException ();
}
- [MonoTODO]
public IRegisteredObject CreateObject (Type type, bool
failIfExists)
{
- throw new NotImplementedException ();
+ return manager.CreateObject (app_id, type, virt_dir,
phys_src_dir, failIfExists);
}
- [MonoTODO]
public string GenerateCode (string virtualPath, string
virtualFileString, out IDictionary linePragmasTable)
{
- throw new NotImplementedException ();
+ // This thing generates a .ccu (CodeCompileUnit?) file
(reported as TrueType font data by 'file'!)
+ // resultType=7 vs. resultType=3 for assemblies
reported in the .compiled file
+ // The virtual path is just added to the dependencies
list, but is checked to be an absolute path.
+ // IsHostCreated returns true after calling this method.
+ //
+ // A null file string causes virtualPath to be mapped
and read to generate the code
+ //
+
+ if (virtualPath == null || virtualPath == "")
+ throw new ArgumentNullException ("virtualPath");
+
+ CodeCompileUnit unit = null;
+ Type cprovider_type;
+ CompilerParameters parameters;
+ unit = GenerateCodeCompileUnit (virtualPath,
virtualFileString, out cprovider_type,
+ out parameters, out
linePragmasTable);
+ return null;
}
[MonoTODO]
- public CodeCompileUnit GenerateCodeCompileUnit (string
virtualPath, string virtualFileString, out Type codeDomProviderType, out
CompilerParameters compilerParameters, out IDictionary linePragmasTable)
+ public CodeCompileUnit GenerateCodeCompileUnit (string
virtualPath,
+ string
virtualFileString,
+ out Type
codeDomProviderType,
+ out
CompilerParameters compilerParameters,
+ out IDictionary
linePragmasTable)
{
throw new NotImplementedException ();
}
- [MonoTODO]
- public CodeCompileUnit GenerateCodeCompileUnit (string
virtualPath, out Type codeDomProviderType, out CompilerParameters
compilerParameters, out IDictionary linePragmasTable)
+ public CodeCompileUnit GenerateCodeCompileUnit (string
virtualPath,
+ out Type
codeDomProviderType,
+ out
CompilerParameters compilerParameters,
+ out IDictionary
linePragmasTable)
{
- throw new NotImplementedException ();
+ return GenerateCodeCompileUnit (virtualPath, out
codeDomProviderType,
+ out compilerParameters,
out linePragmasTable);
}
- [MonoTODO]
+ static string [] shutdown_directories = new string [] {
+ "bin", "App_GlobalResources",
"App_Code",
+ "App_WebReferences",
"App_Browsers" };
+
public string [] GetAppDomainShutdownDirectories ()
{
- throw new NotImplementedException ();
+ return shutdown_directories;
}
[MonoTODO]
@@ -153,7 +214,10 @@
}
[MonoTODO]
- public void GetCodeDirectoryInformation (string virtualCodeDir,
out Type codeDomProviderType, out CompilerParameters compilerParameters, out
string generatedFilesDir)
+ public void GetCodeDirectoryInformation (string virtualCodeDir,
+ out Type
codeDomProviderType,
+ out CompilerParameters
compilerParameters,
+ out string
generatedFilesDir)
{
throw new NotImplementedException ();
}
@@ -161,11 +225,15 @@
[MonoTODO]
public Type GetCompiledType (string virtualPath)
{
+ // CompileFile + get the type based on .compiled file
information
+ // Throws if virtualPath is a special virtual directory
(App_Code et al)
throw new NotImplementedException ();
}
[MonoTODO]
- public void GetCompilerParameters (string virtualPath, out Type
codeDomProviderType, out CompilerParameters compilerParameters)
+ public void GetCompilerParameters (string virtualPath,
+ out Type codeDomProviderType,
+ out CompilerParameters
compilerParameters)
{
throw new NotImplementedException ();
}
@@ -173,24 +241,28 @@
[MonoTODO]
public string GetGeneratedFileVirtualPath (string filePath)
{
+ // returns empty string for any vpath. Test with real
paths.
throw new NotImplementedException ();
}
[MonoTODO]
public string GetGeneratedSourceFile (string virtualPath)
{
+ // This one takes a directory name /xxx and
/xxx/App_Code throw either
+ // a KeyNotFoundException or an
InvalidOperationException
throw new NotImplementedException ();
}
[MonoTODO]
- public string[ ] GetTopLevelAssemblyReferences (string
virtualPath)
+ public string [] GetTopLevelAssemblyReferences (string
virtualPath)
{
throw new NotImplementedException ();
}
- [MonoTODO]
- public string[ ] GetVirtualCodeDirectories ()
+ public string [] GetVirtualCodeDirectories ()
{
+ // Host is created here when needed.
(Unload()+GetVirtualCodeDirectories()+IsHostCreated -> true)
+ //return Host.
throw new NotImplementedException ();
}
@@ -202,6 +274,7 @@
[MonoTODO]
public bool IsCodeAssembly (string assemblyName)
{
+ // Trying all the assemblies loaded by FullName and
GetName().Name yield false here :-?
throw new NotImplementedException ();
}
@@ -223,39 +296,31 @@
throw new NotImplementedException ();
}
- [MonoTODO]
public bool Unload ()
{
- throw new NotImplementedException ();
+ if (host != null) {
+ host.Shutdown ();
+ OnAppDomainShutdown (0);
+ host = null;
+ }
+
+ return true; // FIXME: may be we should do this synch.
+ timeout? Test!
}
- [MonoTODO]
public string CodeGenDir {
- get {
- throw new NotImplementedException ();
- }
+ get { return Host.GetCodeGenDir (); }
}
- [MonoTODO]
public bool IsHostCreated {
- get {
- throw new NotImplementedException ();
- }
+ get { return host != null; }
}
- public event BuildManagerHostUnloadEventHandler
AppDomainShutdown;
- public event EventHandler AppDomainStarted;
- public event BuildManagerHostUnloadEventHandler
AppDomainUnloaded;
-
-
- [MonoTODO]
void IDisposable.Dispose ()
{
- throw new NotImplementedException ();
+ Unload ();
}
-
}
}
+#endif
-#endif
Modified: trunk/mcs/class/System.Web/System.Web.Hosting/ApplicationManager.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Hosting/ApplicationManager.cs
2006-08-10 21:41:59 UTC (rev 63626)
+++ trunk/mcs/class/System.Web/System.Web.Hosting/ApplicationManager.cs
2006-08-10 22:06:30 UTC (rev 63627)
@@ -106,10 +106,10 @@
}
// Used from ClientBuildManager
- internal BareApplicationHost CreateOrReuseHost (string appId,
string vpath, string ppath)
+ internal BareApplicationHost CreateHostWithCheck (string appId,
string vpath, string ppath)
{
if (id_to_host.ContainsKey (appId))
- return id_to_host [appId];
+ throw new InvalidOperationException ("Already
have a host with the same appId");
return CreateHost (appId, vpath, ppath);
}
@@ -118,10 +118,17 @@
{
BareApplicationHost host;
host = (BareApplicationHost)
ApplicationHost.CreateApplicationHost (typeof (BareApplicationHost), vpath,
ppath);
+ host.Manager = this;
+ host.AppID = appId;
id_to_host [appId] = host;
return host;
}
+ internal void RemoveHost (string appId)
+ {
+ id_to_host.Remove (appId);
+ }
+
IRegisteredObject CheckIfExists (BareApplicationHost host, Type
type, bool failIfExists)
{
IRegisteredObject ireg = host.GetObject (type);
Modified: trunk/mcs/class/System.Web/System.Web.Hosting/BareApplicationHost.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Hosting/BareApplicationHost.cs
2006-08-10 21:41:59 UTC (rev 63626)
+++ trunk/mcs/class/System.Web/System.Web.Hosting/BareApplicationHost.cs
2006-08-10 22:06:30 UTC (rev 63627)
@@ -46,6 +46,8 @@
string vpath;
string phys_path;
Dictionary<Type, RegisteredItem> hash;
+ internal ApplicationManager Manager;
+ internal string AppID;
public BareApplicationHost ()
{
@@ -70,6 +72,10 @@
get { return phys_path; }
}
+ public AppDomain Domain {
+ get { return AppDomain.CurrentDomain; }
+ }
+
public void Shutdown ()
{
HostingEnvironment.InitiateShutdown ();
@@ -114,6 +120,7 @@
void OnDomainUnload (object sender, EventArgs args)
{
+ Manager.RemoveHost (AppID);
ICollection<RegisteredItem> values = hash.Values;
RegisteredItem [] objects = new RegisteredItem
[hash.Count];
values.CopyTo (objects, 0);
Modified: trunk/mcs/class/System.Web/System.Web.Hosting/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Hosting/ChangeLog 2006-08-10
21:41:59 UTC (rev 63626)
+++ trunk/mcs/class/System.Web/System.Web.Hosting/ChangeLog 2006-08-10
22:06:30 UTC (rev 63627)
@@ -1,3 +1,8 @@
+2006-08-10 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+ * BareApplicationHost.cs:
+ * ApplicationManager.cs: remove unloaded domains.
+
2006-03-23 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* SimpleWorkerRequest.cs: use UrlUtils instead of Path. Several fixes
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches