myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject [myfaces] branch master updated: refactored
Date Sun, 18 Aug 2019 21:28:13 GMT
This is an automated email from the ASF dual-hosted git repository.

tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/master by this push:
     new 920dba7  refactored
920dba7 is described below

commit 920dba7e89864704214154c5d563c32f63075f59
Author: Thomas Andraschko <tandraschko@apache.org>
AuthorDate: Sun Aug 18 23:28:06 2019 +0200

    refactored
---
 .../myfaces/application/StateManagerImpl.java      | 34 +++++++++-------------
 .../myfaces/application/TreeStructureManager.java  |  2 +-
 .../myfaces/application/ViewHandlerImpl.java       |  4 ++-
 .../myfaces/application/viewstate/StateCache.java  |  1 -
 .../viewstate/StateCacheClientSide.java            |  4 +--
 .../viewstate/StateCacheServerSide.java            |  4 +--
 .../viewstate/{token => }/StateTokenProcessor.java |  2 +-
 ...sor.java => StateTokenProcessorClientSide.java} |  5 ++--
 ...sor.java => StateTokenProcessorServerSide.java} |  5 ++--
 .../context/servlet/PartialViewContextImpl.java    |  2 +-
 10 files changed, 25 insertions(+), 38 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java b/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java
index 02218f2..411f010 100644
--- a/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java
@@ -92,6 +92,7 @@ public class StateManagerImpl extends StateManager
         {
             log.finest("Entering getTreeStructureToSave");
         }
+
         UIViewRoot viewRoot = facesContext.getViewRoot();
         if (viewRoot.isTransient())
         {
@@ -147,7 +148,7 @@ public class StateManagerImpl extends StateManager
 
                 if (uiViewRoot != null)
                 {
-                    facesContext.setViewRoot (uiViewRoot);
+                    facesContext.setViewRoot(uiViewRoot);
                     uiViewRoot.processRestoreState(facesContext, stateArray[1]);
                     
                     RequestViewContext.getCurrentInstance(facesContext).refreshRequestViewContext(
@@ -157,7 +158,7 @@ public class StateManagerImpl extends StateManager
                     // so "contracts" attribute will not be set properly. We need to save
it and
                     // restore it from here. With PSS, the view will always be built so it
is not
                     // necessary to save it on the state.
-                    Object rlc = ((Object[])stateArray[0])[1];
+                    Object rlc = ((Object[]) stateArray[0])[1];
                     if (rlc != null)
                     {
                         facesContext.setResourceLibraryContracts((List) UIComponentBase.
@@ -182,7 +183,6 @@ public class StateManagerImpl extends StateManager
     public Object saveView(FacesContext facesContext)
     {
         UIViewRoot uiViewRoot = facesContext.getViewRoot();
-        
         if (uiViewRoot.isTransient())
         {
             return null;
@@ -201,7 +201,6 @@ public class StateManagerImpl extends StateManager
             if (vdl != null)
             {
                 StateManagementStrategy sms = vdl.getStateManagementStrategy(facesContext,
viewId);
-                
                 if (sms != null)
                 {
                     if (log.isLoggable(Level.FINEST))
@@ -237,7 +236,7 @@ public class StateManagerImpl extends StateManager
                 log.finest("Entering saveSerializedView");
             }
     
-            checkForDuplicateIds(facesContext, facesContext.getViewRoot(), new HashSet<String>());
+            checkForDuplicateIds(facesContext, facesContext.getViewRoot(), new HashSet<>());
     
             if (log.isLoggable(Level.FINEST))
             {
@@ -258,12 +257,11 @@ public class StateManagerImpl extends StateManager
                 Object compStates = getComponentStateToSave(facesContext);
                 Object rlcStates = !facesContext.getResourceLibraryContracts().isEmpty()
? 
                     UIComponentBase.saveAttachedState(facesContext, 
-                                new ArrayList<String>(facesContext.getResourceLibraryContracts()))
: null;
+                                new ArrayList<>(facesContext.getResourceLibraryContracts()))
: null;
                 serializedView = new Object[] {
-                        new Object[]{treeStruct, rlcStates} ,
+                        new Object[]{ treeStruct, rlcStates },
                         compStates};
-                facesContext.getAttributes().put(SERIALIZED_VIEW_REQUEST_ATTR,
-                                                    serializedView);
+                facesContext.getAttributes().put(SERIALIZED_VIEW_REQUEST_ATTR, serializedView);
     
                 if (log.isLoggable(Level.FINEST))
                 {
@@ -307,34 +305,31 @@ public class StateManagerImpl extends StateManager
         
         if (component instanceof NamingContainer)
         {
-            ids = new HashSet<String>();
+            ids = new HashSet<>();
         }
-        
-        int facetCount = component.getFacetCount();
-        if (facetCount > 0)
+
+        if (component.getFacetCount() > 0)
         {
             for (UIComponent facet : component.getFacets().values())
             {
-                checkForDuplicateIds (context, facet, ids);
+                checkForDuplicateIds(context, facet, ids);
             }
         }
         for (int i = 0, childCount = component.getChildCount(); i < childCount; i++)
         {
             UIComponent child = component.getChildren().get(i);
-            checkForDuplicateIds (context, child, ids);
+            checkForDuplicateIds(context, child, ids);
         }
     }
 
     @Override
-    public void writeState(FacesContext facesContext,
-                           Object state) throws IOException
+    public void writeState(FacesContext facesContext, Object state) throws IOException
     {
         if (log.isLoggable(Level.FINEST))
         {
             log.finest("Entering writeState");
         }
 
-        //UIViewRoot uiViewRoot = facesContext.getViewRoot();
         //save state in response (client)
         RenderKit renderKit = facesContext.getRenderKit();
         ResponseStateManager responseStateManager = renderKit.getResponseStateManager();
@@ -345,11 +340,8 @@ public class StateManagerImpl extends StateManager
         {
             log.finest("Exiting writeState");
         }
-
     }
 
-    //helpers
-
     protected RenderKitFactory getRenderKitFactory()
     {
         if (_renderKitFactory == null)
diff --git a/impl/src/main/java/org/apache/myfaces/application/TreeStructureManager.java b/impl/src/main/java/org/apache/myfaces/application/TreeStructureManager.java
index e22ba5c..e564e3f 100755
--- a/impl/src/main/java/org/apache/myfaces/application/TreeStructureManager.java
+++ b/impl/src/main/java/org/apache/myfaces/application/TreeStructureManager.java
@@ -72,7 +72,7 @@ public class TreeStructureManager
         if (component.getFacetCount() > 0)
         {
             Map<String, UIComponent> facetMap = component.getFacets();
-            List<Object[]> structFacetList = new ArrayList<Object[]>();
+            List<Object[]> structFacetList = new ArrayList<>();
             for (Map.Entry<String, UIComponent> entry : facetMap.entrySet())
             {
                 UIComponent child = entry.getValue();
diff --git a/impl/src/main/java/org/apache/myfaces/application/ViewHandlerImpl.java b/impl/src/main/java/org/apache/myfaces/application/ViewHandlerImpl.java
index b7e8f4a..aa8f4ab 100644
--- a/impl/src/main/java/org/apache/myfaces/application/ViewHandlerImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/application/ViewHandlerImpl.java
@@ -196,6 +196,8 @@ public class ViewHandlerImpl extends ViewHandler
     /**
      * Get the locales specified as acceptable by the original request, compare them to the
      * locales supported by this Application and return the best match.
+     *
+     * @param facesContext
      */
     @Override
     public Locale calculateLocale(FacesContext facesContext)
@@ -510,7 +512,7 @@ public class ViewHandlerImpl extends ViewHandler
                     // since we have checked !parameters.containsKey(viewParameter.getName())
                     // here already, the parameters Map will never contain a List under the
                     // key viewParameter.getName(), thus we do not have to check it here
(again).
-                    List<String> parameterValueList = new ArrayList<String>(1);
+                    List<String> parameterValueList = new ArrayList<>(1);
                     parameterValueList.add(parameterValue);
                     parameters.put(viewParameter.getName(), parameterValueList);
                 }
diff --git a/impl/src/main/java/org/apache/myfaces/application/viewstate/StateCache.java b/impl/src/main/java/org/apache/myfaces/application/viewstate/StateCache.java
index bd054ac..e767dd2 100644
--- a/impl/src/main/java/org/apache/myfaces/application/viewstate/StateCache.java
+++ b/impl/src/main/java/org/apache/myfaces/application/viewstate/StateCache.java
@@ -19,7 +19,6 @@
 package org.apache.myfaces.application.viewstate;
 
 import javax.faces.context.FacesContext;
-import org.apache.myfaces.application.viewstate.token.StateTokenProcessor;
 
 /**
  * This class provides an interface to separate the state caching operations (saving/restoring)
diff --git a/impl/src/main/java/org/apache/myfaces/application/viewstate/StateCacheClientSide.java
b/impl/src/main/java/org/apache/myfaces/application/viewstate/StateCacheClientSide.java
index 417f3b8..89c3065 100644
--- a/impl/src/main/java/org/apache/myfaces/application/viewstate/StateCacheClientSide.java
+++ b/impl/src/main/java/org/apache/myfaces/application/viewstate/StateCacheClientSide.java
@@ -23,8 +23,6 @@ import org.apache.myfaces.util.token.CsrfSessionTokenFactoryRandom;
 import org.apache.myfaces.util.token.CsrfSessionTokenFactorySecureRandom;
 import javax.faces.context.FacesContext;
 
-import org.apache.myfaces.application.viewstate.token.ClientSideStateTokenProcessor;
-import org.apache.myfaces.application.viewstate.token.StateTokenProcessor;
 import org.apache.myfaces.config.MyfacesConfig;
 
 class StateCacheClientSide extends StateCache<Object, Object>
@@ -55,7 +53,7 @@ class StateCacheClientSide extends StateCache<Object, Object>
             csrfSessionTokenFactory = new CsrfSessionTokenFactoryRandom(facesContext);
         }
         
-        stateTokenProcessor = new ClientSideStateTokenProcessor();
+        stateTokenProcessor = new StateTokenProcessorClientSide();
         clientViewStateTimeout = config.getClientViewStateTimeout();
     }
 
diff --git a/impl/src/main/java/org/apache/myfaces/application/viewstate/StateCacheServerSide.java
b/impl/src/main/java/org/apache/myfaces/application/viewstate/StateCacheServerSide.java
index 6d9a407..63e71ca 100644
--- a/impl/src/main/java/org/apache/myfaces/application/viewstate/StateCacheServerSide.java
+++ b/impl/src/main/java/org/apache/myfaces/application/viewstate/StateCacheServerSide.java
@@ -42,8 +42,6 @@ import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 import javax.faces.lifecycle.ClientWindow;
 
-import org.apache.myfaces.application.viewstate.token.ServerSideStateTokenProcessor;
-import org.apache.myfaces.application.viewstate.token.StateTokenProcessor;
 import org.apache.myfaces.config.MyfacesConfig;
 import org.apache.myfaces.renderkit.RendererUtils;
 import org.apache.myfaces.util.MyFacesObjectInputStream;
@@ -121,7 +119,7 @@ class StateCacheServerSide extends StateCache<Object, Object>
             csrfSessionTokenFactory = new CsrfSessionTokenFactoryRandom(facesContext);
         }
         
-        stateTokenProcessor = new ServerSideStateTokenProcessor();
+        stateTokenProcessor = new StateTokenProcessorServerSide();
     }
     
     //------------------------------------- METHODS COPIED FROM JspStateManagerImpl--------------------------------
diff --git a/impl/src/main/java/org/apache/myfaces/application/viewstate/token/StateTokenProcessor.java
b/impl/src/main/java/org/apache/myfaces/application/viewstate/StateTokenProcessor.java
similarity index 95%
rename from impl/src/main/java/org/apache/myfaces/application/viewstate/token/StateTokenProcessor.java
rename to impl/src/main/java/org/apache/myfaces/application/viewstate/StateTokenProcessor.java
index 17902ff..13cf48d 100644
--- a/impl/src/main/java/org/apache/myfaces/application/viewstate/token/StateTokenProcessor.java
+++ b/impl/src/main/java/org/apache/myfaces/application/viewstate/StateTokenProcessor.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.myfaces.application.viewstate.token;
+package org.apache.myfaces.application.viewstate;
 
 import javax.faces.context.FacesContext;
 
diff --git a/impl/src/main/java/org/apache/myfaces/application/viewstate/token/ClientSideStateTokenProcessor.java
b/impl/src/main/java/org/apache/myfaces/application/viewstate/StateTokenProcessorClientSide.java
similarity index 90%
rename from impl/src/main/java/org/apache/myfaces/application/viewstate/token/ClientSideStateTokenProcessor.java
rename to impl/src/main/java/org/apache/myfaces/application/viewstate/StateTokenProcessorClientSide.java
index 2f86f3a..c7c0cfa 100644
--- a/impl/src/main/java/org/apache/myfaces/application/viewstate/token/ClientSideStateTokenProcessor.java
+++ b/impl/src/main/java/org/apache/myfaces/application/viewstate/StateTokenProcessorClientSide.java
@@ -16,16 +16,15 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.myfaces.application.viewstate.token;
+package org.apache.myfaces.application.viewstate;
 
 import javax.faces.context.FacesContext;
-import org.apache.myfaces.application.viewstate.StateUtils;
 
 /**
  *
  * @author Thomas Andraschko
  */
-public class ClientSideStateTokenProcessor extends StateTokenProcessor
+public class StateTokenProcessorClientSide extends StateTokenProcessor
 {
     @Override
     public Object decode(FacesContext facesContext, String token)
diff --git a/impl/src/main/java/org/apache/myfaces/application/viewstate/token/ServerSideStateTokenProcessor.java
b/impl/src/main/java/org/apache/myfaces/application/viewstate/StateTokenProcessorServerSide.java
similarity index 93%
rename from impl/src/main/java/org/apache/myfaces/application/viewstate/token/ServerSideStateTokenProcessor.java
rename to impl/src/main/java/org/apache/myfaces/application/viewstate/StateTokenProcessorServerSide.java
index 245b86e..ab0f568 100644
--- a/impl/src/main/java/org/apache/myfaces/application/viewstate/token/ServerSideStateTokenProcessor.java
+++ b/impl/src/main/java/org/apache/myfaces/application/viewstate/StateTokenProcessorServerSide.java
@@ -16,18 +16,17 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.myfaces.application.viewstate.token;
+package org.apache.myfaces.application.viewstate;
 
 import java.io.UnsupportedEncodingException;
 import javax.faces.FacesException;
 import javax.faces.context.FacesContext;
-import org.apache.myfaces.application.viewstate.StateUtils;
 
 /**
  *
  * @author Thomas Andraschko
  */
-public class ServerSideStateTokenProcessor extends StateTokenProcessor
+public class StateTokenProcessorServerSide extends StateTokenProcessor
 {
     @Override
     public Object decode(FacesContext facesContext, String token)
diff --git a/impl/src/main/java/org/apache/myfaces/context/servlet/PartialViewContextImpl.java
b/impl/src/main/java/org/apache/myfaces/context/servlet/PartialViewContextImpl.java
index 2b67b7e..0399092 100644
--- a/impl/src/main/java/org/apache/myfaces/context/servlet/PartialViewContextImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/context/servlet/PartialViewContextImpl.java
@@ -50,7 +50,7 @@ import javax.faces.render.RenderKit;
 import javax.faces.render.RenderKitFactory;
 import javax.faces.view.ViewMetadata;
 import org.apache.myfaces.application.ResourceHandlerImpl;
-import org.apache.myfaces.application.viewstate.token.StateTokenProcessor;
+import org.apache.myfaces.application.viewstate.StateTokenProcessor;
 
 import org.apache.myfaces.context.PartialResponseWriterImpl;
 import org.apache.myfaces.context.RequestViewContext;


Mime
View raw message