From e6df53908aa32a92884ce2dfc11ff78124240ae6 Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Thu, 11 Mar 2010 12:31:51 +0000 Subject: [PATCH] Merged V3.2 to HEAD 19216: ENH-506 - allow script compilation to be disabled for repository tier. Fix to unreported issue with return aspect array from a ScriptNode. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19221 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/jscript/RhinoScriptProcessor.java | 15 +++++++++++++-- .../org/alfresco/repo/jscript/ScriptNode.java | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/source/java/org/alfresco/repo/jscript/RhinoScriptProcessor.java b/source/java/org/alfresco/repo/jscript/RhinoScriptProcessor.java index fc55db87c3..9071cae12b 100644 --- a/source/java/org/alfresco/repo/jscript/RhinoScriptProcessor.java +++ b/source/java/org/alfresco/repo/jscript/RhinoScriptProcessor.java @@ -86,6 +86,9 @@ public class RhinoScriptProcessor extends BaseProcessor implements ScriptProcess /** Pre initialized non secure scope object. */ private Scriptable nonSecureScope; + /** Flag to enable or disable runtime script compliation */ + private boolean compile = true; + /** Cache of runtime compiled script instances */ private final Map scriptCache = new ConcurrentHashMap(256); @@ -108,6 +111,14 @@ public class RhinoScriptProcessor extends BaseProcessor implements ScriptProcess this.storePath = storePath; } + /** + * @param compile the compile flag to set + */ + public void setCompile(boolean compile) + { + this.compile = compile; + } + /** * @see org.alfresco.service.cmr.repository.ScriptProcessor#reset() */ @@ -126,7 +137,7 @@ public class RhinoScriptProcessor extends BaseProcessor implements ScriptProcess // test the cache for a pre-compiled script matching our path Script script = null; String path = location.getPath(); - if (location.isCachable()) + if (this.compile && location.isCachable()) { script = this.scriptCache.get(path); } @@ -154,7 +165,7 @@ public class RhinoScriptProcessor extends BaseProcessor implements ScriptProcess // rely on the ConcurrentHashMap impl to deal both with ensuring the safety of the // underlying structure with asynchronous get/put operations and for fast // multi-threaded access to the common cache. - if (location.isCachable()) + if (this.compile && location.isCachable()) { this.scriptCache.put(path, script); } diff --git a/source/java/org/alfresco/repo/jscript/ScriptNode.java b/source/java/org/alfresco/repo/jscript/ScriptNode.java index 71df1b1009..51dc83d3d8 100644 --- a/source/java/org/alfresco/repo/jscript/ScriptNode.java +++ b/source/java/org/alfresco/repo/jscript/ScriptNode.java @@ -894,7 +894,7 @@ public class ScriptNode implements Serializable, Scopeable, NamespacePrefixResol public Scriptable getAspects() { Set aspects = getAspectsSet(); - String[] result = new String[aspects.size()]; + Object[] result = new Object[aspects.size()]; int count = 0; for (QName qname : aspects) {