mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V2.2 to HEAD
10931: Merged V2.1 to V2.2 9931: Fix for https://issues.alfresco.com/jira/browse/ETWOONE-295 10094: Further fix for ETWOONE-241: SAXException - XML parser apparently is not thread safe 10101: Resolve ACT 1282: wcm workflow falling over on Oracle while hitting in clause limit of 1000 expressions. 10188: https://issues.alfresco.com/jira/browse/ETWOONE-74 (Part 1) 10447: ETWOONE-328: performance improvement added to rule trigger code 10455: Fix for ETWOONE-306. 10292: Fix for ETWOONE-92: If two users update the same contents at the same time, you get InvalidNodeRefException 10293: Fix for ETWOONE-116: Send email action does not handle invalid email address 10294: Fix for ETWOONE-164: when a powerpoint 2007 pptx is stored in alfresco ... 10341: Action Evaluator request level cache git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10934 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -27,6 +27,9 @@ package org.alfresco.web.ui.repo.component.evaluator;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.el.ValueBinding;
|
||||
|
||||
@@ -42,6 +45,8 @@ import org.alfresco.web.ui.common.component.evaluator.BaseEvaluator;
|
||||
*/
|
||||
public class ActionInstanceEvaluator extends BaseEvaluator
|
||||
{
|
||||
private static final String EVALUATOR_CACHE = "_alf_evaluator_cache";
|
||||
|
||||
/**
|
||||
* Evaluate by executing the specified action instance evaluator.
|
||||
*
|
||||
@@ -56,7 +61,7 @@ public class ActionInstanceEvaluator extends BaseEvaluator
|
||||
final Object obj = this.getValue();
|
||||
if (obj instanceof Node)
|
||||
{
|
||||
result = this.getEvaluator().evaluate((Node)obj);
|
||||
result = evaluateCachedResult((Node)obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -87,6 +92,49 @@ public class ActionInstanceEvaluator extends BaseEvaluator
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* To reduce invocations of a particular evaluator for a particular node
|
||||
* save a cache of evaluator result for a node against the current request.
|
||||
* Since the same evaluator may get reused several times for multiple actions, but
|
||||
* in effect execute against the same node instance, this can significantly reduce
|
||||
* the number of invocations required for a particular evaluator.
|
||||
*
|
||||
* @param node Node to evaluate against
|
||||
*
|
||||
* @return evaluator result
|
||||
*/
|
||||
private boolean evaluateCachedResult(Node node)
|
||||
{
|
||||
Boolean result;
|
||||
|
||||
ActionEvaluator evaluator = getEvaluator();
|
||||
String cacheKey = node.getNodeRef().toString() + '_' + evaluator.getClass().getName();
|
||||
Map<String, Boolean> cache = getEvaluatorResultCache();
|
||||
result = cache.get(cacheKey);
|
||||
if (result == null)
|
||||
{
|
||||
result = evaluator.evaluate(node);
|
||||
cache.put(cacheKey, result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the evaluator result cache - tied to the current request
|
||||
*/
|
||||
private Map<String, Boolean> getEvaluatorResultCache()
|
||||
{
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
Map<String, Boolean> cache = (Map<String, Boolean>)fc.getExternalContext().getRequestMap().get(EVALUATOR_CACHE);
|
||||
if (cache == null)
|
||||
{
|
||||
cache = new HashMap<String, Boolean>(64, 1.0f);
|
||||
fc.getExternalContext().getRequestMap().put(EVALUATOR_CACHE, cache);
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext, java.lang.Object)
|
||||
*/
|
||||
|
Reference in New Issue
Block a user