Author: kostat
Date: 2007-03-29 09:55:30 -0500 (Thu, 29 Mar 2007)
New Revision: 75145
Modified:
trunk/mcs/class/System.Web/System.Web.Compilation/AppResourcesCompiler.jvm.cs
trunk/mcs/class/System.Web/System.Web.Compilation/ThemeDirectoryCompiler.jvm.cs
trunk/mcs/class/System.Web/System.Web.J2EE/PageMapper.cs
trunk/mcs/class/System.Web/System.Web.Profile/ProfileParser.jvm.cs
trunk/mcs/class/System.Web/System.Web.UI/MasterPageParser.jvm.cs
trunk/mcs/class/System.Web/System.Web.UI/PageParser.jvm.cs
trunk/mcs/class/System.Web/System.Web.UI/TemplateControl.jvm.cs
trunk/mcs/class/System.Web/System.Web.UI/WebServiceParser.jvm.cs
trunk/mcs/class/System.Web/System.Web/HttpApplicationFactory.cs
Log:
Path HttpContext to the PageMapper and use it. Throw resource not available
exception at the highest level only - when it's known whether we should throw
Modified: trunk/mcs/class/System.Web/System.Web/HttpApplicationFactory.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web/HttpApplicationFactory.cs
2007-03-29 14:53:07 UTC (rev 75144)
+++ trunk/mcs/class/System.Web/System.Web/HttpApplicationFactory.cs
2007-03-29 14:55:30 UTC (rev 75145)
@@ -382,14 +382,14 @@
if (app_file != null) {
#if TARGET_J2EE
- app_type =
System.Web.J2EE.PageMapper.GetObjectType(app_file);
+ app_type =
System.Web.J2EE.PageMapper.GetObjectType(context, app_file);
#else
app_type =
ApplicationFileParser.GetCompiledApplicationType (app_file, context);
+#endif
if (app_type == null) {
string msg =
String.Format ("Error compiling application file ({0}).", app_file);
throw new
ApplicationException (msg);
}
-#endif
} else {
app_type = typeof
(System.Web.HttpApplication);
app_state = new
HttpApplicationState ();
Modified:
trunk/mcs/class/System.Web/System.Web.Compilation/AppResourcesCompiler.jvm.cs
===================================================================
---
trunk/mcs/class/System.Web/System.Web.Compilation/AppResourcesCompiler.jvm.cs
2007-03-29 14:53:07 UTC (rev 75144)
+++
trunk/mcs/class/System.Web/System.Web.Compilation/AppResourcesCompiler.jvm.cs
2007-03-29 14:55:30 UTC (rev 75145)
@@ -52,7 +52,7 @@
internal static Assembly GetCachedLocalResourcesAssembly
(string path)
{
string localResourcesPath = UrlUtils.Combine (path,
"App_LocalResources");
- return System.Web.J2EE.PageMapper.GetObjectAssembly
(localResourcesPath);
+ return System.Web.J2EE.PageMapper.GetObjectAssembly
(HttpContext.Current, localResourcesPath);
}
}
}
Modified:
trunk/mcs/class/System.Web/System.Web.Compilation/ThemeDirectoryCompiler.jvm.cs
===================================================================
---
trunk/mcs/class/System.Web/System.Web.Compilation/ThemeDirectoryCompiler.jvm.cs
2007-03-29 14:53:07 UTC (rev 75144)
+++
trunk/mcs/class/System.Web/System.Web.Compilation/ThemeDirectoryCompiler.jvm.cs
2007-03-29 14:55:30 UTC (rev 75145)
@@ -46,7 +46,7 @@
{
virtualPath = "~/App_Themes/" + virtualPath + "/";
string resolvedUrl =
System.Web.Util.UrlUtils.ResolveVirtualPathFromAppAbsolute
(virtualPath).TrimEnd('/');
- Type tmpType = PageMapper.GetObjectType (resolvedUrl);
+ Type tmpType = PageMapper.GetObjectType (context,
resolvedUrl);
if (tmpType == null)
throw new InvalidOperationException("ThemeDirectoryCompiler '"
+ virtualPath + "' not found");
Modified: trunk/mcs/class/System.Web/System.Web.J2EE/PageMapper.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.J2EE/PageMapper.cs 2007-03-29
14:53:07 UTC (rev 75144)
+++ trunk/mcs/class/System.Web/System.Web.J2EE/PageMapper.cs 2007-03-29
14:55:30 UTC (rev 75145)
@@ -50,7 +50,7 @@
Assembly resolvedAssembly = null;
try
{
- resolvedAssembly = GetCachedAssembly
(args.Name);
+ resolvedAssembly = GetCachedAssembly
(HttpContext.Current, args.Name);
}
catch (Exception ex)
{
@@ -132,7 +132,7 @@
}
#endif
- private static ICachedXmlDoc GetAssembliesCachedDocument()
+ private static ICachedXmlDoc
GetAssembliesCachedDocument(HttpContext context)
{
ICachedXmlDoc doc = (ICachedXmlDoc)
AppDomain.CurrentDomain.GetData (J2EEConsts.ASSEMBLIES_FILE);
@@ -147,7 +147,7 @@
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler
(CurrentDomain_AssemblyResolve);
try {
//Try to load
the global resources
-
HttpContext.AppGlobalResourcesAssembly = GetCachedAssembly
("app_globalresources");
+
HttpContext.AppGlobalResourcesAssembly = GetCachedAssembly (context,
"app_globalresources");
}
catch (Exception ex) {
#if DEBUG
@@ -176,44 +176,40 @@
return new CachedDocumentTypeStorage();
}
- public static Type GetObjectType(string url)
+ public static Type GetObjectType (HttpContext context, string
url)
{
- return GetCachedType(NormalizeName(url), true);
+ return GetCachedType(context, NormalizeName(url), true);
}
- public static Type GetObjectType (string url, bool
throwException) {
- return GetCachedType (NormalizeName (url),
throwException);
+ public static Type GetObjectType (HttpContext context, string
url, bool throwException) {
+ return GetCachedType (context, NormalizeName (url),
throwException);
}
- public static Assembly GetObjectAssembly(string url)
+ public static Assembly GetObjectAssembly (HttpContext context,
string url)
{
- return GetCachedAssembly(NormalizeName(url));
+ return GetCachedAssembly (context, NormalizeName (url));
}
- public static string GetAssemblyResource(string url)
+ public static string GetAssemblyResource (HttpContext context,
string url)
{
- return GetCachedResource(NormalizeName(url));
+ return GetCachedResource (context, NormalizeName (url));
}
- private static string GetCachedResource(string url)
+ private static string GetCachedResource (HttpContext context,
string url)
{
- ICachedXmlDoc doc =
PageMapper.GetAssembliesCachedDocument();
- return doc.GetAssemblyResourceName(url);
+ ICachedXmlDoc doc =
PageMapper.GetAssembliesCachedDocument(context);
+ return doc.GetAssemblyResourceName (context, url);
}
- private static Assembly GetCachedAssembly(string url)
+ private static Assembly GetCachedAssembly (HttpContext context,
string url)
{
- ICachedXmlDoc doc =
PageMapper.GetAssembliesCachedDocument();
- Assembly t = doc.GetAssembly(url);
- if (t == null)
- throw new HttpException(404, "The requested
resource (" + url + ") is not available.");
-
- return t;
+ ICachedXmlDoc doc =
PageMapper.GetAssembliesCachedDocument(context);
+ return doc.GetAssembly (context, url);
}
- private static Type GetCachedType (string url) {
- return GetCachedType (url, true);
+ private static Type GetCachedType (HttpContext context, string
url) {
+ return GetCachedType (context, url, true);
}
- private static Type GetCachedType (string url, bool
throwException)
+ private static Type GetCachedType (HttpContext context, string
url, bool throwException)
{
- ICachedXmlDoc doc =
PageMapper.GetAssembliesCachedDocument();
- Type t = doc.GetType(url);
+ ICachedXmlDoc doc =
PageMapper.GetAssembliesCachedDocument(context);
+ Type t = doc.GetType(context, url);
if (t == null && throwException)
throw new HttpException(404,"The requested
resource (" + url + ") is not available.");
@@ -223,9 +219,9 @@
#region ICachedXmlDoc interface
interface ICachedXmlDoc
{
- Type GetType(string key);
- Assembly GetAssembly(string key);
- string GetAssemblyResourceName(string key);
+ Type GetType (HttpContext context, string key);
+ Assembly GetAssembly (HttpContext context, string key);
+ string GetAssemblyResourceName (HttpContext context,
string key);
}
#endregion
@@ -249,17 +245,17 @@
this(DEFAULT_PAGES_NUMBER)
{}
- string ICachedXmlDoc.GetAssemblyResourceName(string o)
+ string ICachedXmlDoc.GetAssemblyResourceName
(HttpContext context, string o)
{
- return GetMetaByURL(o).Resource;
+ return GetMetaByURL(context, o).Resource;
}
- Type ICachedXmlDoc.GetType(string o)
+ Type ICachedXmlDoc.GetType (HttpContext context, string
o)
{
- return GetMetaByURL(o).Type;
+ return GetMetaByURL(context, o).Type;
}
- Assembly ICachedXmlDoc.GetAssembly(string o)
+ Assembly ICachedXmlDoc.GetAssembly (HttpContext
context, string o)
{
- return GetMetaByURL(o).Assembly;
+ return GetMetaByURL(context, o).Assembly;
}
internal IDictionaryEnumerator GetEnumerator()
@@ -272,17 +268,17 @@
//but only will became important in production mode
when dynamyc compilation will be enabled
//Anyway, locking whole table and compiling under lock
looks odd
//spivak.December 07 2006
- public MetaProvider GetMetaByURL(string url)
+ public MetaProvider GetMetaByURL(HttpContext context,
string url)
{
#if !NO_GLOBAL_LOCK_ON_COMPILE
- string lwUrl = url.ToLower();
+ string lwUrl = url.ToLowerInvariant();
lock (_table)
{
object retVal = _table[lwUrl];
if (retVal == null)
{
- retVal =
PageCompiler.GetCompiler(url);
+ retVal =
PageCompiler.GetCompiler(context, url);
_table[lwUrl] = retVal;
}
@@ -338,7 +334,6 @@
private static readonly string ASSEM_ATTRIB_NAME = "assem";
private static readonly string TYPE_ATTRIB_NAME = "type";
private static string _parser = null;
- private static PageCompiler _errorProvider = new PageCompiler();
private Type _type = null;
private string _typeName = null;
@@ -347,35 +342,21 @@
private string _xmlDescriptor = null;
private string _url = null;
private string _session = null;
+ readonly private HttpContext _context;
- PageCompiler(string url)
+ PageCompiler(HttpContext context, string url)
{
_url = url;
+ _context = context;
_xmlDescriptor = GetDescFromUrl();
_session = DateTime.Now.Ticks.ToString();
LoadTypeAndAssem();
}
- PageCompiler()
- {
- }
- public static PageCompiler Error
+ public static PageCompiler GetCompiler(HttpContext context,
string url)
{
- get
- {
- return _errorProvider;
- }
+ return new PageCompiler(context, url);
}
- public static PageCompiler GetCompiler(string url)
- {
- try{
- return new PageCompiler(url);
- }
- catch(Exception e)
- {
- return Error;
- }
- }
Type MetaProvider.Type
{
@@ -410,11 +391,11 @@
}
}
}
- private void InternalCompile()
+ private bool InternalCompile()
{
string fileName = Path.GetFileName(_url);
- string fullFileName = (fileName.ToLower() ==
"global.asax") ? _url : HttpContext.Current.Request.MapPath(_url);
+ string fullFileName = (fileName.ToLower () ==
"global.asax") ? _url : _context.Request.MapPath (_url);
#if DEBUG
Console.WriteLine("fullFileName=" + fullFileName);
#endif
@@ -424,11 +405,14 @@
string[] command =
GetParserCmd(fileName.ToLower() == "global.asax");
if (J2EEUtils.RunProc(command) != 0)
throw GetCompilerError();
+
+ return true;
}
else
{
- string message = "The requested resource (" +
_url + ") is not available.";
- throw new HttpException(404, message);
+ return false;
+ //string message = "The requested resource (" +
_url + ") is not available.";
+ //throw new HttpException(404, message);
}
}
private string GetDescriptorPath()
@@ -439,7 +423,7 @@
{
try
{
- using (StreamReader sr = new
StreamReader(HttpContext.Current.Request.MapPath("/" + GetDescriptorPath())))
+ using (StreamReader sr = new
StreamReader(_context.Request.MapPath("~/" + GetDescriptorPath())))
{
return
GetTypeFromDescStream(sr.BaseStream);
}
@@ -484,8 +468,8 @@
if (typeName == null)
{
//spawn dynamic compilation and lookup typename
from created folder
- InternalCompile();
- typeName = GetTypeNameFromAppFolder();
+ if (InternalCompile())
+ typeName = GetTypeNameFromAppFolder();
}
return typeName;
}
@@ -547,7 +531,7 @@
if (_parser == null)
{
StreamReader sr =
-
File.OpenText(HttpContext.Current.Request.MapPath("/AspxParser.params"));
+ File.OpenText (_context.Request.MapPath
("~/AspxParser.params"));
_parser = sr.ReadLine();
sr.Close();
}
@@ -582,7 +566,7 @@
private Exception GetCompilerError()
{
- string _errFile =
HttpContext.Current.Request.MapPath("/" + _session + ".vmwerr");
+ string _errFile = _context.Request.MapPath ("~/" +
_session + ".vmwerr");
if (!File.Exists(_errFile))
throw new FileNotFoundException("Internal
Error",_errFile);
Modified: trunk/mcs/class/System.Web/System.Web.Profile/ProfileParser.jvm.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Profile/ProfileParser.jvm.cs
2007-03-29 14:53:07 UTC (rev 75144)
+++ trunk/mcs/class/System.Web/System.Web.Profile/ProfileParser.jvm.cs
2007-03-29 14:55:30 UTC (rev 75145)
@@ -53,7 +53,7 @@
//PageMapper call
string virtualPath = "~/App_Code/ProfileCommon";
string resolvedUrl =
System.Web.Util.UrlUtils.ResolveVirtualPathFromAppAbsolute
(virtualPath).TrimEnd ('/');
- profileBaseType = PageMapper.GetObjectType
(resolvedUrl, false);
+ profileBaseType = PageMapper.GetObjectType
(context, resolvedUrl, false);
ProfileCommonTypeExists = profileBaseType !=
null;
}
@@ -70,7 +70,7 @@
//PageMapper call
string virtualPath = "~/App_Code/ProfileGroup"
+ groupName;
string resolvedUrl =
System.Web.Util.UrlUtils.ResolveVirtualPathFromAppAbsolute
(virtualPath).TrimEnd ('/');
- profileGroupType = PageMapper.GetObjectType
(resolvedUrl, false);
+ profileGroupType = PageMapper.GetObjectType
(context, resolvedUrl, false);
ProfileGroupTypeExists = profileGroupType !=
null;
}
Modified: trunk/mcs/class/System.Web/System.Web.UI/MasterPageParser.jvm.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/MasterPageParser.jvm.cs
2007-03-29 14:53:07 UTC (rev 75144)
+++ trunk/mcs/class/System.Web/System.Web.UI/MasterPageParser.jvm.cs
2007-03-29 14:55:30 UTC (rev 75145)
@@ -49,7 +49,7 @@
public static MasterPage GetCompiledMasterInstance (string
virtualPath, string inputFile, HttpContext context)
{
string resolvedUrl =
System.Web.Util.UrlUtils.ResolveVirtualPathFromAppAbsolute (virtualPath);
- Type tmpType = PageMapper.GetObjectType (resolvedUrl);
+ Type tmpType = PageMapper.GetObjectType (context,
resolvedUrl);
if (tmpType == null)
throw new InvalidOperationException ("Master
page '" + virtualPath + "' not found");
Modified: trunk/mcs/class/System.Web/System.Web.UI/PageParser.jvm.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/PageParser.jvm.cs 2007-03-29
14:53:07 UTC (rev 75144)
+++ trunk/mcs/class/System.Web/System.Web.UI/PageParser.jvm.cs 2007-03-29
14:55:30 UTC (rev 75145)
@@ -46,7 +46,7 @@
string
inputFile,
HttpContext
context)
{
- Type tmpType = PageMapper.GetObjectType(virtualPath);
+ Type tmpType = PageMapper.GetObjectType(context,
virtualPath);
if (tmpType == null)
throw new InvalidOperationException
("Documentation page '" + virtualPath + "' not found");
Object obj = Activator.CreateInstance(tmpType);
Modified: trunk/mcs/class/System.Web/System.Web.UI/TemplateControl.jvm.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/TemplateControl.jvm.cs
2007-03-29 14:53:07 UTC (rev 75144)
+++ trunk/mcs/class/System.Web/System.Web.UI/TemplateControl.jvm.cs
2007-03-29 14:55:30 UTC (rev 75145)
@@ -276,7 +276,7 @@
throw new ArgumentNullException ("virtualPath");
string vpath = UrlUtils.Combine
(TemplateSourceDirectory, virtualPath);
- return PageMapper.GetObjectType (vpath);
+ return PageMapper.GetObjectType (Context, vpath);
}
public Control LoadControl (string virtualPath)
@@ -352,7 +352,9 @@
java.lang.ClassLoader contextClassLoader =
c.getClassLoader ();
//TODO:move this code to page mapper
- string assemblyName = PageMapper.GetAssemblyResource
(this.AppRelativeVirtualPath);
+ string assemblyName = PageMapper.GetAssemblyResource
(HttpContext.Current, this.AppRelativeVirtualPath);
+ if (assemblyName == null)
+ throw new HttpException (404, "The requested
resource (" + this.AppRelativeVirtualPath + ") is not available.");
java.io.InputStream inputStream =
contextClassLoader.getResourceAsStream (assemblyName);
Modified: trunk/mcs/class/System.Web/System.Web.UI/WebServiceParser.jvm.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/WebServiceParser.jvm.cs
2007-03-29 14:53:07 UTC (rev 75144)
+++ trunk/mcs/class/System.Web/System.Web.UI/WebServiceParser.jvm.cs
2007-03-29 14:55:30 UTC (rev 75145)
@@ -39,8 +39,8 @@
public class WebServiceParser
{
public static Type GetCompiledType (string filePath,
HttpContext context)
- {
- return
PageMapper.GetObjectType(context.Request.FilePath);
+ {
+ return PageMapper.GetObjectType (context,
context.Request.FilePath);
}
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches