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-279 Only use default Jexl3 setting for silent (false) and strict (true), cleanup APIs accordingly
Date Sun, 21 Jan 2018 22:47:09 GMT
Repository: commons-scxml
Updated Branches:
  refs/heads/master 05e94b822 -> 3c8c62b34


SCXML-279 Only use default Jexl3 setting for silent (false) and strict (true), cleanup APIs
accordingly

This drops the API changes from SCXML=258, allowing to run SCXML in strict mode (non-strict
being the default)
which only was applicable for Jexl anyway.

This also removes the remaining flags in JexlEvaluator for dynamically setting silent/strict
mode,
which were introduced in SCXML-183. Note that the upgrade to Jexl3 (see SCXML-254) already
made these flags defunct.


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

Branch: refs/heads/master
Commit: 3c8c62b342d0e5b666930e2cb2a42606d76e44df
Parents: 05e94b8
Author: Ate Douma <ate@apache.org>
Authored: Sun Jan 21 23:46:17 2018 +0100
Committer: Ate Douma <ate@apache.org>
Committed: Sun Jan 21 23:46:17 2018 +0100

----------------------------------------------------------------------
 .../org/apache/commons/scxml2/Evaluator.java    |  5 ---
 .../apache/commons/scxml2/EvaluatorFactory.java |  5 ++-
 .../commons/scxml2/EvaluatorProvider.java       | 19 ----------
 .../org/apache/commons/scxml2/SCInstance.java   | 20 ++---------
 .../apache/commons/scxml2/SCXMLExecutor.java    |  9 -----
 .../scxml2/env/groovy/GroovyEvaluator.java      | 14 --------
 .../scxml2/env/javascript/JSEvaluator.java      | 14 --------
 .../commons/scxml2/env/jexl/JexlEvaluator.java  | 38 +-------------------
 .../scxml2/env/minimal/MinimalEvaluator.java    | 15 --------
 .../scxml2/model/actions-initial-test.xml       |  2 +-
 .../scxml2/model/actions-parallel-test.xml      |  2 +-
 .../commons/scxml2/model/actions-state-test.xml |  2 +-
 .../org/apache/commons/scxml2/w3c/W3CTests.java |  1 -
 13 files changed, 8 insertions(+), 138 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/3c8c62b3/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 15f64ec..f85d1e0 100644
