Author: krasnov
Date: 2008-02-07 10:09:21 -0500 (Thu, 07 Feb 2008)
New Revision: 95144

Added:
   trunk/mcs/class/System.Web/System.Web.J2EE/ObjectInputStream.cs
   trunk/mcs/class/System.Web/System.Web.J2EE/ObjectOutputStream.cs
Modified:
   trunk/mcs/class/System.Web/ChangeLog
   trunk/mcs/class/System.Web/System.Web.UI/ChangeLog
   trunk/mcs/class/System.Web/System.Web.UI/Page.jvm.cs
   trunk/mcs/class/System.Web/System.Web/ChangeLog
   trunk/mcs/class/System.Web/System.Web/HttpContext.jvm.cs
   trunk/mcs/class/System.Web/System.Web20.csproj
Log:
* System.Web20.csproj: added ObjectInputStream.cs and ObjectOutputStream.cs
* Page.jvm.cs: added StateSerializer class, fixed processSaveState, 
processRestoreState
* HttpContext.jvm.cs: added CurrentHandlerInternal property

Modified: trunk/mcs/class/System.Web/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/ChangeLog        2008-02-07 15:07:53 UTC (rev 
95143)
+++ trunk/mcs/class/System.Web/ChangeLog        2008-02-07 15:09:21 UTC (rev 
95144)
@@ -1,3 +1,8 @@
+2008-02-07  Vladimir Krasnov  <[EMAIL PROTECTED]>
+
+       * System.Web20.csproj: added ObjectInputStream.cs and
+       ObjectOutputStream.cs
+
 2007-12-30  Vladimir Krasnov  <[EMAIL PROTECTED]>
 
        * System.Web.dll.sources: added AspNetDBSchemaChecker.cs

Modified: trunk/mcs/class/System.Web/System.Web/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web/ChangeLog     2008-02-07 15:07:53 UTC 
(rev 95143)
+++ trunk/mcs/class/System.Web/System.Web/ChangeLog     2008-02-07 15:09:21 UTC 
(rev 95144)
@@ -1,3 +1,7 @@
+2008-02-07  Vladimir Krasnov  <[EMAIL PROTECTED]>
+
+       * HttpContext.jvm.cs: added CurrentHandlerInternal property
+
 2008-02-07  Marek Habersack  <[EMAIL PROTECTED]>
 
        * HttpException.cs: moved several strings to constants, for easier

Modified: trunk/mcs/class/System.Web/System.Web/HttpContext.jvm.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web/HttpContext.jvm.cs    2008-02-07 
15:07:53 UTC (rev 95143)
+++ trunk/mcs/class/System.Web/System.Web/HttpContext.jvm.cs    2008-02-07 
15:09:21 UTC (rev 95144)
@@ -130,5 +130,12 @@
                        Request.SetWorkerRequest (wr);
                        Response.SetWorkerRequest (wr);
                }
+
+               private Page _currentHandlerInternal;
+               internal Page CurrentHandlerInternal
+               {
+                       get { return _currentHandlerInternal; }
+                       set { _currentHandlerInternal = value; }
+               }
        }
 }

Added: trunk/mcs/class/System.Web/System.Web.J2EE/ObjectInputStream.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.J2EE/ObjectInputStream.cs     
2008-02-07 15:07:53 UTC (rev 95143)
+++ trunk/mcs/class/System.Web/System.Web.J2EE/ObjectInputStream.cs     
2008-02-07 15:09:21 UTC (rev 95144)
@@ -0,0 +1,244 @@
+//
+// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
+//
+// Authors:
+//     Vladimir Krasnov <[EMAIL PROTECTED]>
+//     Konstantin Triger <[EMAIL PROTECTED]>
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using java.io;
+
+namespace Mainsoft.Web.Hosting
+{
+       public sealed class ObjectInputStream : System.IO.Stream, ObjectInput
+       {
+               readonly ObjectInput _javaObjectInput;
+
+               public ObjectInputStream (ObjectInput stream)
+               {
+                       _javaObjectInput = stream;
+               }
+
+               public override bool CanRead
+               {
+                       get
+                       {
+                               return true;
+                       }
+               }
+
+               public override bool CanWrite
+               {
+                       get
+                       {
+                               return false;
+                       }
+               }
+
+               public override bool CanSeek
+               {
+                       get
+                       {
+                               return true;
+                       }
+               }
+
+               public override long Length
+               {
+                       get
+                       {
+                               throw new NotSupportedException ();
+                       }
+               }
+
+               public override long Position
+               {
+                       get
+                       {
+                               throw new NotSupportedException ();
+                       }
+                       set
+                       {
+                               throw new NotSupportedException ();
+                       }
+               }
+
+               public override void Flush ()
+               {
+                       throw new NotSupportedException ();
+               }
+
+               public override long Seek (long offset, System.IO.SeekOrigin 
origin)
+               {
+                       if (origin == System.IO.SeekOrigin.Current)
+                               return _javaObjectInput.skip (offset);
+
+                       throw new NotSupportedException ();
+               }
+
+               public override void SetLength (long value)
+               {
+                       throw new NotSupportedException ();
+               }
+
+               public override int Read (byte [] buffer, int offset, int count)
+               {
+                       int rv = _javaObjectInput.read 
(vmw.common.TypeUtils.ToSByteArray (buffer), offset, count);
+                       return rv > 0 ? rv : 0;
+               }
+
+               public override void Write (byte [] buffer, int offset, int 
count)
+               {
+                       throw new NotSupportedException ();
+               }
+
+               public override int ReadByte ()
+               {
+                       return _javaObjectInput.read ();
+               }
+
+               public override void Close ()
+               {
+                       _javaObjectInput.close ();
+               }
+
+               #region ObjectInput Members
+
+               public int available ()
+               {
+                       return _javaObjectInput.available ();
+               }
+
+               public void close ()
+               {
+                       _javaObjectInput.close ();
+               }
+
+               public int read (sbyte [] __p1, int __p2, int __p3)
+               {
+                       return _javaObjectInput.read (__p1, __p2, __p3);
+               }
+
+               public int read (sbyte [] __p1)
+               {
+                       return _javaObjectInput.read (__p1);
+               }
+
+               public int read ()
+               {
+                       return _javaObjectInput.read ();
+               }
+
+               public object readObject ()
+               {
+                       return _javaObjectInput.readObject ();
+               }
+
+               public long skip (long __p1)
+               {
+                       return _javaObjectInput.skip (__p1);
+               }
+
+               #endregion
+
+               #region DataInput Members
+
+               public bool readBoolean ()
+               {
+                       return _javaObjectInput.readBoolean ();
+               }
+
+               public sbyte readByte ()
+               {
+                       return _javaObjectInput.readByte ();
+               }
+
+               public char readChar ()
+               {
+                       return _javaObjectInput.readChar ();
+               }
+
+               public double readDouble ()
+               {
+                       return _javaObjectInput.readDouble ();
+               }
+
+               public float readFloat ()
+               {
+                       return _javaObjectInput.readFloat ();
+               }
+
+               public void readFully (sbyte [] __p1, int __p2, int __p3)
+               {
+                       _javaObjectInput.readFully (__p1, __p2, __p3);
+               }
+
+               public void readFully (sbyte [] __p1)
+               {
+                       _javaObjectInput.readFully (__p1);
+               }
+
+               public int readInt ()
+               {
+                       return _javaObjectInput.readInt ();
+               }
+
+               public string readLine ()
+               {
+                       return _javaObjectInput.readLine ();
+               }
+
+               public long readLong ()
+               {
+                       return _javaObjectInput.readLong ();
+               }
+
+               public short readShort ()
+               {
+                       return _javaObjectInput.readShort ();
+               }
+
+               public string readUTF ()
+               {
+                       return _javaObjectInput.readUTF ();
+               }
+
+               public int readUnsignedByte ()
+               {
+                       return _javaObjectInput.readUnsignedByte ();
+               }
+
+               public int readUnsignedShort ()
+               {
+                       return _javaObjectInput.readUnsignedShort ();
+               }
+
+               public int skipBytes (int __p1)
+               {
+                       return _javaObjectInput.skipBytes (__p1);
+               }
+
+               #endregion
+       }
+
+}

