commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject commons-scxml git commit: SCXML-246: Javascript engine requires global context execution - See: https://issues.apache.org/jira/browse/SCXML-246
Date Sat, 02 Jan 2016 14:45:08 GMT
Repository: commons-scxml
Updated Branches:
  refs/heads/master 7d68a7487 -> a5d7dd51e


SCXML-246: Javascript engine requires global context execution
- See: https://issues.apache.org/jira/browse/SCXML-246


Project: http://git-wip-us.apache.org/repos/asf/commons-scxml/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-scxml/commit/a5d7dd51
Tree: http://git-wip-us.apache.org/repos/asf/commons-scxml/tree/a5d7dd51
Diff: http://git-wip-us.apache.org/repos/asf/commons-scxml/diff/a5d7dd51

Branch: refs/heads/master
Commit: a5d7dd51ec0942096afc8dae17abaaec09e93366
Parents: 7d68a74
Author: Ate Douma <ate@apache.org>
Authored: Sat Jan 2 15:44:55 2016 +0100
Committer: Ate Douma <ate@apache.org>
Committed: Sat Jan 2 15:44:55 2016 +0100

----------------------------------------------------------------------
 src/main/java/org/apache/commons/scxml2/Evaluator.java   |  6 ++++++
 src/main/java/org/apache/commons/scxml2/SCInstance.java  |  3 +++
 .../commons/scxml2/env/groovy/GroovyEvaluator.java       |  5 +++++
 .../commons/scxml2/env/javascript/JSEvaluator.java       | 11 ++++++++++-
 .../apache/commons/scxml2/env/jexl/JexlEvaluator.java    |  5 +++++
 .../commons/scxml2/env/minimal/MinimalEvaluator.java     |  5 +++++
 6 files changed, 34 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/a5d7dd51/src/main/java/org/apache/commons/scxml2/Evaluator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/Evaluator.java b/src/main/java/org/apache/commons/scxml2/Evaluator.java
index 9878d0a..d6ddd77 100644
--- a/src/main/java/org/apache/commons/scxml2/Evaluator.java
+++ b/src/main/java/org/apache/commons/scxml2/Evaluator.java
@@ -73,6 +73,12 @@ public interface Evaluator {
     String getSupportedDatamodel();
 
     /**
+     * If this Evaluator only supports a global context.
+     * @return true if this Evaluator only support a global context
+     */
+    boolean requiresGlobalContext();
+
+    /**
      * @param data data to be cloned
      * @return A deep clone of the data
      */

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/a5d7dd51/src/main/java/org/apache/commons/scxml2/SCInstance.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/SCInstance.java b/src/main/java/org/apache/commons/scxml2/SCInstance.java
index 39f2e11..73051ab 100644
--- a/src/main/java/org/apache/commons/scxml2/SCInstance.java
+++ b/src/main/java/org/apache/commons/scxml2/SCInstance.java
@@ -155,6 +155,9 @@ public class SCInstance implements Serializable {
         if (evaluator == null) {
             evaluator = EvaluatorFactory.getEvaluator(stateMachine);
         }
+        if (evaluator.requiresGlobalContext()) {
+            singleContext = true;
+        }
         if (stateMachine.getDatamodelName() != null && !stateMachine.getDatamodelName().equals(evaluator.getSupportedDatamodel()))
{
             throw new ModelException("Incompatible SCXML document datamodel \""+stateMachine.getDatamodelName()+"\""
                     + " for evaluator "+evaluator.getClass().getName()+" supported datamodel
\""+evaluator.getSupportedDatamodel()+"\"");

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/a5d7dd51/src/main/java/org/apache/commons/scxml2/env/groovy/GroovyEvaluator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/groovy/GroovyEvaluator.java b/src/main/java/org/apache/commons/scxml2/env/groovy/GroovyEvaluator.java
index 451ac42..4f2a8af 100644
--- a/src/main/java/org/apache/commons/scxml2/env/groovy/GroovyEvaluator.java
+++ b/src/main/java/org/apache/commons/scxml2/env/groovy/GroovyEvaluator.java
@@ -163,6 +163,11 @@ public class GroovyEvaluator extends AbstractBaseEvaluator {
         return SUPPORTED_DATA_MODEL;
     }
 
+    @Override
+    public boolean requiresGlobalContext() {
+        return false;
+    }
+
     /**
      * Evaluate an expression.
      *

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/a5d7dd51/src/main/java/org/apache/commons/scxml2/env/javascript/JSEvaluator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/javascript/JSEvaluator.java b/src/main/java/org/apache/commons/scxml2/env/javascript/JSEvaluator.java
index 92e6c64..2f9641d 100644
--- a/src/main/java/org/apache/commons/scxml2/env/javascript/JSEvaluator.java
+++ b/src/main/java/org/apache/commons/scxml2/env/javascript/JSEvaluator.java
@@ -68,7 +68,7 @@ public class JSEvaluator extends AbstractBaseEvaluator {
 
     /** Error message if evaluation context is not a JexlContext. */
     private static final String ERR_CTX_TYPE = "Error evaluating JavaScript "
-        + "expression, Context must be a org.apache.commons.scxml2.env.javascript.JSContext";
+            + "expression, Context must be a org.apache.commons.scxml2.env.javascript.JSContext";
 
     /** Pattern for recognizing the SCXML In() special predicate. */
     private static final Pattern IN_FN = Pattern.compile("In\\(");
@@ -101,6 +101,15 @@ public class JSEvaluator extends AbstractBaseEvaluator {
     }
 
     /**
+     * Javascript engine semantics, using a retained global state, requires global SCXML
context execution
+     * @return true
+     */
+    @Override
+    public boolean requiresGlobalContext() {
+        return true;
+    }
+
+    /**
      * Creates a child context.
      *
      * @return Returns a new child JSContext.

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/a5d7dd51/src/main/java/org/apache/commons/scxml2/env/jexl/JexlEvaluator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/jexl/JexlEvaluator.java b/src/main/java/org/apache/commons/scxml2/env/jexl/JexlEvaluator.java
index af02a0b..d306ca2 100644
--- a/src/main/java/org/apache/commons/scxml2/env/jexl/JexlEvaluator.java
+++ b/src/main/java/org/apache/commons/scxml2/env/jexl/JexlEvaluator.java
@@ -142,6 +142,11 @@ public class JexlEvaluator extends AbstractBaseEvaluator {
         return SUPPORTED_DATA_MODEL;
     }
 
+    @Override
+    public boolean requiresGlobalContext() {
+        return false;
+    }
+
     /**
      * Evaluate an expression.
      *

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/a5d7dd51/src/main/java/org/apache/commons/scxml2/env/minimal/MinimalEvaluator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/env/minimal/MinimalEvaluator.java b/src/main/java/org/apache/commons/scxml2/env/minimal/MinimalEvaluator.java
index 0afefec..0bad641 100644
--- a/src/main/java/org/apache/commons/scxml2/env/minimal/MinimalEvaluator.java
+++ b/src/main/java/org/apache/commons/scxml2/env/minimal/MinimalEvaluator.java
@@ -62,6 +62,11 @@ public class MinimalEvaluator implements Evaluator, Serializable {
     }
 
     @Override
+    public boolean requiresGlobalContext() {
+        return true;
+    }
+
+    @Override
     public Object cloneData(final Object data) {
         return data;
     }


Mime
View raw message