Author: igorz
Date: 2007-12-06 04:40:13 -0500 (Thu, 06 Dec 2007)
New Revision: 90796
Added:
branches/mainsoft/JSF/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/SessionWrapper.cs
Modified:
branches/mainsoft/JSF/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/ServletFacesPageHandlerFactory.cs
branches/mainsoft/JSF/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/ServletFacesViewHandler.cs
branches/mainsoft/JSF/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.csproj
Log:
added session support using SessionWrapper
Modified:
branches/mainsoft/JSF/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/ServletFacesPageHandlerFactory.cs
===================================================================
---
branches/mainsoft/JSF/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/ServletFacesPageHandlerFactory.cs
2007-12-06 09:31:02 UTC (rev 90795)
+++
branches/mainsoft/JSF/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/ServletFacesPageHandlerFactory.cs
2007-12-06 09:40:13 UTC (rev 90796)
@@ -49,8 +49,8 @@
request,
response,
_lifecycle);
-
- return new ServletFacesPageHandler
(AspNetFacesContext.WrapFacesContext (facesContext, context), _lifecycle);
+ IHttpHandler handler = new ServletFacesPageHandler
(AspNetFacesContext.WrapFacesContext (facesContext, context), _lifecycle);
+ return SessionWrapper.WrapHandler (handler, context,
url);
}
public virtual void ReleaseHandler (IHttpHandler handler) {
Modified:
branches/mainsoft/JSF/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/ServletFacesViewHandler.cs
===================================================================
---
branches/mainsoft/JSF/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/ServletFacesViewHandler.cs
2007-12-06 09:31:02 UTC (rev 90795)
+++
branches/mainsoft/JSF/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/ServletFacesViewHandler.cs
2007-12-06 09:40:13 UTC (rev 90796)
@@ -16,5 +16,14 @@
public ServletFacesViewHandler (ViewHandler viewHandler)
: base (viewHandler) {
}
+
+ public override string getActionURL (FacesContext facesContext,
string viewId) {
+ if (viewId.Length > 0 && viewId [0] == '/') {
+ return facesContext.getExternalContext
().getRequestContextPath () + viewId;
+ }
+ else {
+ return viewId;
+ }
+ }
}
}
Added:
branches/mainsoft/JSF/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/SessionWrapper.cs
===================================================================
---
branches/mainsoft/JSF/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/SessionWrapper.cs
2007-12-06 09:31:02 UTC (rev 90795)
+++
branches/mainsoft/JSF/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/SessionWrapper.cs
2007-12-06 09:40:13 UTC (rev 90796)
@@ -0,0 +1,86 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Web;
+using System.Web.J2EE;
+using System.Web.SessionState;
+
+namespace Mainsoft.Web.Hosting
+{
+ public static class SessionWrapper
+ {
+ 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);
+
+ 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);
+
+ if (IRequiresSessionStateType.IsAssignableFrom (type))
+ return
IReadOnlySessionStateType.IsAssignableFrom (type) ?
+ new
ReadOnlySessionWrapperExtendedHandler (handler) : new
SessionWrapperExtendedHandler (handler);
+ return handler;
+ }
+
+ #region SessionWrappers
+
+ class SessionWrapperHandler : IHttpHandler,
IRequiresSessionState
+ {
+ protected readonly IHttpHandler _handler;
+
+ public SessionWrapperHandler (IHttpHandler handler) {
+ _handler = handler;
+ }
+
+ public bool IsReusable {
+ get { return _handler.IsReusable; }
+ }
+
+ public void ProcessRequest (HttpContext context) {
+ _handler.ProcessRequest (context);
+ }
+ }
+
+ sealed class ReadOnlySessionWrapperHandler :
SessionWrapperHandler, IReadOnlySessionState
+ {
+ public ReadOnlySessionWrapperHandler (IHttpHandler
handler) : base (handler) { }
+ }
+
+ #endregion
+
+ #region ExtendedSessionWrappers
+
+ class SessionWrapperExtendedHandler : SessionWrapperHandler,
IHttpExtendedHandler
+ {
+ public SessionWrapperExtendedHandler
(IHttpExtendedHandler handler)
+ : base (handler) {
+ }
+
+ public bool IsCompleted {
+ get { return ((IHttpExtendedHandler)
_handler).IsCompleted; }
+ }
+
+ public object GetContextState (HttpContext context) {
+ return ((IHttpExtendedHandler)
_handler).GetContextState (context);
+ }
+
+ public void SetContextState (HttpContext context,
object state) {
+ ((IHttpExtendedHandler)
_handler).SetContextState (context, state);
+ }
+ }
+
+ sealed class ReadOnlySessionWrapperExtendedHandler :
SessionWrapperExtendedHandler, IReadOnlySessionState
+ {
+ public ReadOnlySessionWrapperExtendedHandler
(IHttpExtendedHandler handler) : base (handler) { }
+ }
+
+ #endregion
+ }
+}
Modified: branches/mainsoft/JSF/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.csproj
===================================================================
--- branches/mainsoft/JSF/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.csproj
2007-12-06 09:31:02 UTC (rev 90795)
+++ branches/mainsoft/JSF/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.csproj
2007-12-06 09:40:13 UTC (rev 90796)
@@ -147,6 +147,7 @@
<Compile Include="Mainsoft.Web.Hosting\ServletFacesPageHandlerFactory.cs"
/>
<Compile Include="Mainsoft.Web.Hosting\ServletWorkerRequest.cs" />
<Compile Include="Mainsoft.Web.Hosting\ServletWorkerRequest.jvm.cs" />
+ <Compile Include="Mainsoft.Web.Hosting\SessionWrapper.cs" />
<Compile Include="Mainsoft.Web.Profile\CloudscapeProfileProvider.cs" />
<Compile Include="Mainsoft.Web.Profile\DerbyProfileHelper.cs" />
<Compile Include="Mainsoft.Web.Profile\DerbyProfileProvider.cs" />
@@ -169,4 +170,11 @@
<Compile Include="Mainsoft.Web\J2EEUtils.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference
Include="Mainsoft.Web.Phantom\Mainsoft.Web.Phantom.csproj">
+ <Project>{D01569DF-A398-480C-9A34-C231E760D7F8}</Project>
+ <Name>Mainsoft.Web.Phantom</Name>
+ <Private>False</Private>
+ </ProjectReference>
+ </ItemGroup>
</Project>
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches