Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Web/Web/Support
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv4775/src/Spring/Spring.Web/Web/Support
Modified Files:
PageHandlerFactory.cs
Log Message:
fixed SPRNET-899
Index: PageHandlerFactory.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Web/Web/Support/PageHandlerFactory.cs,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** PageHandlerFactory.cs 21 Mar 2008 14:12:29 -0000 1.36
--- PageHandlerFactory.cs 26 Mar 2008 23:29:43 -0000 1.37
***************
*** 19,22 ****
--- 19,24 ----
#endregion
+ #region Imports
+
using System;
using System.Collections;
***************
*** 35,38 ****
--- 37,42 ----
using Spring.Web.Process;
+ #endregion
+
namespace Spring.Web.Support
{
***************
*** 67,71 ****
private readonly ILog Log = LogManager.GetLogger(typeof(PageHandlerFactory));
! private IDictionary handlers = CollectionsUtil.CreateCaseInsensitiveHashtable();
/// <summary>
--- 71,75 ----
private readonly ILog Log = LogManager.GetLogger(typeof(PageHandlerFactory));
! private readonly IDictionary pageHandlerWrappers = CollectionsUtil.CreateCaseInsensitiveHashtable();
/// <summary>
***************
*** 87,151 ****
if (isDebug) Log.Debug(string.Format("GetHandler():resolving url '{0}'", url));
! IHttpHandler handler;
!
! lock (handlers.SyncRoot)
! {
! handler = (IHttpHandler)handlers[url];
! if (handler != null)
! {
! if (isDebug)
! Log.Debug(string.Format("GetHandler():resolved url '{0}' from reusable handler cache", url));
! return handler;
! }
! }
!
!
! IConfigurableApplicationContext appContext =
! WebApplicationContext.GetContext(url) as IConfigurableApplicationContext;
! if (appContext == null)
{
! throw new InvalidOperationException(
! "Implementations of IApplicationContext must also implement IConfigurableApplicationContext");
}
! string appRelativeVirtualPath = WebUtils.GetAppRelativePath(url);
! NamedObjectDefinition namedPageDefinition = FindWebObjectDefinition(appRelativeVirtualPath, appContext.ObjectFactory);
!
! if (namedPageDefinition != null)
{
! Type pageType = namedPageDefinition.ObjectDefinition.ObjectType;
! if (typeof(IRequiresSessionState).IsAssignableFrom(pageType))
! {
! handler = new SessionAwarePageHandler(appContext, namedPageDefinition.Name, url, null);
! }
! else
{
! handler = new PageHandler(appContext, namedPageDefinition.Name, url, null);
}
}
else
{
! Type pageType = null;
! pageType = WebObjectUtils.GetCompiledPageType(url);
! if (typeof(IRequiresSessionState).IsAssignableFrom(pageType))
{
! handler = new SessionAwarePageHandler(appContext, appRelativeVirtualPath, url, physicalPath);
}
else
{
! handler = new PageHandler(appContext, appRelativeVirtualPath, url, physicalPath);
}
- }
! if (handler.IsReusable)
! {
! lock (handlers.SyncRoot)
{
! handlers[url] = handler;
}
}
return handler;
}
--- 91,139 ----
if (isDebug) Log.Debug(string.Format("GetHandler():resolving url '{0}'", url));
! PageHandlerWrapper pageHandlerWrapper;
! lock (pageHandlerWrappers.SyncRoot)
{
! pageHandlerWrapper = (PageHandlerWrapper)pageHandlerWrappers[url];
}
! if (pageHandlerWrapper != null)
{
! if (isDebug)
{
! Log.Debug(string.Format("GetHandler():resolved url '{0}' from reusable handler cache", url));
}
}
else
{
! IConfigurableApplicationContext appContext =
! WebApplicationContext.GetContext(url) as IConfigurableApplicationContext;
! if (appContext == null)
{
! throw new InvalidOperationException(
! "Implementations of IApplicationContext must also implement IConfigurableApplicationContext");
! }
!
! string appRelativeVirtualPath = WebUtils.GetAppRelativePath(url);
! NamedObjectDefinition namedPageDefinition = FindWebObjectDefinition(appRelativeVirtualPath, appContext.ObjectFactory);
!
! if (namedPageDefinition != null)
! {
! pageHandlerWrapper = new PageHandlerWrapper(appContext, namedPageDefinition.Name, url, null);
}
else
{
! pageHandlerWrapper = new PageHandlerWrapper(appContext, appRelativeVirtualPath, url, physicalPath);
}
! lock (pageHandlerWrappers.SyncRoot)
{
! pageHandlerWrappers[url] = pageHandlerWrapper;
}
}
+ IHttpHandler handler;
+ handler = pageHandlerWrapper.GetHandler(context);
return handler;
}
***************
*** 161,165 ****
/// override non-virtual methods from the base Page class.
/// </remarks>
! internal class PageHandler : System.Web.UI.Page, IHttpHandler
{
private readonly IApplicationContext appContext;
--- 149,153 ----
/// override non-virtual methods from the base Page class.
/// </remarks>
! internal class PageHandlerWrapper
{
private readonly IApplicationContext appContext;
***************
*** 179,183 ****
/// <summary>
! /// Initializes a new instance of the <see cref="PageHandler"/> class.
/// </summary>
/// <param name="appContext">Application context instance to retrieve page from.</param>
--- 167,171 ----
/// <summary>
! /// Initializes a new instance of the <see cref="PageHandlerWrapper"/> class.
/// </summary>
/// <param name="appContext">Application context instance to retrieve page from.</param>
***************
*** 185,189 ****
/// <param name="url">Requested page URL.</param>
/// <param name="path">Translated server path for the page.</param>
! public PageHandler(IApplicationContext appContext, string pageName, string url, string path)
{
this.appContext = appContext;
--- 173,177 ----
/// <param name="url">Requested page URL.</param>
/// <param name="path">Translated server path for the page.</param>
! public PageHandlerWrapper(IApplicationContext appContext, string pageName, string url, string path)
{
this.appContext = appContext;
***************
*** 194,202 ****
/// <summary>
! /// Initializes a new instance of the <see cref="PageHandler"/> class.
/// </summary>
/// <param name="appContext">Application context instance to retrieve page from.</param>
/// <param name="pageName">Name of the page object to execute.</param>
! public PageHandler(IApplicationContext appContext, string pageName)
: this(appContext, pageName, null, null)
{
--- 182,190 ----
/// <summary>
! /// Initializes a new instance of the <see cref="PageHandlerWrapper"/> class.
/// </summary>
/// <param name="appContext">Application context instance to retrieve page from.</param>
/// <param name="pageName">Name of the page object to execute.</param>
! public PageHandlerWrapper(IApplicationContext appContext, string pageName)
: this(appContext, pageName, null, null)
{
***************
*** 228,238 ****
#endregion
! #region IHttpHandler Members
!
! /// <summary>
! /// Creates instance of the page and delegates call to it.
! /// </summary>
! /// <param name="context">HttpContext of the current page request.</param>
! void IHttpHandler.ProcessRequest(HttpContext context)
{
IHttpHandler handler = cachedHandler;
--- 216,220 ----
#endregion
! public IHttpHandler GetHandler(HttpContext context)
{
IHttpHandler handler = cachedHandler;
***************
*** 255,274 ****
ApplySharedState(handler);
ApplyDependencyInjection(handler);
!
! context.Handler = handler;
! handler.ProcessRequest(context);
! }
!
! /// <summary>
! /// Returns true because this wrapper handler can be reused.
! /// Actual page is instantiated at the beginning of the ProcessRequest method.
! /// </summary>
! bool IHttpHandler.IsReusable
! {
! get { return true; }
}
- #endregion
-
/// <summary>
/// Creates a page instance corresponding to this handler's url.
--- 237,243 ----
ApplySharedState(handler);
ApplyDependencyInjection(handler);
! return handler;
}
/// <summary>
/// Creates a page instance corresponding to this handler's url.
***************
*** 358,393 ****
}
}
- }
! /// <summary>
! /// Wrapper for handlers that require <see cref="HttpSessionState"/>.
! /// </summary>
! /// <remarks>
! /// Delays page object instantiation until ProcessRequest is called
! /// in order to be able to access session state.
! /// </remarks>
! internal class SessionAwarePageHandler : PageHandler, IRequiresSessionState
! {
! /// <summary>
! /// Initializes a new instance of the <see cref="SessionAwarePageHandler"/> class.
! /// </summary>
! /// <param name="appContext">Application context instance to retrieve page from.</param>
! /// <param name="pageName">Name of the page object to execute.</param>
! /// <param name="url">Requested page URL.</param>
! /// <param name="path">Translated server path for the page.</param>
! public SessionAwarePageHandler(IApplicationContext appContext, string pageName, string url, string path)
! : base(appContext, pageName, url, path)
! {
! }
/// <summary>
! /// Initializes a new instance of the <see cref="SessionAwarePageHandler"/> class.
/// </summary>
! /// <param name="appContext">Application context instance to retrieve page from.</param>
! /// <param name="pageName">Name of the page object to execute.</param>
! public SessionAwarePageHandler(IApplicationContext appContext, string pageName)
! : base(appContext, pageName)
{
}
! }
}
\ No newline at end of file
--- 327,390 ----
}
}
! /*
! #region IHttpHandler Members
!
! /// <summary>
! /// Creates instance of the page and delegates call to it.
! /// </summary>
! /// <param name="context">HttpContext of the current page request.</param>
! void IHttpHandler.ProcessRequest(HttpContext context)
! {
! IHttpHandler handler = GetHandler(context);
!
! context.Handler = handler;
! handler.ProcessRequest(context);
! }
!
! /// <summary>
! /// Returns true because this wrapper handler can be reused.
! /// Actual page is instantiated at the beginning of the ProcessRequest method.
! /// </summary>
! bool IHttpHandler.IsReusable
! {
! get { return true; }
! }
+ #endregion
+ */
+ }
+ /*
/// <summary>
! /// Wrapper for handlers that require <see cref="HttpSessionState"/>.
/// </summary>
! /// <remarks>
! /// Delays page object instantiation until ProcessRequest is called
! /// in order to be able to access session state.
! /// </remarks>
! internal class SessionAwarePageHandler : PageHandler, IRequiresSessionState
{
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SessionAwarePageHandler"/> class.
+ /// </summary>
+ /// <param name="appContext">Application context instance to retrieve page from.</param>
+ /// <param name="pageName">Name of the page object to execute.</param>
+ /// <param name="url">Requested page URL.</param>
+ /// <param name="path">Translated server path for the page.</param>
+ public SessionAwarePageHandler(IApplicationContext appContext, string pageName, string url, string path)
+ : base(appContext, pageName, url, path)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SessionAwarePageHandler"/> class.
+ /// </summary>
+ /// <param name="appContext">Application context instance to retrieve page from.</param>
+ /// <param name="pageName">Name of the page object to execute.</param>
+ public SessionAwarePageHandler(IApplicationContext appContext, string pageName)
+ : base(appContext, pageName)
+ {
+ }
}
! */
}
\ No newline at end of file
|