myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1296658 - in /myfaces/core/trunk: impl/src/main/java/org/apache/myfaces/application/ impl/src/main/java/org/apache/myfaces/renderkit/ impl/src/main/java/org/apache/myfaces/view/facelets/ impl/src/main/java/org/apache/myfaces/view/facelets/...
Date Sat, 03 Mar 2012 16:27:59 GMT
Author: lu4242
Date: Sat Mar  3 16:27:59 2012
New Revision: 1296658

URL: http://svn.apache.org/viewvc?rev=1296658&view=rev
Log:
MYFACES-3485 [perf] Use facesContext attribute map instead request map

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/ServerSideStateCacheImpl.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewHandler.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/EncodingHandler.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewHandler.java
    myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategyTest.java
    myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/application/DefaultViewHandlerSupport.java
    myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java?rev=1296658&r1=1296657&r2=1296658&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java
Sat Mar  3 16:27:59 2012
@@ -224,7 +224,7 @@ public class StateManagerImpl extends St
             ExternalContext externalContext = facesContext.getExternalContext();
     
             // SerializedView already created before within this request?
-            serializedView = externalContext.getRequestMap()
+            serializedView = facesContext.getAttributes()
                                                                 .get(SERIALIZED_VIEW_REQUEST_ATTR);
             if (serializedView == null)
             {
@@ -237,7 +237,7 @@ public class StateManagerImpl extends St
                 Object treeStruct = getTreeStructureToSave(facesContext);
                 Object compStates = getComponentStateToSave(facesContext);
                 serializedView = new Object[] {treeStruct, compStates};
-                externalContext.getRequestMap().put(SERIALIZED_VIEW_REQUEST_ATTR,
+                facesContext.getAttributes().put(SERIALIZED_VIEW_REQUEST_ATTR,
                                                     serializedView);
     
                 if (log.isLoggable(Level.FINEST))

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/ServerSideStateCacheImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/ServerSideStateCacheImpl.java?rev=1296658&r1=1296657&r2=1296658&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/ServerSideStateCacheImpl.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/ServerSideStateCacheImpl.java
Sat Mar  3 16:27:59 2012
@@ -312,14 +312,12 @@ class ServerSideStateCacheImpl extends S
 
     public int getNextViewSequence(FacesContext context)
     {
-        ExternalContext externalContext = context.getExternalContext();
-
-        if (!externalContext.getRequestMap().containsKey(RendererUtils.SEQUENCE_PARAM))
+        if (!context.getAttributes().containsKey(RendererUtils.SEQUENCE_PARAM))
         {
             nextViewSequence(context);
         }
 
-        Integer sequence = (Integer) externalContext.getRequestMap().get(RendererUtils.SEQUENCE_PARAM);
+        Integer sequence = (Integer) context.getAttributes().get(RendererUtils.SEQUENCE_PARAM);
         return sequence.intValue();
     }
 
@@ -327,11 +325,12 @@ class ServerSideStateCacheImpl extends S
     {
         ExternalContext externalContext = facescontext.getExternalContext();
         Object sessionObj = externalContext.getSession(true);
+        Integer sequence = null;
         synchronized(sessionObj) // synchronized to increase sequence if multiple requests
                                  // are handled at the same time for the session
         {
             Map<String, Object> map = externalContext.getSessionMap();
-            Integer sequence = (Integer) map.get(RendererUtils.SEQUENCE_PARAM);
+            sequence = (Integer) map.get(RendererUtils.SEQUENCE_PARAM);
             if(sequence == null || sequence.intValue() == Integer.MAX_VALUE)
             {
                 sequence = Integer.valueOf(1);
@@ -341,8 +340,8 @@ class ServerSideStateCacheImpl extends S
                 sequence = Integer.valueOf(sequence.intValue() + 1);
             }
             map.put(RendererUtils.SEQUENCE_PARAM, sequence);
-            externalContext.getRequestMap().put(RendererUtils.SEQUENCE_PARAM, sequence);
         }
+        facescontext.getAttributes().put(RendererUtils.SEQUENCE_PARAM, sequence);
     }
 
     protected Object serializeView(FacesContext context, Object serializedView)

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java?rev=1296658&r1=1296657&r2=1296658&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java
Sat Mar  3 16:27:59 2012
@@ -472,7 +472,7 @@ public class DefaultFaceletsStateManagem
         
         ExternalContext externalContext = context.getExternalContext();
         
-        Object serializedView = externalContext.getRequestMap()
+        Object serializedView = context.getAttributes()
             .get(SERIALIZED_VIEW_REQUEST_ATTR);
         
         //Note on ajax case the method saveState could be called twice: once before start
@@ -553,7 +553,7 @@ public class DefaultFaceletsStateManagem
             //externalContext.getRequestMap().put(SERIALIZED_VIEW_REQUEST_ATTR,
             //        getStateCache().encodeSerializedState(context, serializedView));
 
-            externalContext.getRequestMap().put(SERIALIZED_VIEW_REQUEST_ATTR, serializedView);
+            context.getAttributes().put(SERIALIZED_VIEW_REQUEST_ATTR, serializedView);
 
         }
         

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java?rev=1296658&r1=1296657&r2=1296658&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
Sat Mar  3 16:27:59 2012
@@ -2172,10 +2172,10 @@ public class FaceletViewDeclarationLangu
         }
 
         // get our content type
-        String contentType = (String) extContext.getRequestMap().get("facelets.ContentType");
+        String contentType = (String) context.getAttributes().get("facelets.ContentType");
 
         // get the encoding
-        String encoding = (String) extContext.getRequestMap().get("facelets.Encoding");
+        String encoding = (String) context.getAttributes().get("facelets.Encoding");
 
         // -= Leonardo Uribe =- Add */* to the contentType is a fix done from FaceletViewHandler
         // to make old RI versions work, but since this is for JSF 2.0 it is not necessary
that code.
@@ -2261,7 +2261,7 @@ public class FaceletViewDeclarationLangu
         String contentType = orig;
 
         // see if we need to override the contentType
-        Map<String, Object> m = context.getExternalContext().getRequestMap();
+        Map<Object, Object> m = context.getAttributes();
         if (m.containsKey("facelets.ContentType"))
         {
             contentType = (String) m.get("facelets.ContentType");
@@ -2293,7 +2293,7 @@ public class FaceletViewDeclarationLangu
         String encoding = orig;
 
         // see if we need to override the encoding
-        Map<String, Object> m = context.getExternalContext().getRequestMap();
+        Map<Object, Object> m = context.getAttributes();
         Map<String, Object> sm = context.getExternalContext().getSessionMap();
 
         // 1. check the request attribute

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewHandler.java?rev=1296658&r1=1296657&r2=1296658&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewHandler.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewHandler.java
Sat Mar  3 16:27:59 2012
@@ -411,10 +411,10 @@ public class FaceletViewHandler extends 
         }
 
         // get our content type
-        String contentType = (String) extContext.getRequestMap().get("facelets.ContentType");
+        String contentType = (String) context.getAttributes().get("facelets.ContentType");
 
         // get the encoding
-        String encoding = (String) extContext.getRequestMap().get("facelets.Encoding");
+        String encoding = (String) context.getAttributes().get("facelets.Encoding");
 
         ResponseWriter writer;
         // append */* to the contentType so createResponseWriter will succeed no matter
@@ -466,7 +466,7 @@ public class FaceletViewHandler extends 
         String encoding = orig;
 
         // see if we need to override the encoding
-        Map<String, Object> m = context.getExternalContext().getRequestMap();
+        Map<Object, Object> m = context.getAttributes();
         Map<String, Object> sm = context.getExternalContext().getSessionMap();
 
         // 1. check the request attribute
@@ -522,7 +522,7 @@ public class FaceletViewHandler extends 
         String contentType = orig;
 
         // see if we need to override the contentType
-        Map<String, Object> m = context.getExternalContext().getRequestMap();
+        Map<Object, Object> m = context.getAttributes();
         if (m.containsKey("facelets.ContentType"))
         {
             contentType = (String) m.get("facelets.ContentType");

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/EncodingHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/EncodingHandler.java?rev=1296658&r1=1296657&r2=1296658&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/EncodingHandler.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/EncodingHandler.java
Sat Mar  3 16:27:59 2012
@@ -45,15 +45,15 @@ public class EncodingHandler implements 
         this.next.apply(ctx, parent);
         if (this.encoding == null)
         {
-            if (!ctx.getFacesContext().getExternalContext().getRequestMap().containsKey("facelets.Encoding"))
+            if (!ctx.getFacesContext().getAttributes().containsKey("facelets.Encoding"))
             {
-                ctx.getFacesContext().getExternalContext().getRequestMap().put("facelets.Encoding",
"UTF-8");
+                ctx.getFacesContext().getAttributes().put("facelets.Encoding", "UTF-8");
             }
         }
         else
         {
             //Encoding of document takes precedence over f:view contentType
-            ctx.getFacesContext().getExternalContext().getRequestMap().put("facelets.Encoding",
this.encoding);
+            ctx.getFacesContext().getAttributes().put("facelets.Encoding", this.encoding);
         }
     }
 

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewHandler.java?rev=1296658&r1=1296657&r2=1296658&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewHandler.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewHandler.java
Sat Mar  3 16:27:59 2012
@@ -131,16 +131,16 @@ public final class ViewHandler extends T
                         }
                     }
                 }
-                ctx.getFacesContext().getExternalContext().getRequestMap().put("facelets.ContentType",
v);
+                ctx.getFacesContext().getAttributes().put("facelets.ContentType", v);
             }
             if (this.encoding != null)
             {
                 String v = this.encoding.getValue(ctx);
-                ctx.getFacesContext().getExternalContext().getRequestMap().put("facelets.Encoding",
v);
+                ctx.getFacesContext().getAttributes().put("facelets.Encoding", v);
             }
             else if (encodingValue != null)
             {
-                ctx.getFacesContext().getExternalContext().getRequestMap().put("facelets.Encoding",
encodingValue);
+                ctx.getFacesContext().getAttributes().put("facelets.Encoding", encodingValue);
             }
             if (this.beforePhase != null)
             {

Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategyTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategyTest.java?rev=1296658&r1=1296657&r2=1296658&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategyTest.java
(original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategyTest.java
Sat Mar  3 16:27:59 2012
@@ -420,7 +420,7 @@ public class DefaultFaceletsStateManagem
     
     public UIViewRoot saveAndRestore(StateManagementStrategy stateManagement, UIViewRoot
viewRoot)
     {
-        externalContext.getRequestMap()
+        facesContext.getAttributes()
             .remove(StateManagerImpl.class.getName() + ".SERIALIZED_VIEW");        
         Object state1 = stateManagement.saveView(facesContext);
         stateToRestore = state1;

Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/application/DefaultViewHandlerSupport.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/application/DefaultViewHandlerSupport.java?rev=1296658&r1=1296657&r2=1296658&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/application/DefaultViewHandlerSupport.java
(original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/application/DefaultViewHandlerSupport.java
Sat Mar  3 16:27:59 2012
@@ -248,21 +248,19 @@ public class DefaultViewHandlerSupport i
      */
     protected FacesServletMapping getFacesServletMapping(FacesContext context)
     {
-        Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
+        Map<Object, Object> attributes = context.getAttributes();
 
         // Has the mapping already been determined during this request?
-        if (!requestMap.containsKey(CACHED_SERVLET_MAPPING))
+        FacesServletMapping mapping = (FacesServletMapping) attributes.get(CACHED_SERVLET_MAPPING);
+        if (mapping == null)
         {
             ExternalContext externalContext = context.getExternalContext();
-            FacesServletMapping mapping =
-                calculateFacesServletMapping(
-                    externalContext.getRequestServletPath(),
+            mapping = calculateFacesServletMapping(externalContext.getRequestServletPath(),
                     externalContext.getRequestPathInfo());
 
-            requestMap.put(CACHED_SERVLET_MAPPING, mapping);
+            attributes.put(CACHED_SERVLET_MAPPING, mapping);
         }
-
-        return (FacesServletMapping) requestMap.get(CACHED_SERVLET_MAPPING);
+        return mapping;
     }
 
     /**

Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java?rev=1296658&r1=1296657&r2=1296658&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java
(original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java
Sat Mar  3 16:27:59 2012
@@ -1212,6 +1212,10 @@ public final class RendererUtils
         dest.setValidator(src.getValidator());
     }
 
+    /**
+     * @deprecated Logic corrected and encapsulated better in org.apache.myfaces.renderkit.ServerSideStateCacheImpl
+     */
+    @Deprecated
     public static Integer getViewSequence(FacesContext facescontext)
     {
         Map map = facescontext.getExternalContext().getRequestMap();



Mime
View raw message