You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2012/11/16 18:20:35 UTC

svn commit: r1410492 - in /myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/application/viewstate: CounterSessionViewStorageFactory.java RandomSessionViewStorageFactory.java ServerSideStateCacheImpl.java

Author: lu4242
Date: Fri Nov 16 17:20:34 2012
New Revision: 1410492

URL: http://svn.apache.org/viewvc?rev=1410492&view=rev
Log:
MYFACES-3645 review/refactor/document ViewState handling (step 3 and final for now, remove ProjectStage condition and use only one SerializedViewKey in each strategy used (counter --> IntIntSerializedViewKey, random --> IntByteArraySerializedViewKey). In this way, we can avoid different behaviors in development stage and production stage and with the custom SerializedViewKey, we can ensure the minimal possible size of the key in session (each reference counts as an unused slot), viewId hashCode is used and if no viewId, 0 is returned )

Modified:
    myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/application/viewstate/CounterSessionViewStorageFactory.java
    myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/application/viewstate/RandomSessionViewStorageFactory.java
    myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheImpl.java

Modified: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/application/viewstate/CounterSessionViewStorageFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/application/viewstate/CounterSessionViewStorageFactory.java?rev=1410492&r1=1410491&r2=1410492&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/application/viewstate/CounterSessionViewStorageFactory.java (original)
+++ myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/application/viewstate/CounterSessionViewStorageFactory.java Fri Nov 16 17:20:34 2012
@@ -18,7 +18,6 @@
  */
 package org.apache.myfaces.application.viewstate;
 
-import javax.faces.application.ProjectStage;
 import javax.faces.context.FacesContext;
 
 /**
@@ -43,14 +42,7 @@ class CounterSessionViewStorageFactory e
     @Override
     public SerializedViewKey createSerializedViewKey(FacesContext context, String viewId, Integer key)
     {
-        if (context.isProjectStage(ProjectStage.Production))
-        {
-            return new IntIntSerializedViewKey(viewId == null ? 0 : viewId.hashCode(), key);
-        }
-        else
-        {
-            return new ReferenceSerializedViewKey(viewId, key);
-        }
+        return new IntIntSerializedViewKey(viewId == null ? 0 : viewId.hashCode(), key);
     }
     
 }

Modified: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/application/viewstate/RandomSessionViewStorageFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/application/viewstate/RandomSessionViewStorageFactory.java?rev=1410492&r1=1410491&r2=1410492&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/application/viewstate/RandomSessionViewStorageFactory.java (original)
+++ myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/application/viewstate/RandomSessionViewStorageFactory.java Fri Nov 16 17:20:34 2012
@@ -18,7 +18,6 @@
  */
 package org.apache.myfaces.application.viewstate;
 
-import javax.faces.application.ProjectStage;
 import javax.faces.context.FacesContext;
 
 /**
@@ -43,14 +42,7 @@ class RandomSessionViewStorageFactory ex
     @Override
     public SerializedViewKey createSerializedViewKey(FacesContext context, String viewId, byte[] key)
     {
-        if (context.isProjectStage(ProjectStage.Production))
-        {
-            return new IntByteArraySerializedViewKey(viewId == null ? 0 : viewId.hashCode(), key);
-        }
-        else
-        {
-            return new ReferenceSerializedViewKey(viewId, key);
-        }
+        return new IntByteArraySerializedViewKey(viewId == null ? 0 : viewId.hashCode(), key);
     }
     
 }

Modified: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheImpl.java?rev=1410492&r1=1410491&r2=1410492&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheImpl.java (original)
+++ myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheImpl.java Fri Nov 16 17:20:34 2012
@@ -46,7 +46,7 @@ import org.apache.myfaces.shared.util.We
 
 class ServerSideStateCacheImpl extends StateCache<Object, Object>
 {
-    public static final Logger log = Logger.getLogger(ServerSideStateCacheImpl.class.getName());
+    private static final Logger log = Logger.getLogger(ServerSideStateCacheImpl.class.getName());
     
     public static final String SERIALIZED_VIEW_SESSION_ATTR= 
         ServerSideStateCacheImpl.class.getName() + ".SERIALIZED_VIEW";
@@ -224,17 +224,12 @@ class ServerSideStateCacheImpl extends S
     
     public static final int UNCOMPRESSED_FLAG = 0;
     public static final int COMPRESSED_FLAG = 1;
-    
-    public static final Object[] EMPTY_STATES = new Object[]{null, null};
 
-    //private static final int JSF_SEQUENCE_INDEX = 0;
-    
     private Boolean _useFlashScopePurgeViewsInSession = null;
     
     private Integer _numberOfSequentialViewsInSession = null;
     private boolean _numberOfSequentialViewsInSessionSet = false;
 
-    //private final KeyFactory keyFactory;
     private SessionViewStorageFactory sessionViewStorageFactory;
 
     public ServerSideStateCacheImpl()
@@ -245,19 +240,16 @@ class ServerSideStateCacheImpl extends S
                 RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_PARAM_DEFAULT);
         if (RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_SECURE_RANDOM.equals(randomMode))
         {
-            //keyFactory = new SecureRandomKeyFactory(facesContext);
             sessionViewStorageFactory = new RandomSessionViewStorageFactory(
                     new SecureRandomKeyFactory(facesContext));
         }
         else if (RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN_RANDOM.equals(randomMode))
         {
-            //keyFactory = new RandomKeyFactory(facesContext);
             sessionViewStorageFactory = new RandomSessionViewStorageFactory(
                     new RandomKeyFactory(facesContext));
         }
         else
         {
-            //keyFactory = new CounterKeyFactory();
             sessionViewStorageFactory = new CounterSessionViewStorageFactory(new CounterKeyFactory());
         }
     }