Added: trunk/mcs/class/System.Web/System.Web.J2EE/ObjectOutputStream.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.J2EE/ObjectOutputStream.cs    
2008-02-07 15:07:53 UTC (rev 95143)
+++ trunk/mcs/class/System.Web/System.Web.J2EE/ObjectOutputStream.cs    
2008-02-07 15:09:21 UTC (rev 95144)
@@ -0,0 +1,220 @@
+//
+// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
+//
+// Authors:
+//     Vladimir Krasnov <[EMAIL PROTECTED]>
+//     Konstantin Triger <[EMAIL PROTECTED]>
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using java.io;
+
+namespace Mainsoft.Web.Hosting
+{
+       public sealed class ObjectOutputStream : System.IO.Stream, ObjectOutput
+       {
+               readonly ObjectOutput _javaObjectOutput;
+
+               public ObjectOutputStream (ObjectOutput stream)
+               {
+                       _javaObjectOutput = stream;
+               }
+
+               public override bool CanRead
+               {
+                       get
+                       {
+                               return false;
+                       }
+               }
+
+               public override bool CanSeek
+               {
+                       get
+                       {
+                               return false;
+                       }
+               }
+
+               public override bool CanWrite
+               {
+                       get
+                       {
+                               return true;
+                       }
+               }
+
+               public override void Close ()
+               {
+                       _javaObjectOutput.close ();
+               }
+
+               public override void Flush ()
+               {
+                       _javaObjectOutput.flush ();
+               }
+
+               public override long Length
+               {
+                       get
+                       {
+                               throw new NotSupportedException ();
+                       }
+               }
+
+               public override long Position
+               {
+                       get
+                       {
+                               throw new NotSupportedException ();
+                       }
+                       set
+                       {
+                               throw new NotSupportedException ();
+                       }
+               }
+
+               public override long Seek (long offset, System.IO.SeekOrigin 
origin)
+               {
+                       throw new NotSupportedException ();
+               }
+
+               public override void SetLength (long value)
+               {
+                       throw new NotSupportedException ();
+               }
+
+               public override int Read (byte [] buffer, int offset, int count)
+               {
+                       throw new NotSupportedException ();
+               }
+
+               public override void Write (byte [] buffer, int offset, int 
count)
+               {
+                       _javaObjectOutput.write 
(vmw.common.TypeUtils.ToSByteArray (buffer), offset, count);
+               }
+
+               public override void WriteByte (byte value)
+               {
+                       _javaObjectOutput.write (value);
+               }
+
+               public ObjectOutput NativeStream
+               {
+                       get { return _javaObjectOutput; }
+               }
+
+               #region ObjectOutput Members
+
+               public void close ()
+               {
+                       _javaObjectOutput.close ();
+               }
+
+               public void flush ()
+               {
+                       _javaObjectOutput.flush ();
+               }
+
+               public void write (sbyte [] __p1, int __p2, int __p3)
+               {
+                       _javaObjectOutput.write (__p1, __p2, __p3);
+               }
+
+               public void write (sbyte [] __p1)
+               {
+                       _javaObjectOutput.write (__p1);
+               }
+
+               public void write (int __p1)
+               {
+                       _javaObjectOutput.write (__p1);
+               }
+
+               public void writeObject (object __p1)
+               {
+                       _javaObjectOutput.writeObject (__p1);
+               }
+
+               #endregion
+
+               #region DataOutput Members
+
+
+               public void writeBoolean (bool __p1)
+               {
+                       _javaObjectOutput.writeBoolean (__p1);
+               }
+
+               public void writeByte (int __p1)
+               {
+                       _javaObjectOutput.writeByte (__p1);
+               }
+
+               public void writeBytes (string __p1)
+               {
+                       _javaObjectOutput.writeBytes (__p1);
+               }
+
+               public void writeChar (int __p1)
+               {
+                       _javaObjectOutput.writeChar (__p1);
+               }
+
+               public void writeChars (string __p1)
+               {
+                       _javaObjectOutput.writeChars (__p1);
+               }
+
+               public void writeDouble (double __p1)
+               {
+                       _javaObjectOutput.writeDouble (__p1);
+               }
+
+               public void writeFloat (float __p1)
+               {
+                       _javaObjectOutput.writeFloat (__p1);
+               }
+
+               public void writeInt (int __p1)
+               {
+                       _javaObjectOutput.writeInt (__p1);
+               }
+
+               public void writeLong (long __p1)
+               {
+                       _javaObjectOutput.writeLong (__p1);
+               }
+
+               public void writeShort (int __p1)
+               {
+                       _javaObjectOutput.writeShort (__p1);
+               }
+
+               public void writeUTF (string __p1)
+               {
+                       _javaObjectOutput.writeUTF (__p1);
+               }
+
+               #endregion
+       }
+}

Modified: trunk/mcs/class/System.Web/System.Web.UI/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/ChangeLog  2008-02-07 15:07:53 UTC 
(rev 95143)
+++ trunk/mcs/class/System.Web/System.Web.UI/ChangeLog  2008-02-07 15:09:21 UTC 
(rev 95144)
@@ -1,3 +1,8 @@
+2008-02-07  Vladimir Krasnov  <[EMAIL PROTECTED]>
+
+       * Page.jvm.cs: added StateSerializer class, fixed processSaveState,
+       processRestoreState
+
 2008-02-07  Marek Habersack  <[EMAIL PROTECTED]>
 
        * PageHandlerFactory.cs: call PageParser.GetCompiledPageInstance

Modified: trunk/mcs/class/System.Web/System.Web.UI/Page.jvm.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/Page.jvm.cs        2008-02-07 
15:07:53 UTC (rev 95143)
+++ trunk/mcs/class/System.Web/System.Web.UI/Page.jvm.cs        2008-02-07 
15:09:21 UTC (rev 95144)
@@ -43,6 +43,7 @@
 using javax.faces.component;
 using System.Threading;
 using System.Web.Configuration;
