You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bs...@apache.org on 2010/03/04 05:27:32 UTC

svn commit: r918847 - in /myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component: UIXCollection.java UIXComponent.java UIXComponentBase.java

Author: bsullivan
Date: Thu Mar  4 04:27:32 2010
New Revision: 918847

URL: http://svn.apache.org/viewvc?rev=918847&view=rev
Log:
Fixes for TRINIDAD-1740 Replace Trinidad TreeVisiting APIs with JSF 2 TreeVisiting APIs
TRINIDAD-1669 Improve transient memory consumption of UIXComponentBase.getClientId()

UIXComponent was accidentally calling the wrong CoreRenderer versions of setup/tearDownEncoding context (the deprecated ones that take UIXComponents, rather than the correct ones that take UIComponents)

Fix UIXComponentBase clientID caching enabling code
Speed up clientId clearing when stamping in UIXCollection

Modified:
    myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
    myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java
    myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java

Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java?rev=918847&r1=918846&r2=918847&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java Thu Mar  4 04:27:32 2010
@@ -811,7 +811,10 @@
     // ensure the client IDs are reset on the component, otherwise they will not get the
     // proper stamped IDs. This mirrors the behavior in UIData and follows the JSF specification
     // on when client IDs are allowed to be cached and when they must be reset
-    clearCachedClientIds();
+    List<UIComponent> stamps = getStamps();
+    
+    for (UIComponent stamp : stamps)
+      UIXComponent.clearCachedClientIds(stamp);
   }
 
   /**

Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java?rev=918847&r1=918846&r2=918847&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java Thu Mar  4 04:27:32 2010
@@ -316,10 +316,10 @@
   * whose <code>visit</code> method will be called
   * for each node visited.
   * @return component implementations may return <code>true</code>
-  *   to indicate that the tree visit is complete (eg. all components
-  *   that need to be visited have been visited).  This results in
-  *   the tree visit being short-circuited such that no more components
-  *   are visited.
+  * to indicate that the tree visit is complete (eg. all components
+  * that need to be visited have been visited).  This results in
+  * the tree visit being short-circuited such that no more components
+  * are visited.
   *
   * @see VisitContext#invokeVisitCallback VisitContext.invokeVisitCallback()
   */
@@ -858,7 +858,7 @@
     {
       CoreRenderer coreRenderer = (CoreRenderer)renderer;
 
-      coreRenderer.setupEncodingContext(context, rc, this);
+      coreRenderer.setupEncodingContext(context, rc, (UIComponent)this);
     }
   }
 
@@ -912,7 +912,7 @@
       {
         CoreRenderer coreRenderer = (CoreRenderer)renderer;
 
-        coreRenderer.tearDownEncodingContext(context, rc, this);
+        coreRenderer.tearDownEncodingContext(context, rc, (UIComponent)this);
       }
     }
     finally

Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java?rev=918847&r1=918846&r2=918847&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java Thu Mar  4 04:27:32 2010
@@ -30,8 +30,6 @@
 import java.util.Map;
 import java.util.Properties;
 
-import java.util.concurrent.atomic.AtomicBoolean;
-
 import java.util.concurrent.atomic.AtomicReference;
 
 import javax.el.ELContext;
@@ -264,8 +262,6 @@
     }
   }
 
-
-
   /**
    */
   @Override
@@ -285,7 +281,6 @@
     return getFacesBean().getValueBinding(key);
   }
 
-
   @Override
   public void setValueBinding(String name, ValueBinding binding)
   {
@@ -296,7 +291,6 @@
     getFacesBean().setValueBinding(key, binding);
   }
 
-
   @Override
   public Map<String, Object> getAttributes()
   {
@@ -348,8 +342,6 @@
     return clientId;
   }
   
-
-
   @Override
   public String getClientId(FacesContext context)
   {
@@ -385,14 +377,13 @@
     }
   }
 
-
   /**
    * Gets the identifier for the component.  This implementation
    * never returns a null id.
    */
   @Override
   public String getId()
