merged Sys.Web.Services 2.0 support in my branch:
[mono.git] / mcs / class / System.Web / System.Web.SessionState / HttpSessionState.jvm.cs
index 0524e74bc8c408afbefa7db82920a6d3dae1c4c6..b5d91c268598148f8d2dd34d0e129dea9ccdde1a 100644 (file)
@@ -54,8 +54,6 @@ public sealed class HttpSessionState : ICollection, IEnumerable, java.io.Externa
        private bool _isReadonly;
        internal bool _abandoned;
 
-       private object _app;
-       private bool _readFirstTime = true;
        private bool _needSessionPersistence = false;
 
        internal HttpSessionState (string id,
@@ -76,7 +74,6 @@ public sealed class HttpSessionState : ICollection, IEnumerable, java.io.Externa
                _mode = mode;
                _isReadonly = isReadonly;
 
-               _app = HttpContext.Current.ApplicationInstance;
                _needSessionPersistence = false;
                javax.servlet.ServletConfig config = (javax.servlet.ServletConfig)AppDomain.CurrentDomain.GetData(J2EEConsts.SERVLET_CONFIG);
                string sessionPersistance = config.getInitParameter(J2EEConsts.Enable_Session_Persistency);
@@ -111,10 +108,10 @@ public sealed class HttpSessionState : ICollection, IEnumerable, java.io.Externa
                {
                        output.writeBoolean(_needSessionPersistence);
                        if (!_needSessionPersistence)
-                       {
+                               //indicates that there is nothing to serialize for this object
                                return;
-                       }
-                       System.IO.MemoryStream ms = new System.IO.MemoryStream();
+
+                       System.Web.J2EE.ObjectOutputStream ms = new System.Web.J2EE.ObjectOutputStream(output);
                        System.IO.BinaryWriter bw = new System.IO.BinaryWriter(ms);
                        bw.Write(_id);
                        _dict.Serialize(bw);
@@ -131,7 +128,6 @@ public sealed class HttpSessionState : ICollection, IEnumerable, java.io.Externa
                        else 
                                bw.Write(3);
                        bw.Write(_isReadonly);
-                       output.writeObject(vmw.common.TypeUtils.ToSByteArray(ms.GetBuffer()));
                }
        }
 
@@ -140,17 +136,10 @@ public sealed class HttpSessionState : ICollection, IEnumerable, java.io.Externa
                lock(this)
                {
                        _needSessionPersistence = input.readBoolean();
-                       if (!_needSessionPersistence)
-                       {
-                               return;
-                       }
-                       sbyte[] array = (sbyte[])input.readObject();
-                       if (!_readFirstTime || array == null || array.Length == 0)
-                       {
+                       if(!_needSessionPersistence) //noting has been written 
                                return;
-                       }
-                       _readFirstTime = false;
-                       System.IO.MemoryStream ms = new System.IO.MemoryStream((byte[])vmw.common.TypeUtils.ToByteArray(array));
+
+                       System.Web.J2EE.ObjectInputStream ms = new System.Web.J2EE.ObjectInputStream( input );
                        System.IO.BinaryReader br = new System.IO.BinaryReader(ms);
                        _id = br.ReadString();
                        _dict =  SessionDictionary.Deserialize(br);
@@ -168,15 +157,6 @@ public sealed class HttpSessionState : ICollection, IEnumerable, java.io.Externa
                        else 
                                _mode = SessionStateMode.SQLServer;
                        _isReadonly = br.ReadBoolean();
-                       //      _app = HttpContext.Current.ApplicationInstance;
-               }
-       }
-
-       internal object App
-       {
-               get
-               {
-                       return _app;
                }
        }
 
@@ -317,8 +297,7 @@ public sealed class HttpSessionState : ICollection, IEnumerable, java.io.Externa
                ServletWorkerRequest worker = (ServletWorkerRequest)HttpContext.Current.Request.WorkerRequest;
 //             worker.Servlet.getServletContext().removeAttribute("GH_SESSION_STATE");
                javax.servlet.http.HttpSession javaSession = worker.ServletRequest.getSession(false);
-               if (_app == null)
-                       _app = HttpContext.Current.ApplicationInstance;
+
                if (javaSession != null)
                {
                        javaSession.setAttribute("GH_SESSION_STATE",this);