--- a/src/main/java/org/apache/commons/scxml2/Evaluator.java
+++ b/src/main/java/org/apache/commons/scxml2/Evaluator.java
@@ -33,11 +33,6 @@ public interface Evaluator {
     String DEFAULT_DATA_MODEL = "";
 
     /**
-     * @return indicates if using strict / specification compliant behavior
-     */
-    boolean isStrict();
-
-    /**
      * Get the datamodel type supported by this Evaluator
      * @return The supported datamodel type
      */

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/3c8c62b3/src/main/java/org/apache/commons/scxml2/EvaluatorFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/EvaluatorFactory.java b/src/main/java/org/apache/commons/scxml2/EvaluatorFactory.java
index 0024d4c..49f71b4 100644
--- a/src/main/java/org/apache/commons/scxml2/EvaluatorFactory.java
+++ b/src/main/java/org/apache/commons/scxml2/EvaluatorFactory.java
@@ -93,17 +93,16 @@ public class EvaluatorFactory {
     /**
      * Returns a dedicated Evaluator instance for a specific SCXML document its documentmodel.
      * <p>If no SCXML document is provided a default Evaluator will be returned.</p>
-     * @param strict flag if an evaluator with strict / specification compliant behavior
should be provided
      * @param document The document to return a dedicated Evaluator for. May be null to retrieve
the default Evaluator.
      * @return a new and not sharable Evaluator instance for the provided document, or a
default Evaluator otherwise
      * @throws ModelException If the SCXML document datamodel is not supported.
      */
-    public static Evaluator getEvaluator(final boolean strict, final SCXML document) throws
ModelException {
+    public static Evaluator getEvaluator(final SCXML document) throws ModelException {
         String datamodelName = document != null ? document.getDatamodelName() : null;
         EvaluatorProvider provider = INSTANCE.providers.get(datamodelName == null ? DEFAULT_DATA_MODEL
: datamodelName);
         if (provider == null) {
             throw new ModelException("Unsupported SCXML document datamodel \""+(datamodelName)+"\"");
         }
-        return document != null ? provider.getEvaluator(strict, document) : provider.getEvaluator(strict);
+        return document != null ? provider.getEvaluator(document) : provider.getEvaluator();
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/3c8c62b3/src/main/java/org/apache/commons/scxml2/EvaluatorProvider.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/EvaluatorProvider.java b/src/main/java/org/apache/commons/scxml2/EvaluatorProvider.java
index 157f65d..b7b7e67 100644
--- a/src/main/java/org/apache/commons/scxml2/EvaluatorProvider.java
+++ b/src/main/java/org/apache/commons/scxml2/EvaluatorProvider.java
@@ -34,13 +34,6 @@ public interface EvaluatorProvider {
     Evaluator getEvaluator();
 
     /**
-     * @param strict flag if an evaluator with strict / specification compliant behavior
should be provided
-     * @return a default or generic {@link Evaluator} supporting the {@link #getSupportedDatamodel()}
-     * with strict / specification compliant behavior, if specified
-     */
-    Evaluator getEvaluator(final boolean strict);
-
-    /**
      * Factory method to return a dedicated and optimized {@link Evaluator} instance for
a specific SCXML document.
      * <p>
      * As the returned Evaluator <em>might</em> be optimized and dedicated for
the SCXML document instance, the
@@ -50,16 +43,4 @@ public interface EvaluatorProvider {
      * @return a new and not sharable Evaluator instance
      */
     Evaluator getEvaluator(SCXML document);
-
-    /**
-     * Factory method to return a dedicated and optimized {@link Evaluator} instance for
a specific SCXML document.
-     * <p>
-     * As the returned Evaluator <em>might</em> be optimized and dedicated for
the SCXML document instance, the
-     * Evaluator may not be shareable and reusable for other SCXML documents.
-     * </p>
-     * @param strict flag if an evaluator with strict / specification compliant behavior
should be provided
-     * @param document the SCXML document
-     * @return a new and not sharable Evaluator instance
-     */
-    Evaluator getEvaluator(final boolean strict, final SCXML document);
 }

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/3c8c62b3/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 baa35e3..d29291b 100644
--- a/src/main/java/org/apache/commons/scxml2/SCInstance.java
+++ b/src/main/java/org/apache/commons/scxml2/SCInstance.java
@@ -131,11 +131,6 @@ public class SCInstance implements Serializable {
     private boolean singleContext;
 
     /**
-     * Flag indicating if strict / specification compliant behavior is required
-     */
-    private boolean strict;
-
-    /**
      * Constructor
      * @param internalIOProcessor The I/O Processor for the internal event queue
      * @param evaluator The evaluator
@@ -161,7 +156,7 @@ public class SCInstance implements Serializable {
             throw new ModelException(ERR_NO_STATE_MACHINE);
         }
         if (evaluator == null) {
-            evaluator = EvaluatorFactory.getEvaluator(isStrict(), stateMachine);
+            evaluator = EvaluatorFactory.getEvaluator(stateMachine);
         }
         if (evaluator.requiresGlobalContext()) {
             singleContext = true;
@@ -196,7 +191,7 @@ public class SCInstance implements Serializable {
                     }
                 }
             }
-            if ((stateMachine.isLateBinding() == null && isStrict()) || Boolean.FALSE.equals(stateMachine.isLateBinding()))
{
+            if (stateMachine.isLateBinding() == null || Boolean.FALSE.equals(stateMachine.isLateBinding()))
{
                 // early binding
                 for (EnterableState es : stateMachine.getChildren()) {
                     getContext(es);
@@ -302,17 +297,6 @@ public class SCInstance implements Serializable {
         return singleContext;
     }
 
-    public void setStrict(final boolean strict) throws ModelException {
-        if (initialized) {
-            throw new ModelException("SCInstance: already initialized");
-        }
-        this.strict = strict;
-    }
-
-    public boolean isStrict() {
-        return strict;
-    }
-
     /**
      * Clone data model.
      *

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/3c8c62b3/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java b/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java
index 5e6ad90..4f669dd 100644
--- a/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java
+++ b/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java
@@ -118,7 +118,6 @@ public class SCXMLExecutor implements SCXMLIOProcessor {
         this.exctx = new SCXMLExecutionContext(this, parentSCXMLExecutor.getEvaluator(),
                 parentSCXMLExecutor.getEventdispatcher().newInstance(), parentSCXMLExecutor.getErrorReporter());
         getSCInstance().setSingleContext(parentSCXMLExecutor.isSingleContext());
-        getSCInstance().setStrict(parentSCXMLExecutor.isStrict());
         getSCInstance().setStateMachine(scxml);
     }
 
@@ -251,14 +250,6 @@ public class SCXMLExecutor implements SCXMLIOProcessor {
         return getSCInstance().isSingleContext();
     }
 
-    public void setStrict(final boolean strict) throws ModelException {
-        getSCInstance().setStrict(strict);
-    }
-
-    public boolean isStrict() {
-        return getSCInstance().isStrict();
-    }
-
     /**
      * Get the state machine that is being executed.
      * <b>NOTE:</b> This is the state machine definition or model used by this

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/3c8c62b3/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 e26aaaf..23bbe9c 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
@@ -59,18 +59,9 @@ public class GroovyEvaluator extends AbstractBaseEvaluator {
         }
 
         @Override
-        public Evaluator getEvaluator(final boolean strict) {
-            return new GroovyEvaluator();
-        }
-
-        @Override
         public Evaluator getEvaluator(final SCXML document) {
             return new GroovyEvaluator();
         }
-        @Override
-        public Evaluator getEvaluator(final boolean strict, final SCXML document) {
-            return new GroovyEvaluator();
-        }
     }
 
     /** Error message if evaluation context is not a GroovyContext. */
@@ -126,11 +117,6 @@ public class GroovyEvaluator extends AbstractBaseEvaluator {
         this.scriptCache = newScriptCache();
     }
 
-    @Override
-    public boolean isStrict() {
-        return false;
-    }
-
     /**
      * Overridable factory method to create the GroovyExtendableScriptCache for this GroovyEvaluator.
      * <p>

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/3c8c62b3/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 1ec2d58..b5b32fa 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
@@ -69,18 +69,9 @@ public class JSEvaluator extends AbstractBaseEvaluator {
         }
 
         @Override
-        public Evaluator getEvaluator(final boolean strict) {
-            return new JSEvaluator();
-        }
-
-        @Override
         public Evaluator getEvaluator(final SCXML document) {
             return new JSEvaluator();
         }
-        @Override
-        public Evaluator getEvaluator(final boolean strict, final SCXML document) {
-            return new JSEvaluator();
-        }
     }
 
     private static final String SCXML_SYSTEM_CONTEXT = "_scxmlSystemContext";
@@ -180,11 +171,6 @@ public class JSEvaluator extends AbstractBaseEvaluator {
     }
 
     @Override
-    public boolean isStrict() {
-        return false;
-    }
-
-    @Override
     public String getSupportedDatamodel() {
         return SUPPORTED_DATA_MODEL;
     }

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/3c8c62b3/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 ea7f5a8..0f11d0f 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
@@ -59,19 +59,9 @@ public class JexlEvaluator extends AbstractBaseEvaluator {
         }
 
         @Override
-        public Evaluator getEvaluator(final boolean strict) {
-            return new JexlEvaluator(strict);
-        }
-
-        @Override
         public Evaluator getEvaluator(final SCXML document) {
             return new JexlEvaluator();
         }
-
-        @Override
-        public Evaluator getEvaluator(final boolean strict, final SCXML document) {
-            return new JexlEvaluator(strict);
-        }
     }
 
     /** Error message if evaluation context is not a JexlContext. */
@@ -83,35 +73,9 @@ public class JexlEvaluator extends AbstractBaseEvaluator {
     /** The internal JexlEngine instance to use. */
     private transient volatile JexlEngine jexlEngine;
 
-    /** The current JexlEngine silent mode, stored locally to be reapplied after deserialization
of the engine */
-    private final boolean jexlEngineSilent;
-    /** The current JexlEngine strict mode, stored locally to be reapplied after deserialization
of the engine */
-    private boolean jexlEngineStrict;
-
     /** Constructor. */
     public JexlEvaluator() {
-        this(false);
-    }
-
-    public JexlEvaluator(final boolean strict) {
-        jexlEngineStrict = strict;
-        // create the internal JexlEngine initially
         jexlEngine = getJexlEngine();
-        jexlEngineSilent = jexlEngine.isSilent();
-        jexlEngineStrict = jexlEngine.isStrict();
-    }
-
-    /**
-     * Checks whether the internal Jexl engine throws JexlException during evaluation.
-     * @return true if silent, false (default) otherwise
-     */
-    public boolean isJexlEngineSilent() {
-        return jexlEngineSilent;
-    }
-
-    @Override
-    public boolean isStrict() {
-        return jexlEngineStrict;
     }
 
     @Override
@@ -216,7 +180,7 @@ public class JexlEvaluator extends AbstractBaseEvaluator {
         // See javadoc of org.apache.commons.jexl2.JexlEngine#setFunctions(Map<String,Object>
funcs) for detail.
         Map<String, Object> funcs = new HashMap<>();
         funcs.put(null, JexlBuiltin.class);
-        return new JexlBuilder().namespaces(funcs).strict(jexlEngineStrict).silent(jexlEngineSilent).cache(256).create();
+        return new JexlBuilder().namespaces(funcs).cache(256).create();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/3c8c62b3/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 32a8ed7..6f0443b 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
@@ -51,24 +51,9 @@ public class MinimalEvaluator implements Evaluator, Serializable {
         }
 
         @Override
-        public Evaluator getEvaluator(final boolean strict) {
-            return new MinimalEvaluator();
-        }
-
-        @Override
         public Evaluator getEvaluator(final SCXML document) {
             return new MinimalEvaluator();
         }
-
-        @Override
-        public Evaluator getEvaluator(final boolean strict, final SCXML document) {
-            return new MinimalEvaluator();
-        }
-    }
-
-    @Override
-    public boolean isStrict() {
-        return true;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/3c8c62b3/src/test/java/org/apache/commons/scxml2/model/actions-initial-test.xml
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/scxml2/model/actions-initial-test.xml b/src/test/java/org/apache/commons/scxml2/model/actions-initial-test.xml
index 21ce85e..ff2c481 100644
--- a/src/test/java/org/apache/commons/scxml2/model/actions-initial-test.xml
+++ b/src/test/java/org/apache/commons/scxml2/model/actions-initial-test.xml
@@ -40,7 +40,7 @@
          event="croak" namelist="drink eat" hints="'h2o bzz'"
          delayexpr="1000+500" />
         <cancel sendId="send12345"/>
-        <log expr="leaving" label="entry001" />
+        <log expr="'leaving'" label="entry001" />
         <raise event="event.test"/>
       </transition>
     </initial>

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/3c8c62b3/src/test/java/org/apache/commons/scxml2/model/actions-parallel-test.xml
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/scxml2/model/actions-parallel-test.xml b/src/test/java/org/apache/commons/scxml2/model/actions-parallel-test.xml
index 51706e4..8731bc6 100644
--- a/src/test/java/org/apache/commons/scxml2/model/actions-parallel-test.xml
+++ b/src/test/java/org/apache/commons/scxml2/model/actions-parallel-test.xml
@@ -39,7 +39,7 @@
        event="croak" namelist="drink eat" hints="'h2o bzz'"
        delayexpr="1000+500" />
       <cancel sendId="send12345"/>
-      <log expr="leaving" label="entry001" />
+      <log expr="'leaving'" label="entry001" />
       <raise event="event.test"/>
     </onentry>
 

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/3c8c62b3/src/test/java/org/apache/commons/scxml2/model/actions-state-test.xml
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/scxml2/model/actions-state-test.xml b/src/test/java/org/apache/commons/scxml2/model/actions-state-test.xml
index 89bc038..2dfb2a4 100644
--- a/src/test/java/org/apache/commons/scxml2/model/actions-state-test.xml
+++ b/src/test/java/org/apache/commons/scxml2/model/actions-state-test.xml
@@ -39,7 +39,7 @@
        event="croak" namelist="drink eat" hints="'h2o bzz'"
        delayexpr="1000+500" />
       <cancel sendId="send12345"/>
-      <log expr="leaving" label="entry001" />
+      <log expr="'leaving'" label="entry001" />
       <raise event="event.test"/>
     </onentry>
 

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/3c8c62b3/src/test/java/org/apache/commons/scxml2/w3c/W3CTests.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/scxml2/w3c/W3CTests.java b/src/test/java/org/apache/commons/scxml2/w3c/W3CTests.java
index 29a1d49..71ae057 100644
--- a/src/test/java/org/apache/commons/scxml2/w3c/W3CTests.java
+++ b/src/test/java/org/apache/commons/scxml2/w3c/W3CTests.java
@@ -667,7 +667,6 @@ public class W3CTests {
             }
             final SCXMLExecutor exec = new SCXMLExecutor(null, null, trc);
             exec.setSingleContext(true);
-            exec.setStrict(true);
             exec.setStateMachine(doc);
             exec.addListener(doc, trc);
             exec.registerInvokerClass("scxml", SimpleSCXMLInvoker.class);


Mime
View raw message