-  {  
+  {
     // determine whether we can use the optimized code path or not
     if (_usesFacesBeanImpl)
     {
@@ -425,7 +416,6 @@
     }
   }
 
-
   /**
    * Sets the identifier for the component.  The identifier
    * must follow a subset of the syntax allowed in HTML:
@@ -472,14 +462,12 @@
   @Override
   abstract public String getFamily();
 
-
   @Override
   public UIComponent getParent()
   {
     return _parent;
   }
 
-
   /**
    * <p>Set the parent <code>UIComponent</code> of this
    * <code>UIComponent</code>.</p>
@@ -511,14 +499,12 @@
     }
   }
 
-
   @Override
   public boolean isRendered()
   {
     return getBooleanProperty(RENDERED_KEY, true);
   }
 
-
   @Override
   public void setRendered(boolean rendered)
   {
@@ -567,7 +553,6 @@
     setProperty(RENDERER_TYPE_KEY, rendererType);
   }
 
-
   @Override
   public boolean getRendersChildren()
   {
@@ -578,13 +563,8 @@
     return renderer.getRendersChildren();
   }
 
-
-
-
   // ------------------------------------------------ Tree Management Methods
 
-
-
   @Override
   public UIComponent findComponent(String id)
   {
@@ -655,8 +635,6 @@
     }
   }
 
-
-
   /**
    * <p>Create (if necessary) and return a List of the children associated
    * with this component.</p>
@@ -679,7 +657,6 @@
       return getChildren().size();
   }
 
-
   /**
    * <p>Create (if necessary) and return a Map of the facets associated
    * with this component.</p>
@@ -694,7 +671,6 @@
     return _facets;
   }
 
-
   @Override
   public UIComponent getFacet(String facetName)
   {
@@ -707,7 +683,6 @@
       return getFacets().get(facetName);
   }
 
-
   /**
    * Returns an Iterator over the names of all facets.
    * Unlike getFacets().keySet().iterator(), this does
@@ -795,9 +770,8 @@
   }
 
   // ------------------------------------------- Lifecycle Processing Methods
-
-
-  @Override
+  
+@Override
   public void decode(FacesContext context)
   {
     if (context == null)
@@ -1069,7 +1043,6 @@
     return FacesContext.getCurrentInstance();
   }
 
-
   /**
    * Delegates to LifecycleRenderer, if present,
    * otherwise calls decodeChildrenImpl.
@@ -1104,7 +1077,6 @@
     }
   }
 
-
   /**
    * Delegates to LifecycleRenderer, if present,
    * otherwise calls validateChildrenImpl.
@@ -1140,7 +1112,6 @@
     }
   }
 
-
   /**
    * Delegates to LifecycleRenderer, if present,
    * otherwise calls upateChildrenImpl.
@@ -1326,7 +1297,6 @@
     return n.intValue();
   }
 
-
   /**
    * Return the number of facets.  This is more efficient than
    * calling getFacets().size();
@@ -1340,7 +1310,6 @@
     return _facets.size();
   }
 
-
   /**
    * Broadcast an event to a MethodBinding.
    * This can be used to support MethodBindings such as the "actionListener"
@@ -1493,7 +1462,6 @@
     }
   }
   
-
   /**
    * Override to calls the hooks for setting up and tearing down the
    * context before the children are visited.
@@ -1506,7 +1474,7 @@
     String clientId,
     ContextCallback callback)
     throws FacesException
-  {    
+  {
     String thisClientId = getClientId(context);
 
     if (clientId.equals(thisClientId))
@@ -1617,7 +1585,6 @@
     }
   }
 
-
   static private UIComponent _findInsideOf(
     UIComponent from,
     String id)
@@ -1746,7 +1713,6 @@
   //private transient boolean _initialStateMarked;
 
   private static final Iterator<String> _EMPTY_STRING_ITERATOR = CollectionUtils.emptyIterator();
-
   private static final Iterator<UIComponent> _EMPTY_UICOMPONENT_ITERATOR =
                                                                   CollectionUtils.emptyIterator();
 
@@ -1801,6 +1767,9 @@
   {
   }
 
+  /**
+   * Temporary function controlling whether clientId caching is enabled
+   */
   private static boolean _isClientIdCachingEnabled(FacesContext context)
   {
     if (context == null)
@@ -1810,11 +1779,14 @@
     
     if (cacheClientIds == null)
     {
-      // see if client  is enabled for the application (the default is off)
-      boolean cachingEnabled = Boolean.TRUE.equals(
-                          context.getExternalContext().
-                          getApplicationMap().get(_INIT_PROP_CLIENT_ID_CACHING_ENABLED));
+      // get the servlet initialization parameter
+      String cachingParam = context.getExternalContext().getInitParameter(
+                                                             _INIT_PROP_CLIENT_ID_CACHING_ENABLED);
       
+      Boolean cachingEnabled  = (cachingParam != null)
+                                  ? Boolean.valueOf(cachingParam)
+                                  : Boolean.FALSE;  // default to false
+
       // cache the servlet initialization value
       _sClientIdCachingEnabled.set(cachingEnabled ? Boolean.TRUE : Boolean.FALSE);