commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1649098 [1/2] - in /commons/proper/scxml/trunk/src: main/java/org/apache/commons/scxml2/ main/java/org/apache/commons/scxml2/env/ main/java/org/apache/commons/scxml2/env/xpath/ main/java/org/apache/commons/scxml2/invoke/ main/java/org/apac...
Date Fri, 02 Jan 2015 19:34:31 GMT
Author: ate
Date: Fri Jan  2 19:34:30 2015
New Revision: 1649098

URL: http://svn.apache.org/r1649098
Log:
SCXML-224: Improve SCXML state configuration handling and optional validation

Added:
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/StateConfiguration.java   (with props)
Removed:
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/BuiltinTest.java
Modified:
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Builtin.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCInstance.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutionContext.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLSemantics.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLSystemContext.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Status.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/AbstractStateMachine.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/SimpleContext.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/xpath/XPathFunctions.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/invoke/SimpleSCXMLInvoker.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/semantics/SCXMLSemanticsImpl.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/test/StandaloneUtils.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/EventDataTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/NamespacePrefixedXPathsTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLExecutorTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLTestHelper.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/StatusTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/TieBreakerTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/WildcardTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/WizardsTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/StopWatch.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/GroovyEvaluatorTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/SerializableInitialBaseScriptTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/StaticMethodTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/JSExampleTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/ForeachTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/StaticMethodTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/xpath/XPathExampleTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/InvokeTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/SCXMLRequiredAttributesTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/StateSrcTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/issues/Issue112Test.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/issues/Issue62Test.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/AssignTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/CustomActionTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/DatamodelTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/HistoryTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/ScriptTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/ScxmlInitialAttributeTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/StateTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/StatelessModelTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/semantics/SCXMLSemanticsImplTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/w3c/W3CTests.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/w3c/tests.xml

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Builtin.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Builtin.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Builtin.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Builtin.java Fri Jan  2 19:34:30 2015
@@ -17,9 +17,6 @@
 package org.apache.commons.scxml2;
 
 import java.io.Serializable;
-import java.util.Set;
-
-import org.apache.commons.scxml2.model.TransitionTarget;
 
 /**
  * Implementation of the SCXML specification required In() builtin predicate.
@@ -44,30 +41,7 @@ public class Builtin implements Serializ
      */
     @SuppressWarnings("unchecked")
     public static boolean isMember(final Context ctx, final String state) {
-        return isMember((Set<? extends TransitionTarget>)ctx.getSystemContext().get(SCXMLSystemContext.ALL_STATES_KEY), state);
-    }
-
-    /**
-     * Implements the In() predicate for SCXML documents. The method
-     * name chosen is different since &quot;in&quot; is a reserved token
-     * in some expression languages.
-     *
-     * Does this state belong to the given Set of States.
-     * Simple ID based comparator, assumes IDs are unique.
-     *
-     * @param allStates The Set of State objects to look in
-     * @param state The State ID to compare with
-     * @return Whether this State belongs to this Set
-     */
-    public static boolean isMember(final Set<? extends TransitionTarget> allStates, final String state) {
-        if (allStates != null) {
-            for (TransitionTarget tt : allStates) {
-                if (state.equals(tt.getId())) {
-                    return true;
-                }
-            }
-        }
-        return false;
+        return ((Status)ctx.getSystemContext().getPlatformVariables().get(SCXMLSystemContext.STATUS_KEY)).isInState(state);
     }
 }
 

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCInstance.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCInstance.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCInstance.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCInstance.java Fri Jan  2 19:34:30 2015
@@ -74,6 +74,11 @@ public class SCInstance implements Seria
     private SCXML stateMachine;
 
     /**
+     * The current state configuration of the state machine
+     */
+    private final StateConfiguration stateConfiguration;
+
+    /**
      * The current status of the stateMachine.
      */
     private final Status currentStatus;
@@ -134,7 +139,8 @@ public class SCInstance implements Seria
         this.internalIOProcessor = internalIOProcessor;
         this.evaluator = evaluator;
         this.errorReporter = errorReporter;
-        this.currentStatus = new Status();
+        this.stateConfiguration = new StateConfiguration();
+        this.currentStatus = new Status(stateConfiguration);
     }
 
     /**
@@ -161,7 +167,7 @@ public class SCInstance implements Seria
         globalContext = null;
         contexts.clear();
         histories.clear();
-        currentStatus.clear();
+        stateConfiguration.clear();
 
         // Clone root datamodel
         Datamodel rootdm = stateMachine.getDatamodel();
@@ -328,13 +334,19 @@ public class SCInstance implements Seria
     }
 
     /**
-     * @return Returns the current status (active atomic states) for this instance
+     * @return Returns the state configuration for this instance
+     */
+    public StateConfiguration getStateConfiguration() {
+        return stateConfiguration;
+    }
+
+    /**
+     * @return Returns the current status for this instance
      */
     public Status getCurrentStatus() {
         return currentStatus;
     }
 
-
     /**
      * @return Returns if the state machine is running
      */
@@ -397,6 +409,7 @@ public class SCInstance implements Seria
                 systemContext.getContext().set(SCXMLSystemContext.SESSIONID_KEY, UUID.randomUUID().toString());
                 String _name = stateMachine != null && stateMachine.getName() != null ? stateMachine.getName() : "";
                 systemContext.getContext().set(SCXMLSystemContext.SCXML_NAME_KEY, _name);
+                systemContext.getPlatformVariables().put(SCXMLSystemContext.STATUS_KEY, currentStatus);
             }
         }
         return systemContext != null ? systemContext.getContext() : null;

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutionContext.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutionContext.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutionContext.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutionContext.java Fri Jan  2 19:34:30 2015
@@ -105,6 +105,11 @@ public class SCXMLExecutionContext imple
     private final Map<String, SCXMLIOProcessor> ioProcessors = new HashMap<String, SCXMLIOProcessor>();
 
     /**
+     * Flag indicating if the SCXML configuration should be checked before execution (default = true)
+     */
+    private boolean checkLegalConfiguration = true;
+
+    /**
      * Constructor
      *
      * @param externalIOProcessor The external IO Processor
@@ -159,6 +164,21 @@ public class SCXMLExecutionContext imple
     }
 
     /**
+     * Set if the SCXML configuration should be checked before execution (default = true)
+     * @param checkLegalConfiguration flag to set
+     */
+    public void setCheckLegalConfiguration(boolean checkLegalConfiguration) {
+        this.checkLegalConfiguration = checkLegalConfiguration;
+    }
+
+    /**
+     * @return if the SCXML configuration will be checked before execution
+     */
+    public boolean isCheckLegalConfiguration() {
+        return checkLegalConfiguration;
+    }
+
+    /**
      * Initialize method which will cancel all current active Invokers, clear the internal event queue and mark the
      * state machine process as running (again).
      *

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java Fri Jan  2 19:34:30 2015
@@ -16,7 +16,9 @@
  */
 package org.apache.commons.scxml2;
 
+import java.util.HashSet;
 import java.util.Queue;
+import java.util.Set;
 import java.util.concurrent.ConcurrentLinkedQueue;
 
 import org.apache.commons.logging.Log;
@@ -26,6 +28,7 @@ import org.apache.commons.scxml2.model.E
 import org.apache.commons.scxml2.model.ModelException;
 import org.apache.commons.scxml2.model.Observable;
 import org.apache.commons.scxml2.model.SCXML;
+import org.apache.commons.scxml2.model.TransitionTarget;
 import org.apache.commons.scxml2.semantics.SCXMLSemanticsImpl;
 
 /**
@@ -102,11 +105,49 @@ public class SCXMLExecutor implements SC
      *
      * @return The current Status
      */
