You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by an...@apache.org on 2014/01/23 16:08:35 UTC
svn commit: r1560707 - in
/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad:
bean/util/ValueMap.java component/UIXComponentBase.java
Author: andys
Date: Thu Jan 23 15:08:34 2014
New Revision: 1560707
URL: http://svn.apache.org/r1560707
Log:
TRINIDAD-2447 UIComponent.isCompositeComponent() is slow for UIXComponents
Modified:
myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/ValueMap.java
myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java
Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/ValueMap.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/ValueMap.java?rev=1560707&r1=1560706&r2=1560707&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/ValueMap.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/ValueMap.java Thu Jan 23 15:08:34 2014
@@ -100,11 +100,34 @@ public class ValueMap extends AbstractMa
throw new NullPointerException();
PropertyKey propertyKey = _getPropertyKey(key);
-
- if (_bean.keySet().contains(propertyKey))
- return true;
- else
- return _bean.bindingKeySet().contains(propertyKey);
+
+ // Some notes:
+ //
+ // 1. We could optimize this further by exposing containsLocalKey()
+ // and containsValueExpression() methods on FacesBean. This would
+ // allow FacesBean implementations to avoid retrieving the
+ // actual property value. (For example, FacesBean implememtations
+ // that delegate to FlaggedPropertyMap would be able to short-circuit
+ // after checking flags, rather than have to look up the value in
+ // the underlying PropertyMap.) However, since this requires an
+ // API change to the FacesBean interface, we are skipping this for
+ // now. We should re-evaluate once we can rely on Java 8 (and take
+ // advantage of defender methods).
+ //
+ // 2. ValueMap.containsKey() has always checked for the presence of either
+ // a local property value or a value expression. This differs from
+ // the corresponding code in Mojarra and MyFaces. Both Mojarra and
+ // MyFaces implement UIComponent.getAttributes().containsKey() by
+ // only checking for the presence of a local propery. Thus, to be
+ // consistent, we could call _bean.getLocalProperty() here. However,
+ // given that ValueMap has behaved this way forever, we may have
+ // users that depend on the current behavior. As such, leaving
+ // this as is.
+ //
+ // 3. The "!= null" comparison that we perform here relies on the assumption
+ // that FacesBean does not allow null property values. While this is not
+ // obvious from the FacesBean documentation, this is true in practice.
+ return (_bean.getRawProperty(propertyKey) != null);
}
@Override
Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java?rev=1560707&r1=1560706&r2=1560707&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java Thu Jan 23 15:08:34 2014
@@ -40,6 +40,7 @@ import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.application.ProjectStage;
+import javax.faces.application.Resource;
import javax.faces.component.ContextCallback;
import javax.faces.component.NamingContainer;
import javax.faces.component.StateHolder;
@@ -166,6 +167,12 @@ abstract public class UIXComponentBase e
TYPE.registerKey("javax.faces.webapp.FACET_NAMES",
List.class,
PropertyKey.CAP_NOT_BOUND);
+
+ // JSF hammers on this property during component pushing/popping.
+ // Register the PropertyKey to optimize property lookups.
+ TYPE.registerKey(Resource.COMPONENT_RESOURCE_KEY,
+ PropertyKey.CAP_NOT_BOUND);
+
TYPE.lock();
}