You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by de...@apache.org on 2017/09/17 12:30:50 UTC
[myfaces-trinidad] 27/36: Fixes for TRINIDAD-1740 Replace Trinidad
TreeVisiting APIs with JSF 2 TreeVisiting APIs TRINIDAD-1669 Improve
transient memory consumption of UIXComponentBase.getClientId()
This is an automated email from the ASF dual-hosted git repository.
deki pushed a commit to branch 1.2.12.2-branch
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad.git
commit 995fe9b32518050f115e877a7be0d75491f460da
Author: Blake Sullivan <bs...@apache.org>
AuthorDate: Thu Mar 4 04:27:32 2010 +0000
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
---
.../myfaces/trinidad/component/UIXCollection.java | 5 +-
.../myfaces/trinidad/component/UIXComponent.java | 12 ++---
.../trinidad/component/UIXComponentBase.java | 56 ++++++----------------
3 files changed, 24 insertions(+), 49 deletions(-)
diff --git a/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java b/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
index 1b3ec68..e90479d 100644
--- a/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
+++ b/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
@@ -811,7 +811,10 @@ public abstract class UIXCollection extends UIXComponentBase
// 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);
}
/**
diff --git a/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java b/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java
index 686a777..da9071e 100644
--- a/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java
+++ b/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java
@@ -316,10 +316,10 @@ abstract public class UIXComponent extends UIComponent
* 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 @@ abstract public class UIXComponent extends UIComponent
{
CoreRenderer coreRenderer = (CoreRenderer)renderer;
- coreRenderer.setupEncodingContext(context, rc, this);
+ coreRenderer.setupEncodingContext(context, rc, (UIComponent)this);
}
}
@@ -912,7 +912,7 @@ abstract public class UIXComponent extends UIComponent
{
CoreRenderer coreRenderer = (CoreRenderer)renderer;
- coreRenderer.tearDownEncodingContext(context, rc, this);
+ coreRenderer.tearDownEncodingContext(context, rc, (UIComponent)this);
}
}
finally
diff --git a/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java b/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java
index 335c8f8..a1b5b01 100644
--- a/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java
+++ b/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java
@@ -30,8 +30,6 @@ import java.util.List;
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 @@ abstract public class UIXComponentBase extends UIXComponent
}
}
-
-
/**
*/
@Override
@@ -285,7 +281,6 @@ abstract public class UIXComponentBase extends UIXComponent
return getFacesBean().getValueBinding(key);
}
-
@Override
public void setValueBinding(String name, ValueBinding binding)
{
@@ -296,7 +291,6 @@ abstract public class UIXComponentBase extends UIXComponent
getFacesBean().setValueBinding(key, binding);
}
-
@Override
public Map<String, Object> getAttributes()
{
@@ -348,8 +342,6 @@ abstract public class UIXComponentBase extends UIXComponent
return clientId;
}
-
-
@Override
public String getClientId(FacesContext context)
{
@@ -385,14 +377,13 @@ abstract public class UIXComponentBase extends UIXComponent
}
}
-
/**
* 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 @@ abstract public class UIXComponentBase extends UIXComponent
}
}
-
/**
* Sets the identifier for the component. The identifier
* must follow a subset of the syntax allowed in HTML:
@@ -472,14 +462,12 @@ abstract public class UIXComponentBase extends UIXComponent
@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 @@ abstract public class UIXComponentBase extends UIXComponent
}
}
-
@Override
public boolean isRendered()
{
return getBooleanProperty(RENDERED_KEY, true);
}
-
@Override
public void setRendered(boolean rendered)
{
@@ -567,7 +553,6 @@ abstract public class UIXComponentBase extends UIXComponent
setProperty(RENDERER_TYPE_KEY, rendererType);
}
-
@Override
public boolean getRendersChildren()
{
@@ -578,13 +563,8 @@ abstract public class UIXComponentBase extends UIXComponent
return renderer.getRendersChildren();
}
-
-
-
// ------------------------------------------------ Tree Management Methods
-
-
@Override
public UIComponent findComponent(String id)
{
@@ -655,8 +635,6 @@ abstract public class UIXComponentBase extends UIXComponent
}
}
-
-
/**
* <p>Create (if necessary) and return a List of the children associated
* with this component.</p>
@@ -679,7 +657,6 @@ abstract public class UIXComponentBase extends UIXComponent
return getChildren().size();
}
-
/**
* <p>Create (if necessary) and return a Map of the facets associated
* with this component.</p>
@@ -694,7 +671,6 @@ abstract public class UIXComponentBase extends UIXComponent
return _facets;
}
-
@Override
public UIComponent getFacet(String facetName)
{
@@ -707,7 +683,6 @@ abstract public class UIXComponentBase extends UIXComponent
return getFacets().get(facetName);
}
-
/**
* Returns an Iterator over the names of all facets.
* Unlike getFacets().keySet().iterator(), this does
@@ -795,9 +770,8 @@ abstract public class UIXComponentBase extends UIXComponent
}
// ------------------------------------------- Lifecycle Processing Methods
-
-
- @Override
+
+@Override
public void decode(FacesContext context)
{
if (context == null)
@@ -1069,7 +1043,6 @@ abstract public class UIXComponentBase extends UIXComponent
return FacesContext.getCurrentInstance();
}
-
/**
* Delegates to LifecycleRenderer, if present,
* otherwise calls decodeChildrenImpl.
@@ -1104,7 +1077,6 @@ abstract public class UIXComponentBase extends UIXComponent
}
}
-
/**
* Delegates to LifecycleRenderer, if present,
* otherwise calls validateChildrenImpl.
@@ -1140,7 +1112,6 @@ abstract public class UIXComponentBase extends UIXComponent
}
}
-
/**
* Delegates to LifecycleRenderer, if present,
* otherwise calls upateChildrenImpl.
@@ -1326,7 +1297,6 @@ abstract public class UIXComponentBase extends UIXComponent
return n.intValue();
}
-
/**
* Return the number of facets. This is more efficient than
* calling getFacets().size();
@@ -1340,7 +1310,6 @@ abstract public class UIXComponentBase extends UIXComponent
return _facets.size();
}
-
/**
* Broadcast an event to a MethodBinding.
* This can be used to support MethodBindings such as the "actionListener"
@@ -1493,7 +1462,6 @@ abstract public class UIXComponentBase extends UIXComponent
}
}
-
/**
* Override to calls the hooks for setting up and tearing down the
* context before the children are visited.
@@ -1506,7 +1474,7 @@ abstract public class UIXComponentBase extends UIXComponent
String clientId,
ContextCallback callback)
throws FacesException
- {
+ {
String thisClientId = getClientId(context);
if (clientId.equals(thisClientId))
@@ -1617,7 +1585,6 @@ abstract public class UIXComponentBase extends UIXComponent
}
}
-
static private UIComponent _findInsideOf(
UIComponent from,
String id)
@@ -1746,7 +1713,6 @@ abstract public class UIXComponentBase extends UIXComponent
//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 @@ abstract public class UIXComponentBase extends UIXComponent
{
}
+ /**
+ * Temporary function controlling whether clientId caching is enabled
+ */
private static boolean _isClientIdCachingEnabled(FacesContext context)
{
if (context == null)
@@ -1810,11 +1779,14 @@ abstract public class UIXComponentBase extends UIXComponent
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);
--
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.