-    public synchronized Status getCurrentStatus() {
+    public synchronized Status getStatus() {
         return exctx.getScInstance().getCurrentStatus();
     }
 
     /**
+     * Initializes the state machine with a specific active configuration
+     * <p>
+     * This will first (re)initialize the current state machine: clearing all variable contexts, histories and current
+     * status, and clones the SCXML root datamodel into the root context.
+     * </p>
+     * @param atomicStateIds The set of atomic state ids for the state machine
+     * @throws ModelException when the state machine hasn't been properly configured yet, when an unknown or illegal
+     * stateId is specified, or when the specified active configuration does not represent a legal configuration.
+     * @see {@link SCInstance#initialize()}
+     * @see {@link SCXMLSemantics#isLegalConfiguration(java.util.Set, ErrorReporter)}
+     */
+    public synchronized void setConfiguration(Set<String> atomicStateIds) throws ModelException {
+        exctx.initialize();
+        Set<EnterableState> states = new HashSet<EnterableState>();
+        for (String stateId : atomicStateIds) {
+            TransitionTarget tt = getStateMachine().getTargets().get(stateId);
+            if (tt instanceof EnterableState && ((EnterableState)tt).isAtomicState()) {
+                EnterableState es = (EnterableState)tt;
+                while (es != null && !states.add(es)) {
+                    es = es.getParent();
+                }
+            }
+            else {
+                throw new ModelException("Illegal atomic stateId "+stateId+": state unknown or not an atomic state");
+            }
+        }
+        if (semantics.isLegalConfiguration(states, getErrorReporter())) {
+            for (EnterableState es : states) {
+                exctx.getScInstance().getStateConfiguration().enterState(es);
+            }
+            logState();
+        }
+        else {
+            throw new ModelException("Illegal state machine configuration!");
+        }
+    }
+
+    /**
      * Set or replace the expression evaluator
      * <p>
      * If the state machine instance has been initialized before, it will be initialized again, destroying all existing
@@ -220,6 +261,21 @@ public class SCXMLExecutor implements SC
     }
 
     /**
+     * Set if the SCXML configuration should be checked before execution (default = true)
+     * @param checkLegalConfiguration flag to set
+     */
+    public void setCheckLegalConfiguration(boolean checkLegalConfiguration) {
+        this.exctx.setCheckLegalConfiguration(checkLegalConfiguration);
+    }
+
+    /**
+     * @return if the SCXML configuration will be checked before execution
+     */
+    public boolean isCheckLegalConfiguration() {
+        return exctx.isCheckLegalConfiguration();
+    }
+
+    /**
      * Get the notification registry.
      *
      * @return The notification registry.
@@ -420,7 +476,7 @@ public class SCXMLExecutor implements SC
     protected void logState() {
         if (log.isDebugEnabled()) {
             StringBuilder sb = new StringBuilder("Current States: [ ");
-            for (EnterableState es : getCurrentStatus().getStates()) {
+            for (EnterableState es : getStatus().getStates()) {
                 sb.append(es.getId()).append(", ");
             }
             int length = sb.length();

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLSemantics.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLSemantics.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLSemantics.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLSemantics.java Fri Jan  2 19:34:30 2015
@@ -16,6 +16,9 @@
  */
 package org.apache.commons.scxml2;
 
+import java.util.Set;
+
+import org.apache.commons.scxml2.model.EnterableState;
 import org.apache.commons.scxml2.model.ModelException;
 import org.apache.commons.scxml2.model.SCXML;
 
@@ -150,4 +153,23 @@ public interface SCXMLSemantics {
      * @throws ModelException if a SCXML model error occurred during the execution.
      */
     void finalStep(final SCXMLExecutionContext exctx) throws ModelException;
+
+    /**
+     * Checks whether a given set of states is a legal Harel State Table
+     * configuration (with the respect to the definition of the OR and AND
+     * states).
+     * <p>
+     * When {@link SCXMLExecutionContext#isCheckLegalConfiguration()} is true (default) the SCXMLSemantics implementation
+     * <em>should</em> invoke this method before executing a step, and throw a ModelException if a non-legal
+     * configuration is encountered.
+     * </p>
+     * <p>
+     * This method is also first invoked when manually initializing the status of a state machine through
+     * {@link SCXMLExecutor#setConfiguration(java.util.Set}.
+     * </p>
+     * @param states a set of states
+     * @param errRep ErrorReporter to report detailed error info if needed
+     * @return true if a given state configuration is legal, false otherwise
+     */
+    public boolean isLegalConfiguration(final Set<EnterableState> states, final ErrorReporter errRep);
 }

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLSystemContext.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLSystemContext.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLSystemContext.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLSystemContext.java Fri Jan  2 19:34:30 2015
@@ -19,6 +19,7 @@ package org.apache.commons.scxml2;
 import java.io.Serializable;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
@@ -46,17 +47,15 @@ public class SCXMLSystemContext implemen
     public static final String IOPROCESSORS_KEY = "_ioprocessors";
     public static final String X_KEY = "_x";
 
-    /**
-     * Commons SCXML internal system variable holding the current SCXML configuration of all (including ancestors)
-     * active states.
-     */
-    public static final String ALL_STATES_KEY = "_ALL_STATES";
+    /** The Commons SCXML internal {@link #getPlatformVariables() platform variable key} holding the current SCXML
+     * status instance **/
+    public static final String STATUS_KEY = "status";
 
     /**
      * The set of protected system variables names
      */
     private static final Set<String> PROTECTED_NAMES = new HashSet<String>(Arrays.asList(
-            new String[] {EVENT_KEY, SESSIONID_KEY, SCXML_NAME_KEY, IOPROCESSORS_KEY, X_KEY, ALL_STATES_KEY}
+            new String[] {EVENT_KEY, SESSIONID_KEY, SCXML_NAME_KEY, IOPROCESSORS_KEY, X_KEY}
     ));
 
     /**
@@ -74,12 +73,17 @@ public class SCXMLSystemContext implemen
     /**
      * Initialize or replace systemContext
      * @param systemContext the system context to set
+     * @throws java.lang.NullPointerException if systemContext == null
      */
     void setSystemContext(Context systemContext) {
         if (this.systemContext != null) {
             // replace systemContext
             systemContext.getVars().putAll(this.systemContext.getVars());
         }
+        else {
+            // create Platform variables map
+            systemContext.setLocal(X_KEY, new HashMap<String, Object>());
+        }
         this.systemContext = systemContext;
         this.protectedVars = Collections.unmodifiableMap(systemContext.getVars());
     }
@@ -147,6 +151,14 @@ public class SCXMLSystemContext implemen
     }
 
     /**
+     * @return The Platform specific system variables map stored under the {@link #X_KEY _x} root system variable
+     */
+    @SuppressWarnings("unchecked")
+    public Map<String, Object> getPlatformVariables() {
+        return (Map<String, Object>)get(X_KEY);
+    }
+
+    /**
      * @return Returns the wrapped (modifiable) system context
      */
     Context getContext() {

Added: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/StateConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/StateConfiguration.java?rev=1649098&view=auto
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/StateConfiguration.java (added)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/StateConfiguration.java Fri Jan  2 19:34:30 2015
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.scxml2;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.scxml2.model.EnterableState;
+
+/**
+ * The current active states of a state machine
+ */
+public class StateConfiguration implements Serializable {
+    /**
+     * Serial version UID.
+     */
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * The states that are currently active.
+     */
+    private final Set<EnterableState> activeStates = new HashSet<EnterableState>();
+    private final Set<EnterableState> activeStatesSet = Collections.unmodifiableSet(activeStates);
+
+    /**
+     * The atomic states that are currently active.
+     */
+    private final Set<EnterableState> atomicStates = new HashSet<EnterableState>();
+    private final Set<EnterableState> atomicStatesSet = Collections.unmodifiableSet(atomicStates);
+
+    /**
+     * Get the active states
+     *
+     * @return active states including simple states and their
+     *         complex ancestors up to the root.
+     */
+    public Set<EnterableState> getActiveStates() {
+        return  activeStatesSet;
+    }
+
+    /**
+     * Get the current atomic states (leaf only).
+     *
+     * @return Returns the atomic states - simple (leaf) states only.
+     */
+    public Set<EnterableState> getStates() {
+        return  atomicStatesSet;
+    }
+
+    /**
+     * Enter an active state
+     * If the state is atomic also record it add it to the current states
+     * @param state state to enter
+     */
+    public void enterState(final EnterableState state) {
+        if (!activeStates.add(state)) {
+            throw new IllegalStateException("State "+state.getId()+" already added.");
+        }
+        if (state.isAtomicState()) {
+            if (!atomicStates.add(state)) {
+                throw new IllegalStateException("Atomic state "+state.getId()+" already added.");
+            }
+        }
+    }
+
+    /**
+     * Exit an active state
+     * If the state is atomic also remove it from current states
+     * @param state state to exit
+     */
+    public void exitState(final EnterableState state) {
+        if (!activeStates.remove(state)) {
+            throw new IllegalStateException("State "+state.getId()+" not active.");
+        }
+        atomicStates.remove(state);
+    }
+
+    /**
+     * Clear the state configuration
+     */
+    public void clear() {
+        activeStates.clear();
+        atomicStates.clear();
+    }
+}

Propchange: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/StateConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/StateConfiguration.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Status.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Status.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Status.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Status.java Fri Jan  2 19:34:30 2015
@@ -17,14 +17,13 @@
 package org.apache.commons.scxml2;
 
 import java.io.Serializable;
-import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.commons.scxml2.model.EnterableState;
 import org.apache.commons.scxml2.model.Final;
 
 /**
- * The encapsulation of the current state of a state machine.
+ * The immutable encapsulation of the current state of a state machine.
  *
  */
 public class Status implements Serializable {
@@ -34,10 +33,12 @@ public class Status implements Serializa
      */
     private static final long serialVersionUID = 1L;
 
-    /**
-     * The states that are currently active.
-     */
-    private final Set<EnterableState> states = new HashSet<EnterableState>();
+    private final StateConfiguration configuration;
+
+
+    public Status(StateConfiguration configuration) {
+        this.configuration = configuration;
+    }
 
     /**
      * @return Whether the state machine terminated AND we reached a top level Final state.
@@ -50,8 +51,8 @@ public class Status implements Serializa
      * @return Returns the single top level final state in which the state machine terminated, or null otherwise
      */
     public Final getFinalState() {
-        if (states.size() == 1) {
-            EnterableState es = states.iterator().next();
+        if (configuration.getStates().size() == 1) {
+            EnterableState es = configuration.getStates().iterator().next();
             if (es instanceof Final && es.getParent() == null) {
                 return (Final)es;
             }
@@ -60,36 +61,31 @@ public class Status implements Serializa
     }
 
     /**
-     * Get the states configuration (leaf only).
+     * Get the atomic states configuration (leaf only).
      *
-     * @return Returns the states configuration - simple (leaf) states only.
+     * @return Returns the atomic states configuration - simple (leaf) states only.
      */
     public Set<EnterableState> getStates() {
-        return states;
+        return configuration.getStates();
     }
 
     /**
-     * Get the complete states configuration.
+     * Get the active states configuration.
      *
-     * @return complete states configuration including simple states and their
+     * @return active states configuration including simple states and their
      *         complex ancestors up to the root.
      */
-    public Set<EnterableState> getAllStates() {
-        Set<EnterableState> allStates = new HashSet<EnterableState>(states.size() * 2);
-        for (EnterableState es : states) {
-            EnterableState state = es;
-            while (state != null && allStates.add(state)) {
-                state = state.getParent();
-            }
-        }
-        return allStates;
+    public Set<EnterableState> getActiveStates() {
+        return configuration.getActiveStates();
     }
 
-    /**
-     * Clears the status
-     */
-    public void clear() {
-        states.clear();
+    public boolean isInState(final String state) {
+        for (EnterableState es : configuration.getActiveStates()) {
+            if (state.equals(es.getId())) {
+                return true;
+            }
+        }
+        return false;
     }
 }
 

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/AbstractStateMachine.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/AbstractStateMachine.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/AbstractStateMachine.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/AbstractStateMachine.java Fri Jan  2 19:34:30 2015
@@ -201,7 +201,7 @@ public abstract class AbstractStateMachi
         } catch (ModelException me) {
             logError(me);
         }
-        return engine.getCurrentStatus().isFinal();
+        return engine.getStatus().isFinal();
     }
 
     /**

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/SimpleContext.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/SimpleContext.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/SimpleContext.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/SimpleContext.java Fri Jan  2 19:34:30 2015
@@ -175,7 +175,7 @@ public class SimpleContext implements Co
      */
     public void setLocal(final String name, final Object value) {
         getVars().put(name, value);
-        if (log.isDebugEnabled() && !name.equals(SCXMLSystemContext.ALL_STATES_KEY)) {
+        if (log.isDebugEnabled()) {
             log.debug(name + " = " + String.valueOf(value));
         }
     }

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/xpath/XPathFunctions.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/xpath/XPathFunctions.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/xpath/XPathFunctions.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/xpath/XPathFunctions.java Fri Jan  2 19:34:30 2015
@@ -16,13 +16,12 @@
  */
 package org.apache.commons.scxml2.env.xpath;
 
-import java.util.Set;
+import java.util.Map;
 
 import org.apache.commons.jxpath.ExpressionContext;
 import org.apache.commons.jxpath.Variables;
-import org.apache.commons.scxml2.Builtin;
 import org.apache.commons.scxml2.SCXMLSystemContext;
-import org.apache.commons.scxml2.model.EnterableState;
+import org.apache.commons.scxml2.Status;
 
 /**
  * Commons JXPath custom extension function providing the SCXML In() predicate
@@ -38,6 +37,7 @@ public class XPathFunctions {
     @SuppressWarnings("unchecked")
     public static boolean In(ExpressionContext expressionContext, String state) {
         Variables variables = expressionContext.getJXPathContext().getVariables();
-        return Builtin.isMember((Set<EnterableState>) variables.getVariable(SCXMLSystemContext.ALL_STATES_KEY), state);
+        Map<String,Object> platformVariables = (Map<String, Object>)variables.getVariable(SCXMLSystemContext.X_KEY);
+        return ((Status)platformVariables.get(SCXMLSystemContext.STATUS_KEY)).isInState(state);
     }
 }

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/invoke/SimpleSCXMLInvoker.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/invoke/SimpleSCXMLInvoker.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/invoke/SimpleSCXMLInvoker.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/invoke/SimpleSCXMLInvoker.java Fri Jan  2 19:34:30 2015
@@ -118,7 +118,7 @@ public class SimpleSCXMLInvoker implemen
         } catch (ModelException me) {
             throw new InvokerException(me.getMessage(), me.getCause());
         }
-        if (executor.getCurrentStatus().isFinal()) {
+        if (executor.getStatus().isFinal()) {
             TriggerEvent te = new TriggerEvent("done.invoke."+parentStateId, TriggerEvent.SIGNAL_EVENT);
             new AsyncTrigger(parentIOProcessor, te).start();
         }
@@ -132,9 +132,9 @@ public class SimpleSCXMLInvoker implemen
         if (cancelled) {
             return; // no further processing should take place
         }
-        boolean doneBefore = executor.getCurrentStatus().isFinal();
+        boolean doneBefore = executor.getStatus().isFinal();
         executor.addEvent(evt);
-        if (!doneBefore && executor.getCurrentStatus().isFinal()) {
+        if (!doneBefore && executor.getStatus().isFinal()) {
             TriggerEvent te = new TriggerEvent("done.invoke."+parentStateId,TriggerEvent.SIGNAL_EVENT);
             new AsyncTrigger(parentIOProcessor, te).start();
         }

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/semantics/SCXMLSemanticsImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/semantics/SCXMLSemanticsImpl.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/semantics/SCXMLSemanticsImpl.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/semantics/SCXMLSemanticsImpl.java Fri Jan  2 19:34:30 2015
@@ -33,7 +33,7 @@ import org.apache.commons.scxml2.SCXMLEx
 import org.apache.commons.scxml2.SCXMLExpressionException;
 import org.apache.commons.scxml2.SCXMLSemantics;
 import org.apache.commons.scxml2.SCXMLSystemContext;
-import org.apache.commons.scxml2.Status;
+import org.apache.commons.scxml2.StateConfiguration;
 import org.apache.commons.scxml2.TriggerEvent;
 import org.apache.commons.scxml2.invoke.Invoker;
 import org.apache.commons.scxml2.invoke.InvokerException;
@@ -118,8 +118,6 @@ public class SCXMLSemanticsImpl implemen
         Step step = new Step(null);
         step.getTransitList().add(exctx.getStateMachine().getInitialTransition());
         microStep(exctx, step, statesToInvoke);
-        // AssignCurrentStatus
-        setSystemAllStatesVariable(exctx.getScInstance());
         // Execute Immediate Transitions
 
         if (exctx.isRunning()) {
@@ -172,7 +170,6 @@ public class SCXMLSemanticsImpl implemen
             if (!step.getTransitList().isEmpty()) {
                 HashSet<TransitionalState> statesToInvoke = new HashSet<TransitionalState>();
                 microStep(exctx, step, statesToInvoke);
-                setSystemAllStatesVariable(exctx.getScInstance());
                 if (exctx.isRunning()) {
                     macroStep(exctx, statesToInvoke);
                 }
@@ -206,8 +203,8 @@ public class SCXMLSemanticsImpl implemen
         if (exctx.isRunning()) {
             return;
         }
-        ArrayList<EnterableState> configuration = new ArrayList<EnterableState>(exctx.getScInstance().getCurrentStatus().getAllStates());
-        Collections.sort(configuration,DocumentOrder.reverseDocumentOrderComparator);
+        ArrayList<EnterableState> configuration = new ArrayList<EnterableState>(exctx.getScInstance().getStateConfiguration().getActiveStates());
+        Collections.sort(configuration, DocumentOrder.reverseDocumentOrderComparator);
         for (EnterableState es : configuration) {
             for (OnExit onexit : es.getOnExits()) {
                 executeContent(exctx, onexit);
@@ -221,7 +218,7 @@ public class SCXMLSemanticsImpl implemen
             exctx.getNotificationRegistry().fireOnExit(es, es);
             exctx.getNotificationRegistry().fireOnExit(exctx.getStateMachine(), es);
             if (!(es instanceof Final && es.getParent() == null)) {
-                exctx.getScInstance().getCurrentStatus().getStates().remove(es);
+                exctx.getScInstance().getStateConfiguration().exitState(es);
             }
             // else: keep final Final
             // TODO: returnDoneEvent(s.donedata)?
@@ -260,8 +257,8 @@ public class SCXMLSemanticsImpl implemen
         step.clearIntermediateState();
 
         // compute exitSet, if there is something to exit and record their History configurations if applicable
-        if (!exctx.getScInstance().getCurrentStatus().getStates().isEmpty()) {
-            computeExitSet(step, exctx.getScInstance().getCurrentStatus());
+        if (!exctx.getScInstance().getStateConfiguration().getActiveStates().isEmpty()) {
+            computeExitSet(step, exctx.getScInstance().getStateConfiguration());
         }
         // compute entrySet
         computeEntrySet(exctx, step);
@@ -270,12 +267,12 @@ public class SCXMLSemanticsImpl implemen
         Set<EnterableState> states = step.getEntrySet();
         if (!step.getExitSet().isEmpty()) {
             // calculate result states by taking current states, subtracting exitSet and adding entrySet
-            states = new HashSet<EnterableState>(exctx.getScInstance().getCurrentStatus().getStates());
+            states = new HashSet<EnterableState>(exctx.getScInstance().getStateConfiguration().getStates());
             states.removeAll(step.getExitSet());
             states.addAll(step.getEntrySet());
         }
         // validate the result states represent a legal configuration
-        if (!isLegalConfig(states, exctx.getErrorReporter())) {
+        if (exctx.isCheckLegalConfiguration() && !isLegalConfiguration(states, exctx.getErrorReporter())) {
             throw new ModelException("Illegal state machine configuration!");
         }
     }
@@ -317,7 +314,6 @@ public class SCXMLSemanticsImpl implemen
                 }
                 else {
                     microStep(exctx, step, statesToInvoke);
-                    setSystemAllStatesVariable(exctx.getScInstance());
                 }
 
             } while (exctx.isRunning() && !macroStepDone);
@@ -335,15 +331,14 @@ public class SCXMLSemanticsImpl implemen
      * This method corresponds to the Algorithm for SCXML processing computeExitSet() procedure.
      * <p>
      * @param step The step containing the list of transitions to be taken
-     * @param currentStatus The current status of the state machine ({@link SCInstance#getCurrentStatus()}).
+     * @param stateConfiguration The current configuration of the state machine ({@link SCInstance#getStateConfiguration()}).
      */
-    public void computeExitSet(final Step step, final Status currentStatus) {
-        if (!currentStatus.getStates().isEmpty()) {
-            Set<EnterableState> configuration = currentStatus.getAllStates();
+    public void computeExitSet(final Step step, final StateConfiguration stateConfiguration) {
+        if (!stateConfiguration.getActiveStates().isEmpty()) {
             for (SimpleTransition st : step.getTransitList()) {
-                computeExitSet(st, step.getExitSet(), configuration);
+                computeExitSet(st, step.getExitSet(), stateConfiguration.getActiveStates());
             }
-            recordHistory(step, currentStatus.getStates(), configuration);
+            recordHistory(step, stateConfiguration.getStates(), stateConfiguration.getActiveStates());
         }
     }
 
@@ -354,17 +349,17 @@ public class SCXMLSemanticsImpl implemen
      * <p>
      * @param transition The transition to compute the states to exit from
      * @param exitSet The set for adding the states to exit to
-     * @param configuration The current configuration of the state machine ({@link Status#getAllStates()}).
+     * @param activeStates The current active states of the state machine ({@link StateConfiguration#getActiveStates()}).
      */
-    public void computeExitSet(SimpleTransition transition, Set<EnterableState> exitSet, Set<EnterableState> configuration) {
+    public void computeExitSet(SimpleTransition transition, Set<EnterableState> exitSet, Set<EnterableState> activeStates) {
         if (!transition.getTargets().isEmpty()) {
             TransitionalState transitionDomain = transition.getTransitionDomain();
             if (transitionDomain == null) {
                 // root transition: every active state will be exited
-                exitSet.addAll(configuration);
+                exitSet.addAll(activeStates);
             }
             else {
-                for (EnterableState state : configuration) {
+                for (EnterableState state : activeStates) {
                     if (state.isDescendantOf(transitionDomain)) {
                         exitSet.add(state);
                     }
@@ -380,15 +375,15 @@ public class SCXMLSemanticsImpl implemen
      * {@link #computeEntrySet(SCXMLExecutionContext, Step)}.
      * </p>
      * <p>
-     * Only after the new configuration has been validated (see: {@link #isLegalConfig(Set, ErrorReporter)}), the
+     * Only after the new configuration has been validated (see: {@link #isLegalConfiguration(Set, ErrorReporter)}), the
      * history configurations will be persisted during the actual {@link #exitStates(SCXMLExecutionContext, Step, Set)}
      * processing.
      * </p>
      * @param step The step containing the list of states to exit, and the map to record the new history configurations
-     * @param states The current set of active atomic states in the state machine
-     * @param allStates The current set of all active states in the state machine
+     * @param atomicStates The current set of active atomic states in the state machine
+     * @param activeStates The current set of all active states in the state machine
      */
-    public void recordHistory(final Step step, final Set<EnterableState> states, final Set<EnterableState> allStates) {
+    public void recordHistory(final Step step, final Set<EnterableState> atomicStates, final Set<EnterableState> activeStates) {
         for (EnterableState es : step.getExitSet()) {
             if (es instanceof TransitionalState && ((TransitionalState)es).hasHistory()) {
                 TransitionalState ts = (TransitionalState)es;
@@ -399,7 +394,7 @@ public class SCXMLSemanticsImpl implemen
                         if (deep == null) {
                             //calculate deep history for a given state once
                             deep = new HashSet<EnterableState>();
-                            for (EnterableState ott : states) {
+                            for (EnterableState ott : atomicStates) {
                                 if (ott.isDescendantOf(es)) {
                                     deep.add(ott);
                                 }
@@ -410,7 +405,7 @@ public class SCXMLSemanticsImpl implemen
                         if (shallow == null) {
                             //calculate shallow history for a given state once
                             shallow = new HashSet<EnterableState>(ts.getChildren());
-                            shallow.retainAll(allStates);
+                            shallow.retainAll(activeStates);
                         }
                         step.getNewHistoryConfigurations().put(h, shallow);
                     }
@@ -562,7 +557,7 @@ public class SCXMLSemanticsImpl implemen
         step.getTransitList().clear();
         ArrayList<Transition> enabledTransitions = new ArrayList<Transition>();
 
-        ArrayList<EnterableState> configuration = new ArrayList<EnterableState>(exctx.getScInstance().getCurrentStatus().getAllStates());
+        ArrayList<EnterableState> configuration = new ArrayList<EnterableState>(exctx.getScInstance().getStateConfiguration().getActiveStates());
         Collections.sort(configuration,DocumentOrder.documentOrderComparator);
 
         HashSet<EnterableState> visited = new HashSet<EnterableState>();
@@ -612,7 +607,7 @@ public class SCXMLSemanticsImpl implemen
         LinkedHashSet<Transition> preemptedTransitions = new LinkedHashSet<Transition>();
         Map<Transition, Set<EnterableState>> exitSets = new HashMap<Transition, Set<EnterableState>>();
 
-        Set<EnterableState> configuration = exctx.getScInstance().getCurrentStatus().getAllStates();
+        Set<EnterableState> configuration = exctx.getScInstance().getStateConfiguration().getActiveStates();
         Collections.sort(enabledTransitions, DocumentOrder.documentOrderComparator);
 
         for (Transition t1 : enabledTransitions) {
@@ -777,7 +772,7 @@ public class SCXMLSemanticsImpl implemen
      * @param errRep ErrorReporter to report detailed error info if needed
      * @return true if a given state configuration is legal, false otherwise
      */
-    public boolean isLegalConfig(final Set<EnterableState> states, final ErrorReporter errRep) {
+    public boolean isLegalConfiguration(final Set<EnterableState> states, final ErrorReporter errRep) {
         /*
          * For every active state we add 1 to the count of its parent. Each
          * Parallel should reach count equal to the number of its children and
@@ -805,24 +800,27 @@ public class SCXMLSemanticsImpl implemen
         }
         if (scxmlCount.size() > 1) {
             errRep.onError(ErrorConstants.ILLEGAL_CONFIG, "Multiple top-level OR states active!", scxmlCount);
+            legalConfig = false;
         }
-        //Validate child counts:
-        for (Map.Entry<EnterableState, Set<EnterableState>> entry : counts.entrySet()) {
-            EnterableState es = entry.getKey();
-            Set<EnterableState> count = entry.getValue();
-            if (es instanceof Parallel) {
-                Parallel p = (Parallel) es;
-                if (count.size() < p.getChildren().size()) {
-                    errRep.onError(ErrorConstants.ILLEGAL_CONFIG, "Not all AND states active for parallel " + p.getId(), entry);
-                    legalConfig = false;
-                }
-            } else {
-                if (count.size() > 1) {
-                    errRep.onError(ErrorConstants.ILLEGAL_CONFIG, "Multiple OR states active for state " + es.getId(), entry);
-                    legalConfig = false;
+        else {
+            //Validate child counts:
+            for (Map.Entry<EnterableState, Set<EnterableState>> entry : counts.entrySet()) {
+                EnterableState es = entry.getKey();
+                Set<EnterableState> count = entry.getValue();
+                if (es instanceof Parallel) {
+                    Parallel p = (Parallel) es;
+                    if (count.size() < p.getChildren().size()) {
+                        errRep.onError(ErrorConstants.ILLEGAL_CONFIG, "Not all AND states active for parallel " + p.getId(), entry);
+                        legalConfig = false;
+                    }
+                } else {
+                    if (count.size() > 1) {
+                        errRep.onError(ErrorConstants.ILLEGAL_CONFIG, "Multiple OR states active for state " + es.getId(), entry);
+                        legalConfig = false;
+                    }
                 }
+                count.clear(); //cleanup
             }
-            count.clear(); //cleanup
         }
         //cleanup
         scxmlCount.clear();
@@ -831,15 +829,6 @@ public class SCXMLSemanticsImpl implemen
     }
 
     /**
-     * Stores the current state machine configuration ({@link Status#getAllStates()}) in the system context.
-     * @param scInstance the state machine instance holding the current configuration
-     */
-    public void setSystemAllStatesVariable(final SCInstance scInstance) {
-        Status currentStatus = scInstance.getCurrentStatus();
-        scInstance.getSystemContext().setLocal(SCXMLSystemContext.ALL_STATES_KEY, currentStatus.getAllStates());
-    }
-
-    /**
      * Stores the provided event in the system context
      * <p>
      * For the event a EventVariable is instantiated and the provided event its type is mapped to the one of the
@@ -929,9 +918,8 @@ public class SCXMLSemanticsImpl implemen
                     exctx.cancelInvoker(inv);
                 }
             }
-
+            exctx.getScInstance().getStateConfiguration().exitState(es);
         }
-        exctx.getScInstance().getCurrentStatus().getStates().removeAll(exitList);
     }
 
     /**
@@ -1007,14 +995,10 @@ public class SCXMLSemanticsImpl implemen
         if (step.getEntrySet().isEmpty()) {
             return;
         }
-        Set<EnterableState> configuration = null;
         ArrayList<EnterableState> entryList = new ArrayList<EnterableState>(step.getEntrySet());
         Collections.sort(entryList, DocumentOrder.documentOrderComparator);
         for (EnterableState es : entryList) {
-            if (es.isAtomicState()) {
-                // only track atomic active states in Status
-                exctx.getScInstance().getCurrentStatus().getStates().add(es);
-            }
+            exctx.getScInstance().getStateConfiguration().enterState(es);
             if (es instanceof TransitionalState && !((TransitionalState)es).getInvokes().isEmpty()) {
                 statesToInvoke.add((TransitionalState) es);
             }
@@ -1048,14 +1032,7 @@ public class SCXMLSemanticsImpl implemen
                 else {
                     exctx.getInternalIOProcessor().addEvent(new TriggerEvent("done.state."+parent.getId(),TriggerEvent.CHANGE_EVENT));
                     if (parent.isRegion()) {
-                        if (configuration == null) {
-                            // Note: configuration may 'grow' during enterStates, but activation works downwards
-                            //       so it doesn't matter for determining if the parallel children are already
-                            //       all in final state, or may become so further down (which at that time will
-                            //       trigger the parallel parent done event)
-                            configuration = exctx.getScInstance().getCurrentStatus().getAllStates();
-                        }
-                        if (isInFinalState(parent.getParent(), configuration)) {
+                        if (isInFinalState(parent.getParent(), exctx.getScInstance().getStateConfiguration().getActiveStates())) {
                             exctx.getInternalIOProcessor().addEvent(new TriggerEvent("done.state."+parent.getParent().getId()
                                     , TriggerEvent.CHANGE_EVENT));
                         }

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/test/StandaloneUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/test/StandaloneUtils.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/test/StandaloneUtils.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/test/StandaloneUtils.java Fri Jan  2 19:34:30 2015
@@ -114,7 +114,7 @@ public final class StandaloneUtils {
                     TriggerEvent[] evts = {new TriggerEvent(null,
                         TriggerEvent.SIGNAL_EVENT, null)};
                     exec.triggerEvents(evts);
-                    if (exec.getCurrentStatus().isFinal()) {
+                    if (exec.getStatus().isFinal()) {
                         System.out.println("A final configuration reached.");
                     }
                 } else {
@@ -126,7 +126,7 @@ public final class StandaloneUtils {
                                 TriggerEvent.SIGNAL_EVENT, null);
                     }
                     exec.triggerEvents(evts);
-                    if (exec.getCurrentStatus().isFinal()) {
+                    if (exec.getStatus().isFinal()) {
                         System.out.println("A final configuration reached.");
                     }
                 }

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/EventDataTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/EventDataTest.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/EventDataTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/EventDataTest.java Fri Jan  2 19:34:30 2015
@@ -36,7 +36,7 @@ public class EventDataTest {
     public void testEventdata01Sample() throws Exception {
     	SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/eventdata-01.xml");
         exec.go();
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
         Assert.assertEquals("state1", currentStates.iterator().next().getId());
         TriggerEvent te = new TriggerEvent("event.foo",
@@ -61,7 +61,7 @@ public class EventDataTest {
     public void testEventdata02Sample() throws Exception {
         SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/eventdata-02.xml");
         exec.go();
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
         Assert.assertEquals("state0", currentStates.iterator().next().getId());
         TriggerEvent te1 = new TriggerEvent("connection.alerting",
@@ -81,7 +81,7 @@ public class EventDataTest {
     public void testEventdata03Sample() throws Exception {
         SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/eventdata-03.xml");
         exec.go();
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
         Assert.assertEquals("ten", currentStates.iterator().next().getId());
         TriggerEvent te = new TriggerEvent("event.foo",

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/NamespacePrefixedXPathsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/NamespacePrefixedXPathsTest.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/NamespacePrefixedXPathsTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/NamespacePrefixedXPathsTest.java Fri Jan  2 19:34:30 2015
@@ -41,7 +41,7 @@ public class NamespacePrefixedXPathsTest
     // Same test, since same documents (different expression languages)
     private void runtest(SCXMLExecutor exec) throws Exception {
         // must be in state "ten" at the onset
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
         Assert.assertEquals("ten", currentStates.iterator().next().getId());
 
@@ -83,7 +83,7 @@ public class NamespacePrefixedXPathsTest
         Assert.assertEquals("seventy", currentStates.iterator().next().getId());
 
         // done
-        Assert.assertTrue(exec.getCurrentStatus().isFinal());
+        Assert.assertTrue(exec.getStatus().isFinal());
     }
 }
 

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLExecutorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLExecutorTest.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLExecutorTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLExecutorTest.java Fri Jan  2 19:34:30 2015
@@ -107,7 +107,7 @@ public class SCXMLExecutorTest {
     public void testSCXMLExecutorPrefix01Sample() throws Exception {
         SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/prefix-01.xml");
         exec.go();
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
         Assert.assertEquals("ten", currentStates.iterator().next().getId());
         currentStates = SCXMLTestHelper.fireEvent(exec, "done.state.ten");
@@ -126,7 +126,7 @@ public class SCXMLExecutorTest {
         Assert.assertEquals(1, currentStates.size());
         Assert.assertEquals("twenty_two", currentStates.iterator().next().getId());
         SCXMLTestHelper.fireEvent(exec, "done.state.twenty_two");
-        Assert.assertEquals(3, exec.getCurrentStatus().getStates().size());
+        Assert.assertEquals(3, exec.getStatus().getStates().size());
     }
 
     @Test
@@ -206,7 +206,7 @@ public class SCXMLExecutorTest {
     public void testSend01Sample() throws Exception {
         SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/send-01.xml");
         exec.go();
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
         Assert.assertEquals("ten", currentStates.iterator().next().getId());
         currentStates = SCXMLTestHelper.fireEvent(exec, "done.state.ten");
@@ -218,10 +218,10 @@ public class SCXMLExecutorTest {
     public void testSend02TypeSCXMLSample() throws Exception {
         SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/send-02.xml");
         exec.go();
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
         Assert.assertEquals("ninety", currentStates.iterator().next().getId());
-        Assert.assertTrue(exec.getCurrentStatus().isFinal());
+        Assert.assertTrue(exec.getStatus().isFinal());
     }
 
     @Test
@@ -262,6 +262,25 @@ public class SCXMLExecutorTest {
         SCXMLTestHelper.assertPostTriggerState(exec, "open", payload, "opened");
     }
 
+    @Test
+    public void testSCXMLExecutorSetConfiguration() throws Exception {
+        SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/transitions-01.xml");
+        exec.go();
+        Set<EnterableState> currentStates = SCXMLTestHelper.fireEvent(exec, "done.state.ten");
+        Assert.assertEquals(1, currentStates.size());
+        Assert.assertEquals("twenty_one", currentStates.iterator().next().getId());
+        currentStates = SCXMLTestHelper.fireEvent(exec, "done.state.twenty_one");
+        Assert.assertEquals(1, currentStates.size());
+        Assert.assertEquals("twenty_two", currentStates.iterator().next().getId());
+        Set<String> stateIds = new HashSet<String>();
+        stateIds.add("twenty_one");
+        exec.setConfiguration(stateIds);
+        Assert.assertEquals(1, exec.getStatus().getStates().size());
+        SCXMLTestHelper.fireEvent(exec, "done.state.twenty_one");
+        Assert.assertEquals(1, currentStates.size());
+        Assert.assertEquals("twenty_two", currentStates.iterator().next().getId());
+    }
+
     private void checkMicrowave01Sample(SCXMLExecutor exec) throws Exception {
         Set<EnterableState> currentStates = SCXMLTestHelper.fireEvent(exec, "turn_on");
         Assert.assertEquals(1, currentStates.size());

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLTestHelper.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLTestHelper.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLTestHelper.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLTestHelper.java Fri Jan  2 19:34:30 2015
@@ -136,7 +136,7 @@ public class SCXMLTestHelper {
     }
 
     public static void assertState(SCXMLExecutor exec, String expectedStateId) throws Exception {
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals("Expected 1 simple (leaf) state with id '"
             + expectedStateId + "' but found " + currentStates.size() + " states instead.",
             1, currentStates.size());
@@ -151,17 +151,17 @@ public class SCXMLTestHelper {
     public static Set<EnterableState> fireEvent(SCXMLExecutor exec, String name, Object payload) throws Exception {
         TriggerEvent[] evts = {new TriggerEvent(name, TriggerEvent.SIGNAL_EVENT, payload)};
         exec.triggerEvents(evts);
-        return exec.getCurrentStatus().getStates();
+        return exec.getStatus().getStates();
     }
 
     public static Set<EnterableState> fireEvent(SCXMLExecutor exec, TriggerEvent te) throws Exception {
         exec.triggerEvent(te);
-        return exec.getCurrentStatus().getStates();
+        return exec.getStatus().getStates();
     }
 
     public static Set<EnterableState> fireEvents(SCXMLExecutor exec, TriggerEvent[] evts) throws Exception {
         exec.triggerEvents(evts);
-        return exec.getCurrentStatus().getStates();
+        return exec.getStatus().getStates();
     }
 
     public static void assertPostTriggerState(SCXMLExecutor exec,

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/StatusTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/StatusTest.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/StatusTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/StatusTest.java Fri Jan  2 19:34:30 2015
@@ -27,18 +27,20 @@ import org.junit.Test;
 
 public class StatusTest {
 
+    private StateConfiguration stateConfiguration;
     private Status status;
     
     @Before
     public void setUp() {
-        status = new Status();
+        stateConfiguration = new StateConfiguration();
+        status = new Status(stateConfiguration);
     }
     
     @Test
     public void testIsFinalStateFalse() {
         State state = new State();
 
-        status.getStates().add(state);
+        stateConfiguration.enterState(state);
         
         Assert.assertFalse(status.isFinal());
     }
@@ -48,7 +50,7 @@ public class StatusTest {
         Final state = new Final();
         state.setParent(new State());
         
-        status.getStates().add(state);
+        stateConfiguration.enterState(state);
 
         Assert.assertFalse(status.isFinal());
     }
@@ -56,16 +58,16 @@ public class StatusTest {
     @Test
     public void testIsFinalState() {
         Final state = new Final();
-        
-        status.getStates().add(state);
-        
+
+        stateConfiguration.enterState(state);
+
         Assert.assertTrue(status.isFinal());
     }
 
     @Test
     public void testGetAllStatesEmptyStatus() {
 
-        Set<EnterableState> returnValue = status.getAllStates();
+        Set<EnterableState> returnValue = status.getActiveStates();
 
         Assert.assertEquals(0, returnValue.size());
     }
@@ -74,13 +76,28 @@ public class StatusTest {
     public void testGetAllStatesContainsParent() {
         State parent = new State();
         parent.setId("0");
+        stateConfiguration.enterState(parent);
         State state = new State();
         state.setId("1");
         state.setParent(parent);
-        status.getStates().add(state);
+        stateConfiguration.enterState(state);
 
-        Set<EnterableState> returnValue = status.getAllStates();
+        Set<EnterableState> returnValue = status.getActiveStates();
 
         Assert.assertEquals(2, returnValue.size());
     }
+
+    @Test
+    public void testIsInState() {
+        State parent = new State();
+        parent.setId("0");
+        stateConfiguration.enterState(parent);
+        State state = new State();
+        state.setId("1");
+        state.setParent(parent);
+        stateConfiguration.enterState(state);
+        Assert.assertTrue(status.isInState("0"));
+        Assert.assertTrue(status.isInState("1"));
+        Assert.assertFalse(status.isInState("2"));
+    }
 }

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/TieBreakerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/TieBreakerTest.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/TieBreakerTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/TieBreakerTest.java Fri Jan  2 19:34:30 2015
@@ -40,7 +40,7 @@ public class TieBreakerTest {
     public void testTieBreaker01() throws Exception {
         SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/tie-breaker-01.xml");
         exec.go();
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
         Assert.assertEquals("ten", currentStates.iterator().next().getId());
         currentStates = SCXMLTestHelper.fireEvent(exec, "done.state.ten");
@@ -52,7 +52,7 @@ public class TieBreakerTest {
     public void testTieBreaker02() throws Exception {
         SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/tie-breaker-02.xml");
         exec.go();
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
         Assert.assertEquals("eleven", currentStates.iterator().next().getId());
         currentStates = SCXMLTestHelper.fireEvent(exec, "done.state.ten");
@@ -64,7 +64,7 @@ public class TieBreakerTest {
     public void testTieBreaker03() throws Exception {
         SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/tie-breaker-03.xml");
         exec.go();
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
         Assert.assertEquals("eleven", currentStates.iterator().next().getId());
         currentStates = SCXMLTestHelper.fireEvent(exec, "done.state.ten");
@@ -86,7 +86,7 @@ public class TieBreakerTest {
     public void testTieBreaker05() throws Exception {
         SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/tie-breaker-05.xml");
         exec.go();
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(3, currentStates.size());
         for (TransitionTarget tt : currentStates) {
             String id = tt.getId();
@@ -106,7 +106,7 @@ public class TieBreakerTest {
     public void testTieBreaker06() throws Exception {
         SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/tie-breaker-06.xml");
         exec.go();
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
     }
 }

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/WildcardTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/WildcardTest.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/WildcardTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/WildcardTest.java Fri Jan  2 19:34:30 2015
@@ -34,7 +34,7 @@ public class WildcardTest {
     public void testWildcard01Sample() throws Exception {
     	SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/wildcard-01.xml");
         exec.go();
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
         Assert.assertEquals("state1", currentStates.iterator().next().getId());
         exec = SCXMLTestHelper.testInstanceSerializability(exec);
@@ -47,7 +47,7 @@ public class WildcardTest {
     public void testWildcard02Sample() throws Exception {
         SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/wildcard-02.xml");
         exec.go();
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
         Assert.assertEquals("state2", currentStates.iterator().next().getId());
     }

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/WizardsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/WizardsTest.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/WizardsTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/WizardsTest.java Fri Jan  2 19:34:30 2015
@@ -38,7 +38,7 @@ public class WizardsTest {
         SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/wizard-01.xml");
         exec.go();
         Assert.assertNotNull(exec);
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
         Assert.assertEquals("state1", currentStates.iterator().next().getId());
         exec = SCXMLTestHelper.testInstanceSerializability(exec);
@@ -64,7 +64,7 @@ public class WizardsTest {
         exec.go();
         // If you change this, you must also change
         // the TestEventDispatcher
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
         Assert.assertEquals("state2", currentStates.iterator().next().getId());
         exec = SCXMLTestHelper.testInstanceSerializability(exec);

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/StopWatch.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/StopWatch.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/StopWatch.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/StopWatch.java Fri Jan  2 19:34:30 2015
@@ -94,7 +94,7 @@ public class StopWatch extends AbstractS
 
     // used by the demonstration (see StopWatchDisplay usecase)
     public String getCurrentState() {
-        return getEngine().getCurrentStatus().getStates().iterator().next().getId();
+        return getEngine().getStatus().getStates().iterator().next().getId();
     }
 
     private void increment() {

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/GroovyEvaluatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/GroovyEvaluatorTest.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/GroovyEvaluatorTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/GroovyEvaluatorTest.java Fri Jan  2 19:34:30 2015
@@ -16,35 +16,31 @@
  */
 package org.apache.commons.scxml2.env.groovy;
 
-import java.util.HashSet;
-import java.util.Set;
-
 import org.apache.commons.scxml2.Context;
 import org.apache.commons.scxml2.Evaluator;
 import org.apache.commons.scxml2.SCXMLExpressionException;
 import org.apache.commons.scxml2.SCXMLSystemContext;
+import org.apache.commons.scxml2.StateConfiguration;
+import org.apache.commons.scxml2.Status;
 import org.apache.commons.scxml2.model.State;
-import org.apache.commons.scxml2.model.TransitionTarget;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
 public class GroovyEvaluatorTest {
 
-    private String BAD_EXPRESSION = ">";
+    private static final String BAD_EXPRESSION = ">";
     private Context ctx;
-    private Context rootCtx;
 
     @Before
     public void before() {
-        rootCtx = new GroovyContext();
-        ctx = new GroovyContext(new SCXMLSystemContext(rootCtx), null);
+        ctx = new GroovyContext(new SCXMLSystemContext(new GroovyContext()), null);
     }
 
     @Test
     public void testEval() throws SCXMLExpressionException {
         Evaluator eval = new GroovyEvaluator();
-        Assert.assertEquals(new Integer(2), eval.eval(ctx, "1 + 1"));
+        Assert.assertEquals(2, eval.eval(ctx, "1 + 1"));
     }
 
     @Test
@@ -56,14 +52,13 @@ public class GroovyEvaluatorTest {
     @Test
     public void testBuiltInFunctions() throws SCXMLExpressionException {
         Evaluator eval = new GroovyEvaluator();
+        StateConfiguration stateConfiguration = new StateConfiguration();
+        Status status = new Status(stateConfiguration);
+        ctx.getSystemContext().getPlatformVariables().put(SCXMLSystemContext.STATUS_KEY, status);
 
-        Set<TransitionTarget> allStates = new HashSet<TransitionTarget>();
         State state1 = new State();
         state1.setId("state1");
-        allStates.add(state1);
-
-        rootCtx.set(SCXMLSystemContext.ALL_STATES_KEY, allStates);
-
+        stateConfiguration.enterState(state1);
         Assert.assertTrue(eval.evalCond(ctx, "In('state1')"));
     }
 

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/SerializableInitialBaseScriptTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/SerializableInitialBaseScriptTest.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/SerializableInitialBaseScriptTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/SerializableInitialBaseScriptTest.java Fri Jan  2 19:34:30 2015
@@ -39,7 +39,7 @@ public class SerializableInitialBaseScri
         URL scxml = SCXMLTestHelper.getResource("org/apache/commons/scxml2/env/groovy/serializable-initial-base-script.xml");
     	SCXMLExecutor exec = SCXMLTestHelper.getExecutor(scxml, new GroovyEvaluator(true));
         exec.go();
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
         Assert.assertEquals("state1", currentStates.iterator().next().getId());
         exec = SCXMLTestHelper.testInstanceSerializability(exec);

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/StaticMethodTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/StaticMethodTest.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/StaticMethodTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/StaticMethodTest.java Fri Jan  2 19:34:30 2015
@@ -31,7 +31,7 @@ public class StaticMethodTest {
         SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/groovy/static-method.xml");
         exec.getRootContext().set("System", System.class);
         exec.go();
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
         Assert.assertEquals("static", currentStates.iterator().next().getId());
     }

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/JSExampleTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/JSExampleTest.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/JSExampleTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/JSExampleTest.java Fri Jan  2 19:34:30 2015
@@ -17,7 +17,6 @@
 
 package org.apache.commons.scxml2.env.javascript;
 
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
@@ -52,7 +51,7 @@ public class JSExampleTest {
         SCXML scxml = SCXMLTestHelper.parse("org/apache/commons/scxml2/env/javascript/example-01.xml", actions);
         SCXMLExecutor exec = SCXMLTestHelper.getExecutor(scxml);
         exec.go();
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
         Assert.assertEquals("end", currentStates.iterator().next().getId());
     }

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/ForeachTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/ForeachTest.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/ForeachTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/ForeachTest.java Fri Jan  2 19:34:30 2015
@@ -30,6 +30,6 @@ public class ForeachTest {
     public void testForeach() throws Exception {
         SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/foreach.xml");
         exec.go();
-        Assert.assertTrue(exec.getCurrentStatus().isFinal());
+        Assert.assertTrue(exec.getStatus().isFinal());
     }
 }

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/StaticMethodTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/StaticMethodTest.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/StaticMethodTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/StaticMethodTest.java Fri Jan  2 19:34:30 2015
@@ -32,7 +32,7 @@ public class StaticMethodTest {
         SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/static-method.xml");
         exec.getRootContext().set("System", System.class);
         exec.go();
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
         Assert.assertEquals("static", currentStates.iterator().next().getId());
     }

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/xpath/XPathExampleTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/xpath/XPathExampleTest.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/xpath/XPathExampleTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/xpath/XPathExampleTest.java Fri Jan  2 19:34:30 2015
@@ -38,7 +38,7 @@ public class XPathExampleTest {
 
         SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/xpath/example-01.xml");
         exec.go();
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
         Assert.assertEquals("mid", currentStates.iterator().next().getId());
 
@@ -55,7 +55,7 @@ public class XPathExampleTest {
 
         SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/xpath/example-02.xml");
         exec.go();
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
         Assert.assertEquals("end", currentStates.iterator().next().getId());
 

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/InvokeTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/InvokeTest.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/InvokeTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/InvokeTest.java Fri Jan  2 19:34:30 2015
@@ -16,7 +16,6 @@
  */
 package org.apache.commons.scxml2.invoke;
 
-import java.net.URL;
 import java.util.Set;
 
 import org.apache.commons.scxml2.SCXMLExecutor;
@@ -45,7 +44,7 @@ public class InvokeTest {
         exec.setStateMachine(scxml);
         exec.registerInvokerClass("scxml", SimpleSCXMLInvoker.class);
         exec.go();
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
         Assert.assertEquals("invoker", currentStates.iterator().next().getId());
     }
@@ -57,7 +56,7 @@ public class InvokeTest {
         exec.setStateMachine(scxml);
         exec.registerInvokerClass("scxml", SimpleSCXMLInvoker.class);
         exec.go();
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
     }
     
@@ -68,7 +67,7 @@ public class InvokeTest {
         exec.setStateMachine(scxml);
         exec.registerInvokerClass("scxml", SimpleSCXMLInvoker.class);
         exec.go();
-        Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
+        Set<EnterableState> currentStates = exec.getStatus().getStates();
         Assert.assertEquals(1, currentStates.size());
         SCXMLTestHelper.fireEvent(exec, "s1.next");
         SCXMLTestHelper.fireEvent(exec, "state1.next");

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/SCXMLRequiredAttributesTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/SCXMLRequiredAttributesTest.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/SCXMLRequiredAttributesTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/SCXMLRequiredAttributesTest.java Fri Jan  2 19:34:30 2015
@@ -150,7 +150,7 @@ public class SCXMLRequiredAttributesTest
         SCXML scxml = SCXMLTestHelper.parse(new StringReader(VALID_SCXML), null);
         SCXMLExecutor exec = SCXMLTestHelper.getExecutor(scxml);
         exec.go();
-        assertTrue(exec.getCurrentStatus().isFinal());
+        assertTrue(exec.getStatus().isFinal());
     }
 
     @Test
@@ -263,6 +263,6 @@ public class SCXMLRequiredAttributesTest
         SCXML scxml = SCXMLTestHelper.parse(new StringReader(SCXML_WITH_FOREACH), null);
         SCXMLExecutor exec = SCXMLTestHelper.getExecutor(scxml);
         exec.go();
-        assertTrue(exec.getCurrentStatus().isFinal());
+        assertTrue(exec.getStatus().isFinal());
     }
 }

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/StateSrcTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/StateSrcTest.java?rev=1649098&r1=1649097&r2=1649098&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/StateSrcTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/StateSrcTest.java Fri Jan  2 19:34:30 2015
@@ -33,13 +33,13 @@ public class StateSrcTest {
     public void testRecursiveSrcInclude() throws Exception {
         SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/io/src-test-1.xml");
         exec.go();
-        Set<EnterableState> states = exec.getCurrentStatus().getStates();
+        Set<EnterableState> states = exec.getStatus().getStates();
         Assert.assertEquals(1, states.size());
         Assert.assertEquals("srctest3", states.iterator().next().getId());
         states = SCXMLTestHelper.fireEvent(exec, "src.test");
         Assert.assertEquals(1, states.size());
         Assert.assertEquals("srctest1end", states.iterator().next().getId());
-        Assert.assertTrue(exec.getCurrentStatus().isFinal());
+        Assert.assertTrue(exec.getStatus().isFinal());
     }
     
     @Test



Mime
View raw message