myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mat...@apache.org
Subject svn commit: r987227 - in /myfaces/trinidad/branches/1.2.12.3-branch: trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/web.xml trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java
Date Thu, 19 Aug 2010 16:43:36 GMT
Author: matzew
Date: Thu Aug 19 16:43:36 2010
New Revision: 987227

URL: http://svn.apache.org/viewvc?rev=987227&view=rev
Log:
trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.javaTRINIDAD-1883
- StateManagerImpl.PageState is incompatible in Trinidad 1.2 and 2.0

Modified:
    myfaces/trinidad/branches/1.2.12.3-branch/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/web.xml
    myfaces/trinidad/branches/1.2.12.3-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java

Modified: myfaces/trinidad/branches/1.2.12.3-branch/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.3-branch/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/web.xml?rev=987227&r1=987226&r2=987227&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.3-branch/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/web.xml
(original)
+++ myfaces/trinidad/branches/1.2.12.3-branch/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/web.xml
Thu Aug 19 16:43:36 2010
@@ -58,10 +58,10 @@
 
   <!-- Trinidad by default uses an optimized client-side state saving
        mechanism. To disable that, uncomment the following -->
-  <!--context-param>
+  <context-param>
     <param-name>org.apache.myfaces.trinidad.CLIENT_STATE_METHOD</param-name>
     <param-value>all</param-value>
-  </context-param-->
+  </context-param>
 
   <!-- Trinidad also supports an optimized strategy for caching some
    view state at an application level, which significantly improves

Modified: myfaces/trinidad/branches/1.2.12.3-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.3-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java?rev=987227&r1=987226&r2=987227&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.3-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java
(original)
+++ myfaces/trinidad/branches/1.2.12.3-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java
Thu Aug 19 16:43:36 2010
@@ -192,7 +192,7 @@ public class StateManagerImpl extends St
     // Don't remove transient components...
     Object structure = new Structure(component);
     Object state = component.processSaveState(context);