+using Mainsoft.Web.Hosting;
 
 namespace System.Web.UI
 {
@@ -106,6 +107,8 @@
                        _context.PushHandler (this);
                        if (jsfHandler == _context.Handler)
                                _context.Handler = this;
+                       
+                       _context.CurrentHandlerInternal = this;
 
                        return jsfHandler;
                }
@@ -200,17 +203,7 @@
                        System.Diagnostics.Trace.WriteLine ("processSaveState");
 
                        object state = new Pair (_state, GetValidatorsState ());
-                       if (getFacesContext ().getApplication 
().getStateManager ().isSavingStateInClient (getFacesContext ())) {
-                               int length;
-                               byte [] buffer = new ObjectStateFormatter 
(this).SerializeInternal (state, out length);
-                               if (buffer.Length != length) {
-                                       byte [] trimmedBuffer = new byte 
[length];
-                                       Array.Copy (buffer, trimmedBuffer, 
length);
-                                       buffer = trimmedBuffer;
-                               }
-                               state = vmw.common.TypeUtils.ToSByteArray 
(buffer);
-                       }
-                       return state;
+                       return new StateSerializer (state);
                }
 
                public override void processRestoreState (FacesContext context, 
object state) {
@@ -220,10 +213,7 @@
                                throw new ArgumentNullException ("state");
                        IHttpHandler jsfHandler = EnterThread ();
                        try {
-                               if (getFacesContext ().getApplication 
().getStateManager ().isSavingStateInClient (getFacesContext ())) {
-                                       byte [] buffer = (byte []) 
vmw.common.TypeUtils.ToByteArray ((sbyte []) state);
-                                       state = new ObjectStateFormatter 
(this).DeserializeInternal (buffer);
-                               }
+                               state = ((StateSerializer) state).State;
                                _state = (Pair) ((Pair) state).First;
                                _validatorsState = (bool []) ((Pair) 
state).Second;
                                RestorePageState ();
@@ -459,5 +449,52 @@
                        }
                }
                #endregion
+
+               #region StateSerializer
+               public sealed class StateSerializer : java.io.Externalizable
+               {
+                       object _state;
+
+                       public StateSerializer ()
+                       {
+                       }
+
+                       public StateSerializer (object state)
+                       {
+                               _state = state;
+                       }
+
+                       public object State
+                       {
+                               get { return _state; }
+                       }
+
+                       public void readExternal (java.io.ObjectInput __p1)
+                       {
+                               Console.WriteLine ("readExternal: " + 
CurrentPage);
+                               ObjectStateFormatter osf = new 
ObjectStateFormatter (CurrentPage);
+                               _state = osf.Deserialize (new ObjectInputStream 
(__p1));
+                       }
+
+                       public void writeExternal (java.io.ObjectOutput __p1)
+                       {
+                               Console.WriteLine ("writeExternal: " + 
CurrentPage);
+                               ObjectStateFormatter osf = new 
ObjectStateFormatter (CurrentPage);
+                               osf.Serialize (new ObjectOutputStream (__p1), 
_state);
+                       }
+
+                       private Page CurrentPage
+                       {
+                               get
+                               {
+                                       HttpContext context = 
HttpContext.Current;
+                                       if (context.CurrentHandler is Page)
+                                               return (Page) 
context.CurrentHandler;
+                                       
+                                       return context.CurrentHandlerInternal;
+                               }
+                       }
+               } 
+               #endregion
        }
 }

Modified: trunk/mcs/class/System.Web/System.Web20.csproj
===================================================================
--- trunk/mcs/class/System.Web/System.Web20.csproj      2008-02-07 15:07:53 UTC 
(rev 95143)
+++ trunk/mcs/class/System.Web/System.Web20.csproj      2008-02-07 15:09:21 UTC 
(rev 95144)
@@ -1161,6 +1161,8 @@
     <Compile Include="System.Web.Configuration\FileMatchingInfo.cs" />
     <Compile Include="System.Web.Configuration_2.0\AppSettings.jvm.cs" />
     <Compile Include="System.Web.Configuration_2.0\MachineKeySectionUtils.cs" 
/>
+    <Compile Include="System.Web.J2EE\ObjectInputStream.cs" />
+    <Compile Include="System.Web.J2EE\ObjectOutputStream.cs" />
     <Compile Include="System.Web.Security\AspNetDBSchemaChecker.cs" />
     <Compile Include="System.Web.SessionState\HttpSessionState.cs" />
     <Compile Include="System.Web.SessionState\ISessionHandler.cs" />
@@ -1454,4 +1456,4 @@
   <PropertyGroup>
     <PreBuildEvent>"$(ProjectDir)..\..\class\lib\net_2_0\culevel.exe" -o 
"$(ProjectDir)System.Web\UplevelHelper.cs" 
"$(ProjectDir)UplevelHelperDefinitions.xml"</PreBuildEvent>
   </PropertyGroup>
-</Project>
+</Project>
\ No newline at end of file

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to