Author: igorz
Date: 2007-12-25 09:32:18 -0500 (Tue, 25 Dec 2007)
New Revision: 91876
Modified:
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/ServletFacesPageHandler.cs
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/ServletFacesPageHandlerFactory.cs
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/SessionWrapper.cs
Log:
1. refactoring
2. make Jsf handler IServiceProvider
Modified:
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/ServletFacesPageHandler.cs
===================================================================
---
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/ServletFacesPageHandler.cs
2007-12-25 12:12:52 UTC (rev 91875)
+++
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/ServletFacesPageHandler.cs
2007-12-25 14:32:18 UTC (rev 91876)
@@ -15,20 +15,22 @@
namespace Mainsoft.Web.Hosting
{
- public sealed class ServletFacesPageHandler : IHttpHandler
+ public sealed class ServletFacesPageHandler : IHttpHandler,
IServiceProvider
{
readonly FacesContextFactory _facesContextFactory;
readonly Lifecycle _lifecycle;
readonly string _executionFilePath;
+ readonly Type _pageType;
public bool IsReusable {
get { return false; }
}
- public ServletFacesPageHandler (string executionFilePath,
FacesContextFactory facesContextFactory, Lifecycle lifecycle) {
+ public ServletFacesPageHandler (string executionFilePath, Type
pageType, FacesContextFactory facesContextFactory, Lifecycle lifecycle) {
_facesContextFactory = facesContextFactory;
_lifecycle = lifecycle;
_executionFilePath = executionFilePath;
+ _pageType = pageType;
}
public void ProcessRequest (HttpContext context) {
@@ -43,7 +45,7 @@
Trace.WriteLine ("FacesPageHandler:
before execute");
_lifecycle.execute (facesContext);
Trace.WriteLine ("FacesPageHandler:
after execute");
-
+
Trace.WriteLine ("FacesPageHandler:
before render");
_lifecycle.render (facesContext);
Trace.WriteLine ("FacesPageHandler:
after render");
@@ -59,5 +61,11 @@
facesContext.release ();
}
}
+
+ public object GetService (Type serviceType) {
+ if (serviceType == typeof (Type))
+ return _pageType;
+ return null;
+ }
}
}
Modified:
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/ServletFacesPageHandlerFactory.cs
===================================================================
---
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/ServletFacesPageHandlerFactory.cs
2007-12-25 12:12:52 UTC (rev 91875)
+++
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/ServletFacesPageHandlerFactory.cs
2007-12-25 14:32:18 UTC (rev 91876)
@@ -9,14 +9,16 @@
using System;
using javax.faces.webapp;
using javax.faces;
+using System.Web.J2EE;
namespace Mainsoft.Web.Hosting
{
public sealed class ServletFacesPageHandlerFactory :
BaseFacesPageHandlerFactory
{
public override IHttpHandler GetHandler (HttpContext context,
string requestType, string url, string path) {
- IHttpHandler handler = new ServletFacesPageHandler
(url, FacesContextFactory, Lifecycle);
- return SessionWrapper.WrapHandler (handler, context,
url);
+ Type pageType = PageMapper.GetObjectType (context, url);
+ IHttpHandler handler = new ServletFacesPageHandler
(url, pageType, FacesContextFactory, Lifecycle);
+ return SessionWrapper.WrapHandler (handler);
}
}
}
Modified: trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/SessionWrapper.cs
===================================================================
--- trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/SessionWrapper.cs
2007-12-25 12:12:52 UTC (rev 91875)
+++ trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/SessionWrapper.cs
2007-12-25 14:32:18 UTC (rev 91876)
@@ -12,16 +12,16 @@
static readonly Type IRequiresSessionStateType = typeof
(IRequiresSessionState);
static readonly Type IReadOnlySessionStateType = typeof
(IReadOnlySessionState);
- public static IHttpHandler WrapHandler (IHttpHandler handler,
HttpContext context, string url) {
- Type type = PageMapper.GetObjectType (context, url);
+ public static IHttpHandler WrapHandler (IHttpHandler handler) {
+ Type type = (Type) ((IServiceProvider)
handler).GetService (typeof (Type));
if (IRequiresSessionStateType.IsAssignableFrom (type))
return
IReadOnlySessionStateType.IsAssignableFrom (type) ?
new ReadOnlySessionWrapperHandler
(handler) : new SessionWrapperHandler (handler);
return handler;
}
- public static IHttpHandler WrapHandler (IHttpExtendedHandler
handler, HttpContext context, string url) {
- Type type = PageMapper.GetObjectType (context, url);
+ public static IHttpHandler WrapHandler (IHttpExtendedHandler
handler) {
+ Type type = (Type) ((IServiceProvider)
handler).GetService (typeof (Type));
if (IRequiresSessionStateType.IsAssignableFrom (type))
return
IReadOnlySessionStateType.IsAssignableFrom (type) ?
@@ -31,7 +31,7 @@
#region SessionWrappers
- class SessionWrapperHandler : IHttpHandler,
IRequiresSessionState
+ class SessionWrapperHandler : IHttpHandler,
IRequiresSessionState, IServiceProvider
{
protected readonly IHttpHandler _handler;
@@ -46,6 +46,10 @@
public void ProcessRequest (HttpContext context) {
_handler.ProcessRequest (context);
}
+
+ public object GetService (Type serviceType) {
+ return ((IServiceProvider) _handler).GetService
(serviceType);
+ }
}
sealed class ReadOnlySessionWrapperHandler :
SessionWrapperHandler, IReadOnlySessionState
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches