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/10/23 20:59:23 UTC

svn commit: r1401386 - in /myfaces/shared/trunk_4.0.x/core: ./ src/main/java/org/apache/myfaces/shared/application/ src/main/java/org/apache/myfaces/shared/renderkit/html/

Author: lu4242
Date: Tue Oct 23 18:59:22 2012
New Revision: 1401386

URL: http://svn.apache.org/viewvc?rev=1401386&view=rev
Log:
update shared to snapshot version

Modified:
    myfaces/shared/trunk_4.0.x/core/pom.xml
    myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/application/DefaultViewHandlerSupport.java
    myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlCheckboxRendererBase.java
    myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRadioRendererBase.java
    myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlResponseWriterImpl.java

Modified: myfaces/shared/trunk_4.0.x/core/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/pom.xml?rev=1401386&r1=1401385&r2=1401386&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/pom.xml (original)
+++ myfaces/shared/trunk_4.0.x/core/pom.xml Tue Oct 23 18:59:22 2012
@@ -143,7 +143,7 @@
     <profile>
       <id>synch-myfaces-impl-shared</id>
       <properties>
-        <myfaces.impl.shared.version>2.0.15-SNAPSHOT</myfaces.impl.shared.version>
+        <myfaces.impl.shared.version>2.0.16-SNAPSHOT</myfaces.impl.shared.version>
       </properties>
       <activation>
         <property>

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/application/DefaultViewHandlerSupport.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/application/DefaultViewHandlerSupport.java?rev=1401386&r1=1401385&r2=1401386&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/application/DefaultViewHandlerSupport.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/application/DefaultViewHandlerSupport.java Tue Oct 23 18:59:22 2012
@@ -78,6 +78,27 @@ public class DefaultViewHandlerSupport i
 
     private volatile ConcurrentLRUCache<String, Boolean> _checkedViewIdMap = null;
     private Boolean _checkedViewIdCacheEnabled = null;
+    
+    private final String[] _faceletsViewMappings;
+    private final String[] _contextSuffixes;
+    private final String _faceletsContextSufix;
+    private final boolean _initialized;
+    
+    public DefaultViewHandlerSupport()
+    {
+        _faceletsViewMappings = null;
+        _contextSuffixes = null;
+        _faceletsContextSufix = null;
+        _initialized = false;
+    }
+    
+    public DefaultViewHandlerSupport(FacesContext facesContext)
+    {
+        _faceletsViewMappings = getFaceletsViewMappings(facesContext);
+        _contextSuffixes = getContextSuffix(facesContext);
+        _faceletsContextSufix = getFaceletsContextSuffix(facesContext);
+        _initialized = true;
+    }
 
     public String calculateViewId(FacesContext context, String viewId)
     {
@@ -182,7 +203,7 @@ public class DefaultViewHandlerSupport i
             if (mapping.isExtensionMapping())
             {
                 //See JSF 2.0 section 7.5.2 
-                String[] contextSuffixes = getContextSuffix(context); 
+                String[] contextSuffixes = _initialized ? _contextSuffixes : getContextSuffix(context); 
                 boolean founded = false;
                 for (String contextSuffix : contextSuffixes)
                 {
@@ -407,8 +428,8 @@ public class DefaultViewHandlerSupport i
      */
     protected String handleSuffixMapping(FacesContext context, String requestViewId)
     {
-        String[] faceletsViewMappings = getFaceletsViewMappings(context);
-        String[] jspDefaultSuffixes = getContextSuffix(context);
+        String[] faceletsViewMappings = _initialized ? _faceletsViewMappings : getFaceletsViewMappings(context);
+        String[] jspDefaultSuffixes = _initialized ? _contextSuffixes : getContextSuffix(context);
         
         int slashPos = requestViewId.lastIndexOf('/');
         int extensionPos = requestViewId.lastIndexOf('.');
@@ -467,7 +488,7 @@ public class DefaultViewHandlerSupport i
         }
         
         //jsp suffixes didn't match, try facelets suffix
-        String faceletsDefaultSuffix = this.getFaceletsContextSuffix(context);
+        String faceletsDefaultSuffix = _initialized ? _faceletsContextSufix : this.getFaceletsContextSuffix(context);
         if (faceletsDefaultSuffix != null)
         {
             for (String defaultSuffix : jspDefaultSuffixes)

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlCheckboxRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlCheckboxRendererBase.java?rev=1401386&r1=1401385&r2=1401386&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlCheckboxRendererBase.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlCheckboxRendererBase.java Tue Oct 23 18:59:22 2012
@@ -220,7 +220,14 @@ public class HtmlCheckboxRendererBase ex
             }
 
             writer.startElement(HTML.TD_ELEM, selectMany);
-            writer.write(selectItem.getLabel());
+            if (selectItem.isEscape())
+            {
+                writer.writeText(selectItem.getLabel(),HTML.LABEL_ATTR);
+            }
+            else
+            {
+                writer.write(selectItem.getLabel());
+            }
             writer.endElement(HTML.TD_ELEM);
 
             if (pageDirectionLayout)

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRadioRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRadioRendererBase.java?rev=1401386&r1=1401385&r2=1401386&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRadioRendererBase.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRadioRendererBase.java Tue Oct 23 18:59:22 2012
@@ -194,7 +194,14 @@ public class HtmlRadioRendererBase
             }
 
             writer.startElement(HTML.TD_ELEM, selectOne);
-            writer.write(selectItem.getLabel());
+            if (selectItem.isEscape())
+            {
+                writer.writeText(selectItem.getLabel(),HTML.LABEL_ATTR);
+            }
+            else
+            {
+                writer.write(selectItem.getLabel());
+            }
             writer.endElement(HTML.TD_ELEM);
 
             if (pageDirectionLayout)

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlResponseWriterImpl.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlResponseWriterImpl.java?rev=1401386&r1=1401385&r2=1401386&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlResponseWriterImpl.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlResponseWriterImpl.java Tue Oct 23 18:59:22 2012
@@ -21,8 +21,6 @@ package org.apache.myfaces.shared.render
 import java.io.IOException;
 import java.io.Writer;
 import java.nio.charset.Charset;
-import java.util.HashSet;
-import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -100,8 +98,6 @@ public class HtmlResponseWriterImpl
 
     private boolean _cdataOpen;
 
-    private static final Set<String> S_EMPTY_HTML_ELEMENTS = new HashSet<String>();
-
     private static final String CDATA_START = "<![CDATA[ \n";
     private static final String CDATA_START_NO_LINE_RETURN = "<![CDATA[";
     private static final String COMMENT_START = "<!--\n";
@@ -112,23 +108,86 @@ public class HtmlResponseWriterImpl
     private static final String COMMENT_COMMENT_END = "\n//-->";
     private static final String COMMENT_END = "\n-->";
 
-    static
+    static private final String[][] EMPTY_ELEMENT_ARR = new String[256][];
+
+    static private final String[] A_NAMES = new String[]
     {
-        S_EMPTY_HTML_ELEMENTS.add("area");
-        S_EMPTY_HTML_ELEMENTS.add("br");
-        S_EMPTY_HTML_ELEMENTS.add("base");
-        S_EMPTY_HTML_ELEMENTS.add("basefont");
-        S_EMPTY_HTML_ELEMENTS.add("col");
-        S_EMPTY_HTML_ELEMENTS.add("frame");
-        S_EMPTY_HTML_ELEMENTS.add("hr");
-        S_EMPTY_HTML_ELEMENTS.add("img");
-        S_EMPTY_HTML_ELEMENTS.add("input");
-        S_EMPTY_HTML_ELEMENTS.add("isindex");
-        S_EMPTY_HTML_ELEMENTS.add("link");
-        S_EMPTY_HTML_ELEMENTS.add("meta");
-        S_EMPTY_HTML_ELEMENTS.add("param");
-    }
+      "area",
+    };
+
+    static private final String[] B_NAMES = new String[]
+    {
+      "br",
+      "base",
+      "basefont",
+    };
+
+    static private final String[] C_NAMES = new String[]
+    {
+      "col",
+    };
+
+    static private final String[] E_NAMES = new String[]
+    {
+      "embed",
+    };
+
+    static private final String[] F_NAMES = new String[]
+    {
+      "frame",
+    };
+
+    static private final String[] H_NAMES = new String[]
+    {
+      "hr",
+    };
+
+    static private final String[] I_NAMES = new String[]
+    {
+      "img",
+      "input",
+      "isindex",
+    };
+
+    static private final String[] L_NAMES = new String[]
+    {
+      "link",
+    };
 
+    static private final String[] M_NAMES = new String[]
+    {
+      "meta",
+    };
+
+    static private final String[] P_NAMES = new String[]
+    {
+      "param",
+    };
+
+    static
+    {
+      EMPTY_ELEMENT_ARR['a'] = A_NAMES;
+      EMPTY_ELEMENT_ARR['A'] = A_NAMES;
+      EMPTY_ELEMENT_ARR['b'] = B_NAMES;
+      EMPTY_ELEMENT_ARR['B'] = B_NAMES;
+      EMPTY_ELEMENT_ARR['c'] = C_NAMES;
+      EMPTY_ELEMENT_ARR['C'] = C_NAMES;
+      EMPTY_ELEMENT_ARR['e'] = E_NAMES;
+      EMPTY_ELEMENT_ARR['E'] = E_NAMES;
+      EMPTY_ELEMENT_ARR['f'] = F_NAMES;
+      EMPTY_ELEMENT_ARR['F'] = F_NAMES;
+      EMPTY_ELEMENT_ARR['h'] = H_NAMES;
+      EMPTY_ELEMENT_ARR['H'] = H_NAMES;
+      EMPTY_ELEMENT_ARR['i'] = I_NAMES;
+      EMPTY_ELEMENT_ARR['I'] = I_NAMES;
+      EMPTY_ELEMENT_ARR['l'] = L_NAMES;
+      EMPTY_ELEMENT_ARR['L'] = L_NAMES;
+      EMPTY_ELEMENT_ARR['m'] = M_NAMES;
+      EMPTY_ELEMENT_ARR['M'] = M_NAMES;
+      EMPTY_ELEMENT_ARR['p'] = P_NAMES;
+      EMPTY_ELEMENT_ARR['P'] = P_NAMES;
+    }    
+    
     public HtmlResponseWriterImpl(Writer writer, String contentType, String characterEncoding)
     {
         this(writer,contentType,characterEncoding,true);
@@ -298,7 +357,7 @@ public class HtmlResponseWriterImpl
     {
         if (_startTagOpen)
         {
-            if (!_useStraightXml && S_EMPTY_HTML_ELEMENTS.contains(_startElementName.toLowerCase()))
+            if (!_useStraightXml && isEmptyElement(_startElementName))
             {
                 _currentWriter.write(" />");
                 // make null, this will cause NullPointer in some invalid element nestings
@@ -342,6 +401,29 @@ public class HtmlResponseWriterImpl
             _startTagOpen = false;
         }
     }
+    
+    private boolean isEmptyElement(String elem)
+    {
+        // Code taken from trinidad
+        // =-=AEW Performance?  Certainly slower to use a hashtable,
+        // at least if we can't assume the input name is lowercased.
+        // -= Leonardo Uribe =- elem.toLowerCase() internally creates an array,
+        // and the contains() force a call to hashCode(). The array uses simple
+        // char comparison, which at the end is faster and use less memory.
+        // Note this call is very frequent, so at the end it is worth to do it.
+        String[] array = EMPTY_ELEMENT_ARR[elem.charAt(0)];
+        if (array != null)
+        {
+            for (int i = array.length - 1; i >= 0; i--)
+            {
+                if (elem.equalsIgnoreCase(array[i]))
+                {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
 
     private void resetStartedElement()
     {
@@ -396,7 +478,7 @@ public class HtmlResponseWriterImpl
         }
         else
         {
-            if (!_useStraightXml && S_EMPTY_HTML_ELEMENTS.contains(name.toLowerCase()))
+            if (!_useStraightXml && isEmptyElement(name))
             {
            /*
            Should this be here?  It warns even when you have an x:htmlTag value="br", it should just close.