-    return new PageState(context, structure, state, null);
+    return new PageState(context, new Object[]{structure, state}, null);
   }
 
   /**
@@ -214,8 +214,9 @@ public class StateManagerImpl extends St
 
     PageState viewState = (PageState) savedState;
 
-    Object structure = viewState.getStructure();
-    Object state = viewState.getState();
+    Object[] stateArray = (Object[])viewState.getViewState(context);
+    Object structure = stateArray[0];
+    Object state = stateArray[1];
 
     UIComponent component =
       ((Structure) structure).createComponent();
@@ -240,7 +241,7 @@ public class StateManagerImpl extends St
 
     Object structure = new Structure(root);
     Object state = root.processSaveState(context);
-    return new PageState(context, structure, state, root);
+    return new PageState(context, new Object[]{structure, state}, root);
   }
 
   static public UIViewRoot restoreViewRoot(
@@ -260,8 +261,9 @@ public class StateManagerImpl extends St
       return root; // bug 4712492
     }
 
-    Object structure = viewState.getStructure();
-    Object state = viewState.getState();
+    Object[] stateArray = (Object[])viewState.getViewState(context);
+    Object structure = stateArray[0];
+    Object state = stateArray[1];
 
     root = (UIViewRoot)
       ((Structure) structure).createComponent();
@@ -340,8 +342,7 @@ public class StateManagerImpl extends St
         // inner class of StateManager
         PageState pageState = new PageState(
             context,
-            structure,
-            state,
+            new Object[]{structure, state},
             // Save the view root into the page state as a transient
             // if this feature has not been disabled
             _useViewRootCache(context) ? root : null);
@@ -406,7 +407,7 @@ public class StateManagerImpl extends St
       else
       {
         // use null viewRoot since this state is shared across users:
-        PageState applicationState = new PageState(context, structure, state, null);
+        PageState applicationState = new PageState(context, new Object[]{structure, state},
null);
 
         // If we need to, stash the state off in our cache
         if (!dontSave)
@@ -638,8 +639,9 @@ public class StateManagerImpl extends St
         return root;
       }
 
-      structure = viewState.getStructure();
-      state = viewState.getState();
+      Object[] stateArray = (Object[])viewState.getViewState(context);
+      structure = stateArray[0];
+      state = stateArray[1];
     }
     else
     {
@@ -1216,15 +1218,14 @@ public class StateManagerImpl extends St
   {
     private static final long serialVersionUID = 1L;
 
-    private Object _structure, _state;
+    private Object _viewState;
 
     // use transient since UIViewRoots are not Serializable.
     private transient ViewRootState _cachedState;
 
-    public PageState(FacesContext fc, Object structure, Object state, UIViewRoot root)
+    public PageState(FacesContext fc, Object viewState, UIViewRoot root)
     {
-      _structure = structure;
-      _state = state;
+      _viewState = viewState;
 
       boolean zipState = _zipState(fc);
 
@@ -1234,7 +1235,7 @@ public class StateManagerImpl extends St
         if (zipState)
         {
           // zip the page state. This will also catch any serialization problems.
-          _zipToBytes(state, structure);
+          _zipToBytes(fc, viewState);
         }
         else
         {
@@ -1243,7 +1244,7 @@ public class StateManagerImpl extends St
           //  immediately
           try
           {
-            new ObjectOutputStream(new ByteArrayOutputStream()).writeObject(state);
+            new ObjectOutputStream(new ByteArrayOutputStream()).writeObject(viewState);
           }
           catch (IOException e)
           {
@@ -1259,24 +1260,14 @@ public class StateManagerImpl extends St
                        : null;
     }
 
-    public Object getStructure()
+    public Object getViewState(FacesContext context)
     {
-      if (_zipState(FacesContext.getCurrentInstance()))
+      if (_zipState(context))
       {
-        return _unzipBytes((byte[])_structure);
+        return _unzipBytes(context, (byte[])_viewState);
       }
 
-      return _structure;
-    }
-
-    public Object getState()
-    {
-      if (_zipState(FacesContext.getCurrentInstance()))
-      {
-        return _unzipBytes((byte[])_state);
-      }
-
-      return _state;
+      return _viewState;
     }
 
     public void clearViewRootState()
@@ -1363,10 +1354,10 @@ public class StateManagerImpl extends St
       return zipStateObject.toString().equalsIgnoreCase("true");
     }
 
-    private Object _unzipBytes(byte[] zippedBytes)
+    private Object _unzipBytes(FacesContext context, byte[] zippedBytes)
     {
       Inflater decompressor = null;
-      ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
+      ExternalContext externalContext = context.getExternalContext();
       Map<String,Object> sessionMap  = externalContext.getSessionMap();
 
       try
@@ -1428,10 +1419,10 @@ public class StateManagerImpl extends St
       }
     }
 
-    private void _zipToBytes(Object state, Object structure)
+    private void _zipToBytes(FacesContext context, Object viewState)
     {
       Deflater compresser = null;
-      ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
+      ExternalContext externalContext = context.getExternalContext();
       Map<String,Object> sessionMap  = externalContext.getSessionMap();
 
       try
@@ -1454,7 +1445,7 @@ public class StateManagerImpl extends St
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream oos = new ObjectOutputStream(baos);
 
-        oos.writeObject(state);
+        oos.writeObject(viewState);
         oos.flush();
         oos.close();
 
@@ -1467,34 +1458,11 @@ public class StateManagerImpl extends St
 
         while (!compresser.finished())
         {
-			    int count = compresser.deflate(buf);
-			    baos.write(buf, 0, count);
-		    }
-
-        _state = baos.toByteArray();
-
-        //Serialize structure
-        baos.reset();
-        oos = new ObjectOutputStream(baos);
-        compresser.reset();
-
-        oos.writeObject(structure);
-        oos.flush();
-        oos.close();
-
-        ret =  baos.toByteArray();
-        compresser.setInput(ret);
-        compresser.finish();
-
-        baos.reset();
-
-        while (!compresser.finished())
-        {
           int count = compresser.deflate(buf);
           baos.write(buf, 0, count);
-        }
+	}
 
-        _structure = baos.toByteArray();
+        _viewState = baos.toByteArray();
       }
       catch (IOException e)
       {



Mime
View raw message