You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by at...@apache.org on 2014/03/23 00:34:23 UTC
svn commit: r1580369 [3/5] - 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/groovy/
main/java/org/apache/commons/scxml2/env/jexl/ main/java/org/a...
Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Script.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Script.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Script.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Script.java Sat Mar 22 23:34:20 2014
@@ -86,7 +86,7 @@ public class Script extends Action imple
final Log appLog, final Collection<TriggerEvent> derivedEvents)
throws ModelException, SCXMLExpressionException {
Context ctx = isGlobalScript() ? scInstance.getGlobalScriptContext() :
- scInstance.getContext(getParentTransitionTarget());
+ scInstance.getContext(getParentEnterableState());
ctx.setLocal(getNamespacesKey(), getNamespaces());
Evaluator eval = scInstance.getEvaluator();
eval.evalScript(ctx, getScript());
Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Send.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Send.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Send.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Send.java Sat Mar 22 23:34:20 2014
@@ -253,8 +253,8 @@ public class Send extends Action impleme
final Log appLog, final Collection<TriggerEvent> derivedEvents)
throws ModelException, SCXMLExpressionException {
// Send attributes evaluation
- TransitionTarget parentTarget = getParentTransitionTarget();
- Context ctx = scInstance.getContext(parentTarget);
+ EnterableState parentState = getParentEnterableState();
+ Context ctx = scInstance.getContext(parentState);
ctx.setLocal(getNamespacesKey(), getNamespaces());
Evaluator eval = scInstance.getEvaluator();
// Most attributes of <send> are expressions so need to be
@@ -294,7 +294,7 @@ public class Send extends Action impleme
if (varObj == null) {
//considered as a warning here
errRep.onError(ErrorConstants.UNDEFINED_VARIABLE,
- varName + " = null", parentTarget);
+ varName + " = null", parentState);
}
params.put(varName, varObj);
}
Added: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/SimpleTransition.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/SimpleTransition.java?rev=1580369&view=auto
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/SimpleTransition.java (added)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/SimpleTransition.java Sat Mar 22 23:34:20 2014
@@ -0,0 +1,234 @@
+/*
+ * 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.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The class in this SCXML object model that corresponds to the
+ * simple <transition> SCXML element, without Transition rules for "events" or
+ * "guard-conditions". Used for <history> or <history> elements.
+ *
+ */
+public class SimpleTransition extends Executable
+ implements NamespacePrefixesHolder, Observable {
+
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 2L;
+
+ /**
+ * The Transition type: internal or external (default)
+ * @see {@link #isTypeInternal()}
+ */
+ private TransitionType type;
+
+ /**
+ * Derived effective Transition type.
+ * @see #isTypeInternal()
+ */
+ private Boolean typeInternal;
+
+ /**
+ * Optional property that specifies the new state(s) or parallel
+ * element to transition to. May be specified by reference or in-line.
+ * If multiple state(s) are specified, they must belong to the regions
+ * of the same parallel.
+ */
+ private List<TransitionTarget> targets;
+
+ /**
+ * The transition target ID
+ */
+ private String next;
+
+ /**
+ * The path(s) for this transition, one per target, in the same order
+ * as <code>targets</code>.
+ * @see Path
+ */
+ private List<Path> paths;
+
+ /**
+ * The current XML namespaces in the SCXML document for this action node,
+ * preserved for deferred XPath evaluation.
+ */
+ private Map<String, String> namespaces;
+
+ /**
+ * Constructor.
+ */
+ public SimpleTransition() {
+ super();
+ this.targets = new ArrayList<TransitionTarget>();
+ this.paths = new ArrayList<Path>();
+ }
+
+ /**
+ * @return true if Transition type == internal or false if type == external (default)
+ */
+ public final TransitionType getType() {
+ return type;
+ }
+
+ /**
+ * Sets the Transition type
+ * @param type the Transition type
+ */
+ public final void setType(final TransitionType type) {
+ this.type = type;
+ }
+
+ /**
+ * Returns the effective Transition type.
+ * <p>
+ * A transition type is only effectively internal if:
+ * <ul>
+ * <li>its {@link #getType()} == {@link TransitionType#internal}</li>
+ * <li>its source state {@link #getParent()} {@link State#isComposite()}</li>
+ * <li>all its {@link #getTargets()} are proper descendants of its {@link #getParent()}</li>
+ * </ul>
+ * Otherwise it is treated (for determining its exit states) as if it is of type {@link TransitionType#external}
+ * </p>
+ * @see <a href="http://www.w3.org/TR/2014/CR-scxml-20140313/#SelectingTransitions">
+ * http://www.w3.org/TR/2014/CR-scxml-20140313/#SelectingTransitions</a>
+ * </p>
+ * @return true if the effective Transition type is {@link TransitionType#internal}
+ */
+ public final boolean isTypeInternal() {
+ if (typeInternal == null) {
+ // derive typeInternal
+
+ boolean internal = TransitionType.internal == type;
+
+ if (internal) {
+ internal = (getParent() != null && getParent() instanceof State && ((State)getParent()).isComposite());
+ }
+
+ if (internal && targets.size() > 0) {
+ for (Path p : getPaths()) {
+ // TODO: testing the following actual works and always is correct
+ if (p.getPathScope() == null || p.getPathScope() == getParent()) {
+ continue;
+ }
+ // not a proper descendant
+ internal = false;
+ break;
+ }
+ }
+
+ typeInternal = internal;
+ }
+ return typeInternal;
+ }
+
+ /**
+ * Get the XML namespaces at this action node in the SCXML document.
+ *
+ * @return Returns the map of namespaces.
+ */
+ public final Map<String, String> getNamespaces() {
+ return namespaces;
+ }
+
+ /**
+ * Set the XML namespaces at this action node in the SCXML document.
+ *
+ * @param namespaces The document namespaces.
+ */
+ public final void setNamespaces(final Map<String, String> namespaces) {
+ this.namespaces = namespaces;
+ }
+
+ /**
+ * Get the list of transition targets (may be an empty list).
+ *
+ * @return Returns the target(s) as specified in SCXML markup.
+ * <p>Remarks: Is <code>empty</code> for "stay" transitions.
+ * Contains parent (the source node) for "self" transitions.</p>
+ *
+ * @since 0.7
+ */
+ public final List<TransitionTarget> getTargets() {
+ return targets;
+ }
+
+ /**
+ * Get the list of runtime transition target, which always contains
+ * atleast one TransitionTarget instance.
+ *
+ * @return Returns the actual targets of a transition at runtime.
+ * <p>Remarks: For both the "stay" and "self"
+ * transitions it returns parent (the source node). This method should
+ * never return an empty list or <code>null</code>.</p>
+ *
+ * @since 0.7
+ */
+ public final List<TransitionTarget> getRuntimeTargets() {
+ if (targets.size() == 0) {
+ List<TransitionTarget> runtimeTargets = new ArrayList<TransitionTarget>();
+ runtimeTargets.add(getParent());
+ return runtimeTargets;
+ }
+ return targets;
+ }
+
+ /**
+ * Get the ID of the transition target (may be null, if, for example,
+ * the target is specified inline).
+ *
+ * @return String Returns the transition target ID
+ * @see #getTargets()
+ */
+ public final String getNext() {
+ return next;
+ }
+
+ /**
+ * Set the transition target by specifying its ID.
+ *
+ * @param next The the transition target ID
+ */
+ public final void setNext(final String next) {
+ this.next = next;
+ }
+
+ /**
+ * Get the path(s) of this transiton.
+ *
+ * @see Path
+ * @return List returns the list of transition path(s)
+ *
+ * @since 0.7
+ */
+ public final List<Path> getPaths() {
+ if (paths.size() == 0) {
+ if (targets.size() > 0) {
+ int i = 0;
+ for (TransitionTarget tt : targets) {
+ paths.add(i++, new Path(getParent(), tt));
+ }
+ } else {
+ paths.add(new Path(getParent(), null));
+ }
+ }
+ return paths;
+ }
+}
Propchange: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/SimpleTransition.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/SimpleTransition.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/State.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/State.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/State.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/State.java Sat Mar 22 23:34:20 2014
@@ -16,15 +16,12 @@
*/
package org.apache.commons.scxml2.model;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
/**
* The class in this SCXML object model that corresponds to the
* <state> SCXML element.
*
*/
-public class State extends TransitionTarget {
+public class State extends TransitionalState {
/**
* Serial version UID.
@@ -32,29 +29,6 @@ public class State extends TransitionTar
private static final long serialVersionUID = 2L;
/**
- * The Map containing immediate children of this State, keyed by
- * their IDs. Incompatible with the parallel or invoke property.
- */
- private Map<String, TransitionTarget> children;
-
- /**
- * The Invoke child, which defines an external process that should
- * be invoked, immediately after the onentry executable content,
- * and the transitions become candidates after the invoked
- * process has completed its execution.
- * May occur 0 or 1 times. Incompatible with the state or parallel
- * property.
- */
- private Invoke invoke;
-
- /**
- * Boolean property indicating whether this is a final state or not.
- * Default value is false . Final states may not have substates or
- * outgoing transitions.
- */
- private boolean isFinal;
-
- /**
* The id of the initial child of this composite, corresponding with the state initial attribute
*/
private String first;
@@ -69,49 +43,6 @@ public class State extends TransitionTar
* Constructor.
*/
public State() {
- this.children = new LinkedHashMap<String, TransitionTarget>();
- }
-
- /**
- * Is this state a "final" state.
- *
- * @return boolean Returns the isFinal.
- *
- * @since 0.7
- */
- public final boolean isFinal() {
- return isFinal;
- }
-
- /**
- * Set whether this is a "final" state.
- *
- * @param isFinal
- * The isFinal to set.
- *
- * @since 0.7
- */
- public final void setFinal(final boolean isFinal) {
- this.isFinal = isFinal;
- }
-
- /**
- * Get the Invoke child (may be null).
- *
- * @return Invoke Returns the invoke.
- */
- public final Invoke getInvoke() {
- return invoke;
- }
-
- /**
- * Set the Invoke child.
- *
- * @param invoke
- * The invoke to set.
- */
- public final void setInvoke(final Invoke invoke) {
- this.invoke = invoke;
}
/**
@@ -152,7 +83,7 @@ public class State extends TransitionTar
*/
public final void setFirst(final String target) {
this.first = target;
- Transition t = new Transition();
+ SimpleTransition t = new SimpleTransition();
t.setNext(target);
Initial ini = new Initial();
ini.setGenerated();
@@ -162,34 +93,12 @@ public class State extends TransitionTar
}
/**
- * Get the map of child states (may be empty).
- *
- * @return Map Returns the children.
- */
- public final Map<String, TransitionTarget> getChildren() {
- return children;
- }
-
- /**
- * Add a child transition target.
- *
- * @param tt
- * a child transition target
- *
- * @since 0.7
- */
- public final void addChild(final TransitionTarget tt) {
- this.children.put(tt.getId(), tt);
- tt.setParent(this);
- }
-
- /**
* Check whether this is a simple (leaf) state (UML terminology).
*
* @return true if this is a simple state, otherwise false
*/
public final boolean isSimple() {
- return children.isEmpty();
+ return getChildren().isEmpty();
}
/**
@@ -198,7 +107,7 @@ public class State extends TransitionTar
* @return true if this is a composite state, otherwise false
*/
public final boolean isComposite() {
- return !children.isEmpty();
+ return !isSimple();
}
/**
@@ -211,6 +120,5 @@ public class State extends TransitionTar
public final boolean isRegion() {
return getParent() instanceof Parallel;
}
-
}
Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Transition.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Transition.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Transition.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Transition.java Sat Mar 22 23:34:20 2014
@@ -16,10 +16,6 @@
*/
package org.apache.commons.scxml2.model;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
/**
* The class in this SCXML object model that corresponds to the
* <transition> SCXML element. Transition rules are triggered
@@ -27,25 +23,12 @@ import java.util.Map;
* "guard-conditions".
*
*/
-public class Transition extends Executable
- implements NamespacePrefixesHolder, Observable {
-
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 2L;
+public class Transition extends SimpleTransition implements DocumentOrder {
/**
- * The Transition type: internal or external (default)
- * @see {@link #isTypeInternal()}
+ * The document order of this transition
*/
- private TransitionType type;
-
- /**
- * Derived effective Transition type.
- * @see #isTypeInternal()
- */
- private Boolean typeInternal;
+ private int order;
/**
* Property that specifies the trigger for this transition.
@@ -58,96 +41,29 @@ public class Transition extends Executab
private String cond;
/**
- * Optional property that specifies the new state(s) or parallel
- * element to transition to. May be specified by reference or in-line.
- * If multiple state(s) are specified, they must belong to the regions
- * of the same parallel.
- */
- private List<TransitionTarget> targets;
-
- /**
- * The transition target ID (used by XML Digester only).
- */
- private String next;
-
- /**
- * The path(s) for this transition, one per target, in the same order
- * as <code>targets</code>.
- * @see Path
- */
- private List<Path> paths;
-
- /**
- * The current XML namespaces in the SCXML document for this action node,
- * preserved for deferred XPath evaluation.
- */
- private Map<String, String> namespaces;
-
- /**
* Constructor.
*/
public Transition() {
super();
- this.targets = new ArrayList<TransitionTarget>();
- this.paths = new ArrayList<Path>();
}
- /**
- * @return true if Transition type == internal or false if type == external (default)
- */
- public final TransitionType getType() {
- return type;
- }
/**
- * Sets the Transition type
- * @param type the Transition type
+ * @return the document order of this transition
+ * @see DocumentOrder
*/
- public final void setType(final TransitionType type) {
- this.type = type;
+ @Override
+ public final int getOrder() {
+ return order;
}
/**
- * Returns the effective Transition type.
- * <p>
- * A transition type is only effectively internal if:
- * <ul>
- * <li>its {@link #getType()} == {@link TransitionType#internal}</li>
- * <li>its source state {@link #getParent()} {@link State#isComposite()}</li>
- * <li>all its {@link #getTargets()} are proper descendants of its {@link #getParent()}</li>
- * </ul>
- * Otherwise it is treated (for determining its exit states) as if it is of type {@link TransitionType#external}
- * </p>
- * @see <a href="http://www.w3.org/TR/2014/CR-scxml-20140313/#SelectingTransitions">
- * http://www.w3.org/TR/2014/CR-scxml-20140313/#SelectingTransitions</a>
- * </p>
- * @return true if the effective Transition type is {@link TransitionType#internal}
+ * Sets the document order of this transition
+ * @param order the document order
+ * @see DocumentOrder
*/
- public final boolean isTypeInternal() {
- if (typeInternal == null) {
- // derive typeInternal
-
- boolean internal = TransitionType.internal == type;
-
- if (internal) {
- internal = (getParent() != null && getParent() instanceof State && ((State)getParent()).isComposite());
- }
-
- if (internal && targets.size() > 0) {
- for (Path p : getPaths()) {
- // TODO: testing the following actual works and always is correct
- if (p.getPathScope() == null || p.getPathScope() == getParent()) {
- continue;
- }
- // not a proper descendant
- internal = false;
- break;
- }
- }
-
- typeInternal = internal;
- }
- return typeInternal;
+ public final void setOrder(int order) {
+ this.order = order;
}
/**
@@ -155,7 +71,7 @@ public class Transition extends Executab
*
* @return Returns the cond.
*/
- public final String getCond() {
+ public String getCond() {
return cond;
}
@@ -164,7 +80,7 @@ public class Transition extends Executab
*
* @param cond The cond to set.
*/
- public final void setCond(final String cond) {
+ public void setCond(final String cond) {
this.cond = cond;
}
@@ -174,7 +90,7 @@ public class Transition extends Executab
*
* @return Returns the event.
*/
- public final String getEvent() {
+ public String getEvent() {
return event;
}
@@ -184,102 +100,8 @@ public class Transition extends Executab
*
* @param event The event to set.
*/
- public final void setEvent(final String event) {
+ public void setEvent(final String event) {
this.event = event;
}
-
- /**
- * Get the XML namespaces at this action node in the SCXML document.
- *
- * @return Returns the map of namespaces.
- */
- public final Map<String, String> getNamespaces() {
- return namespaces;
- }
-
- /**
- * Set the XML namespaces at this action node in the SCXML document.
- *
- * @param namespaces The document namespaces.
- */
- public final void setNamespaces(final Map<String, String> namespaces) {
- this.namespaces = namespaces;
- }
-
- /**
- * Get the list of transition targets (may be an empty list).
- *
- * @return Returns the target(s) as specified in SCXML markup.
- * <p>Remarks: Is <code>empty</code> for "stay" transitions.
- * Contains parent (the source node) for "self" transitions.</p>
- *
- * @since 0.7
- */
- public final List<TransitionTarget> getTargets() {
- return targets;
- }
-
- /**
- * Get the list of runtime transition target, which always contains
- * atleast one TransitionTarget instance.
- *
- * @return Returns the actual targets of a transition at runtime.
- * <p>Remarks: For both the "stay" and "self"
- * transitions it returns parent (the source node). This method should
- * never return an empty list or <code>null</code>.</p>
- *
- * @since 0.7
- */
- public final List<TransitionTarget> getRuntimeTargets() {
- if (targets.size() == 0) {
- List<TransitionTarget> runtimeTargets = new ArrayList<TransitionTarget>();
- runtimeTargets.add(getParent());
- return runtimeTargets;
- }
- return targets;
- }
-
- /**
- * Get the ID of the transition target (may be null, if, for example,
- * the target is specified inline).
- *
- * @return String Returns the transition target ID
- * (used by SCXML Digester only).
- * @see #getTargets()
- */
- public final String getNext() {
- return next;
- }
-
- /**
- * Set the transition target by specifying its ID.
- *
- * @param next The the transition target ID (used by SCXML Digester only).
- */
- public final void setNext(final String next) {
- this.next = next;
- }
-
- /**
- * Get the path(s) of this transiton.
- *
- * @see Path
- * @return List returns the list of transition path(s)
- *
- * @since 0.7
- */
- public final List<Path> getPaths() {
- if (paths.size() == 0) {
- if (targets.size() > 0) {
- int i = 0;
- for (TransitionTarget tt : targets) {
- paths.add(i++, new Path(getParent(), tt));
- }
- } else {
- paths.add(new Path(getParent(), null));
- }
- }
- return paths;
- }
}
Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/TransitionTarget.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/TransitionTarget.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/TransitionTarget.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/TransitionTarget.java Sat Mar 22 23:34:20 2014
@@ -17,8 +17,6 @@
package org.apache.commons.scxml2.model;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
/**
* An abstract base class for elements in SCXML that can serve as a
@@ -27,6 +25,7 @@ import java.util.List;
*/
public abstract class TransitionTarget implements Serializable, Observable {
+ private static final TransitionTarget[] ZERO_ANCESTORS = new TransitionTarget[0];
/**
* Identifier for this transition target. Other parts of the SCXML
* document may refer to this <state> using this ID.
@@ -34,51 +33,19 @@ public abstract class TransitionTarget i
private String id;
/**
- * Optional property holding executable content to be run upon
- * entering this transition target.
- */
- private OnEntry onEntry;
-
- /**
- * Optional property holding executable content to be run upon
- * exiting this transition target.
- */
- private OnExit onExit;
-
- /**
- * Optional property holding the data model for this transition target.
- */
- private Datamodel datamodel;
-
- /**
- * A list of outgoing Transitions from this state, by document order.
- */
- private List<Transition> transitions;
-
- /**
* The parent of this transition target (may be null, if the parent
* is the SCXML document root).
*/
private TransitionTarget parent;
- /**
- * List of history states owned by a given state (applies to non-leaf
- * states).
- */
- private List<History> history;
+ private TransitionTarget[] ancestors = ZERO_ANCESTORS;
/**
* Constructor.
*/
public TransitionTarget() {
super();
- onEntry = new OnEntry(); //empty defaults
- onEntry.setParent(this);
- onExit = new OnExit(); //empty defaults
- onExit.setParent(this);
- transitions = new ArrayList<Transition>();
parent = null;
- history = new ArrayList<History>();
}
/**
@@ -100,101 +67,19 @@ public abstract class TransitionTarget i
}
/**
- * Get the onentry property.
- *
- * @return Returns the onEntry.
- */
- public final OnEntry getOnEntry() {
- return onEntry;
- }
-
- /**
- * Set the onentry property.
- *
- * @param onEntry The onEntry to set.
- */
- public final void setOnEntry(final OnEntry onEntry) {
- this.onEntry = onEntry;
- this.onEntry.setParent(this);
- }
-
- /**
- * Get the onexit property.
- *
- * @return Returns the onExit.
- */
- public final OnExit getOnExit() {
- return onExit;
- }
-
- /**
- * Set the onexit property.
- *
- * @param onExit The onExit to set.
- */
- public final void setOnExit(final OnExit onExit) {
- this.onExit = onExit;
- this.onExit.setParent(this);
- }
-
- /**
- * Get the data model for this transition target.
- *
- * @return Returns the data model.
- */
- public final Datamodel getDatamodel() {
- return datamodel;
- }
-
- /**
- * Set the data model for this transition target.
- *
- * @param datamodel The Datamodel to set.
- */
- public final void setDatamodel(final Datamodel datamodel) {
- this.datamodel = datamodel;
- }
-
- /**
- * Get the list of all outgoing transitions from this state, that
- * will be candidates for being fired on the given event.
- *
- * @param event The event
- * @return List Returns the candidate transitions for given event
+ * @return the number of TransitionTarget ancestors
*/
- public final List<Transition> getTransitionsList(final String event) {
- List<Transition> matchingTransitions = null; // since we returned null upto v0.6
- for (Transition t : transitions) {
- if ((event == null && t.getEvent() == null)
- || (event != null && event.equals(t.getEvent()))) {
- if (matchingTransitions == null) {
- matchingTransitions = new ArrayList<Transition>();
- }
- matchingTransitions.add(t);
- }
- }
- return matchingTransitions;
+ public int getNumberOfAncestors() {
+ return ancestors.length;
}
/**
- * Add a transition to the map of all outgoing transitions for
- * this state.
- *
- * @param transition
- * The transitions to set.
+ * Get the ancestor of this TransitionTarget at specified level
+ * @param level the level of the ancestor to return, zero being top
+ * @return the ancestor at specified level
*/
- public final void addTransition(final Transition transition) {
- transitions.add(transition);
- transition.setParent(this);
- }
-
- /**
- * Get the outgoing transitions for this state as a java.util.List.
- *
- * @return List Returns the transitions list.
- */
- public final List<Transition> getTransitionsList() {
- return transitions;
+ public final TransitionTarget getAncestor(int level) {
+ return ancestors[level];
}
/**
@@ -203,7 +88,7 @@ public abstract class TransitionTarget i
* @return Returns the parent state
* (null if parent is <scxml> element)
*/
- public final TransitionTarget getParent() {
+ public TransitionTarget getParent() {
return parent;
}
@@ -212,65 +97,26 @@ public abstract class TransitionTarget i
*
* @param parent The parent state to set
*/
- public final void setParent(final TransitionTarget parent) {
- this.parent = parent;
- }
-
- /**
- * Get the parent State.
- *
- * @return The parent State
- */
- public final State getParentState() {
- TransitionTarget tt = this.getParent();
- if (tt == null) {
- return null;
- } else {
- if (tt instanceof State) {
- return (State) tt;
- } else { //tt is Parallel
- return tt.getParentState();
- }
+ public void setParent(final TransitionTarget parent) {
+ if (parent == null) {
+ throw new IllegalArgumentException("Parent parameter cannot be null");
+ }
+ if (parent == this) {
+ throw new IllegalArgumentException("Cannot set self as parent");
+ }
+ if (this.parent != parent) {
+ this.parent = parent;
+ updateDescendantsAncestors();
}
}
/**
- * This method is used by XML digester.
- *
- * @param h
- * History pseudo state
- *
- * @since 0.7
- */
- public final void addHistory(final History h) {
- history.add(h);
- h.setParent(this);
- }
-
- /**
- * Does this state have a history pseudo state.
- *
- * @return boolean true if a given state contains at least one
- * history pseudo state
- *
- * @since 0.7
- */
- public final boolean hasHistory() {
- return (!history.isEmpty());
- }
-
- /**
- * Get the list of history pseudo states for this state.
- *
- * @return a list of all history pseudo states contained by a given state
- * (can be empty)
- * @see #hasHistory()
- *
- * @since 0.7
+ * Update TransitionTarget descendants their ancestors
*/
- public final List<History> getHistory() {
- return history;
+ protected void updateDescendantsAncestors() {
+ ancestors = new TransitionTarget[parent.ancestors.length+1];
+ System.arraycopy(parent.ancestors, 0, ancestors, 0, parent.ancestors.length);
+ ancestors[parent.ancestors.length] = parent;
}
-
}
Added: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/TransitionalState.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/TransitionalState.java?rev=1580369&view=auto
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/TransitionalState.java (added)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/TransitionalState.java Sat Mar 22 23:34:20 2014
@@ -0,0 +1,215 @@
+/*
+ * 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.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * An abstract base class for state elements in SCXML that can be transitioned out from, such as State or Parallel.
+ */
+public abstract class TransitionalState extends EnterableState {
+
+ /**
+ * A list of outgoing Transitions from this state, by document order.
+ */
+ private List<Transition> transitions;
+
+ /**
+ * Optional property holding the data model for this state.
+ */
+ private Datamodel datamodel;
+
+ /**
+ * List of history states owned by a given state (applies to non-leaf
+ * states).
+ */
+ private List<History> history;
+
+ /**
+ * The Invoke child, which defines an external process that should
+ * be invoked, immediately after the onentry executable content,
+ * and the transitions become candidates after the invoked
+ * process has completed its execution.
+ * May occur 0 or 1 times. Incompatible with the state or parallel
+ * property.
+ */
+ private Invoke invoke;
+
+ /**
+ * The set of EnterableState children contained in this TransitionalState
+ */
+ private List<EnterableState> children;
+
+ public TransitionalState() {
+ super();
+ transitions = new ArrayList<Transition>();
+ history = new ArrayList<History>();
+ children = new ArrayList<EnterableState>();
+ }
+
+ /**
+ * Update TransitionTarget descendants their ancestors
+ */
+ protected void updateDescendantsAncestors() {
+ super.updateDescendantsAncestors();
+ for (History h : history) {
+ // reset ancestors
+ h.updateDescendantsAncestors();
+ }
+ for (TransitionTarget child : children) {
+ child.updateDescendantsAncestors();
+ }
+ }
+
+ /**
+ * Get the list of all outgoing transitions from this state, that
+ * will be candidates for being fired on the given event.
+ *
+ * @param event The event
+ * @return List Returns the candidate transitions for given event
+ */
+ public final List<Transition> getTransitionsList(final String event) {
+ List<Transition> matchingTransitions = null; // since we returned null upto v0.6
+ for (Transition t : transitions) {
+ if ((event == null && t.getEvent() == null)
+ || (event != null && event.equals(t.getEvent()))) {
+ if (matchingTransitions == null) {
+ matchingTransitions = new ArrayList<Transition>();
+ }
+ matchingTransitions.add(t);
+ }
+ }
+ return matchingTransitions;
+ }
+
+ /**
+ * Add a transition to the map of all outgoing transitions for
+ * this state.
+ *
+ * @param transition
+ * The transitions to set.
+ */
+ public final void addTransition(final Transition transition) {
+ transitions.add(transition);
+ transition.setParent(this);
+ }
+
+ /**
+ * Get the outgoing transitions for this state as a java.util.List.
+ *
+ * @return List Returns the transitions list.
+ */
+ public final List<Transition> getTransitionsList() {
+ return transitions;
+ }
+
+ /**
+ * Get the data model for this transition target.
+ *
+ * @return Returns the data model.
+ */
+ public final Datamodel getDatamodel() {
+ return datamodel;
+ }
+
+ /**
+ * Set the data model for this transition target.
+ *
+ * @param datamodel The Datamodel to set.
+ */
+ public final void setDatamodel(final Datamodel datamodel) {
+ this.datamodel = datamodel;
+ }
+
+ /**
+ * @param h History pseudo state
+ *
+ * @since 0.7
+ */
+ public final void addHistory(final History h) {
+ history.add(h);
+ h.setParent(this);
+ }
+
+ /**
+ * Does this state have a history pseudo state.
+ *
+ * @return boolean true if a given state contains at least one
+ * history pseudo state
+ *
+ * @since 0.7
+ */
+ public final boolean hasHistory() {
+ return (!history.isEmpty());
+ }
+
+ /**
+ * Get the list of history pseudo states for this state.
+ *
+ * @return a list of all history pseudo states contained by a given state
+ * (can be empty)
+ * @see #hasHistory()
+ *
+ * @since 0.7
+ */
+ public final List<History> getHistory() {
+ return history;
+ }
+
+ /**
+ * Get the Invoke child (may be null).
+ *
+ * @return Invoke Returns the invoke.
+ */
+ public final Invoke getInvoke() {
+ return invoke;
+ }
+
+ /**
+ * Set the Invoke child.
+ *
+ * @param invoke
+ * The invoke to set.
+ */
+ public final void setInvoke(final Invoke invoke) {
+ this.invoke = invoke;
+ }
+
+ /**
+ * Get the set of child transition targets (may be empty).
+ *
+ * @return Set Returns the children.
+ *
+ * @since 0.7
+ */
+ public final List<EnterableState> getChildren() {
+ return children;
+ }
+
+ /**
+ * Add a child.
+ *
+ * @param es A child enterable state.
+ *
+ * @since 0.7
+ */
+ public void addChild(final EnterableState es) {
+ children.add(es);
+ es.setParent(this);
+ }
+}
Propchange: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/TransitionalState.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/TransitionalState.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Var.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Var.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Var.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Var.java Sat Mar 22 23:34:20 2014
@@ -102,7 +102,7 @@ public class Var extends Action {
final ErrorReporter errRep, final SCInstance scInstance,
final Log appLog, final Collection<TriggerEvent> derivedEvents)
throws ModelException, SCXMLExpressionException {
- Context ctx = scInstance.getContext(getParentTransitionTarget());
+ Context ctx = scInstance.getContext(getParentEnterableState());
Evaluator eval = scInstance.getEvaluator();
ctx.setLocal(getNamespacesKey(), getNamespaces());
Object varObj = eval.eval(ctx, expr);
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=1580369&r1=1580368&r2=1580369&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 Sat Mar 22 23:34:20 2014
@@ -20,7 +20,6 @@ import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
@@ -46,11 +45,16 @@ import org.apache.commons.scxml2.Trigger
import org.apache.commons.scxml2.invoke.Invoker;
import org.apache.commons.scxml2.invoke.InvokerException;
import org.apache.commons.scxml2.model.Action;
+import org.apache.commons.scxml2.model.DocumentOrder;
+import org.apache.commons.scxml2.model.EnterableState;
import org.apache.commons.scxml2.model.Executable;
+import org.apache.commons.scxml2.model.Final;
import org.apache.commons.scxml2.model.Finalize;
import org.apache.commons.scxml2.model.History;
import org.apache.commons.scxml2.model.Initial;
import org.apache.commons.scxml2.model.Invoke;
+import org.apache.commons.scxml2.model.SimpleTransition;
+import org.apache.commons.scxml2.model.TransitionalState;
import org.apache.commons.scxml2.model.ModelException;
import org.apache.commons.scxml2.model.OnEntry;
import org.apache.commons.scxml2.model.OnExit;
@@ -83,12 +87,6 @@ public class SCXMLSemanticsImpl implemen
private Log appLog = LogFactory.getLog(SCXMLSemantics.class);
/**
- * The TransitionTarget comparator.
- */
- private TransitionTargetComparator<TransitionTarget> targetComparator =
- new TransitionTargetComparator<TransitionTarget>();
-
- /**
* Current document namespaces are saved under this key in the parent
* state's context.
*/
@@ -101,14 +99,6 @@ public class SCXMLSemanticsImpl implemen
private static final String ERR_ILLEGAL_ALLOC = ".error.illegalalloc";
/**
- * TransitionTargetComparator factory method.
- * @return Comparator The TransitionTarget comparator
- */
- protected Comparator<TransitionTarget> getTTComparator() {
- return targetComparator;
- }
-
- /**
* Set the log used by this <code>SCXMLSemantics</code> instance.
*
* @param log The new log.
@@ -228,27 +218,27 @@ public class SCXMLSemanticsImpl implemen
final ErrorReporter errRep, final SCInstance scInstance) throws ModelException {
NotificationRegistry nr = scInstance.getNotificationRegistry();
Collection<TriggerEvent> internalEvents = step.getAfterStatus().getEvents();
- Map<TransitionTarget, Invoker> invokers = scInstance.getInvokers();
+ Map<TransitionalState, Invoker> invokers = scInstance.getInvokers();
// ExecutePhaseActions / OnExit
- for (TransitionTarget tt : step.getExitList()) {
- OnExit oe = tt.getOnExit();
+ for (EnterableState es : step.getExitList()) {
+ OnExit oe = es.getOnExit();
executeContent(oe, evtDispatcher, errRep, scInstance, internalEvents);
// check if invoke is active in this state
- if (invokers.containsKey(tt)) {
- Invoker toCancel = invokers.get(tt);
+ if (invokers.containsKey(es)) {
+ Invoker toCancel = invokers.get(es);
try {
toCancel.cancel();
} catch (InvokerException ie) {
- TriggerEvent te = new TriggerEvent(tt.getId()
+ TriggerEvent te = new TriggerEvent(es.getId()
+ ".invoke.cancel.failed", TriggerEvent.ERROR_EVENT);
internalEvents.add(te);
}
// done here, don't wait for cancel response
- invokers.remove(tt);
+ invokers.remove(es);
}
- nr.fireOnExit(tt, tt);
- nr.fireOnExit(stateMachine, tt);
- TriggerEvent te = new TriggerEvent(tt.getId() + ".exit",
+ nr.fireOnExit(es, es);
+ nr.fireOnExit(stateMachine, es);
+ TriggerEvent te = new TriggerEvent(es.getId() + ".exit",
TriggerEvent.CHANGE_EVENT);
internalEvents.add(te);
}
@@ -272,52 +262,52 @@ public class SCXMLSemanticsImpl implemen
final ErrorReporter errRep, final SCInstance scInstance) throws ModelException {
NotificationRegistry nr = scInstance.getNotificationRegistry();
Collection<TriggerEvent> internalEvents = step.getAfterStatus().getEvents();
- for (TransitionTarget tt : step.getEntryList()) {
- OnEntry oe = tt.getOnEntry();
+ for (EnterableState es : step.getEntryList()) {
+ OnEntry oe = es.getOnEntry();
executeContent(oe, evtDispatcher, errRep, scInstance, internalEvents);
- nr.fireOnEntry(tt, tt);
- nr.fireOnEntry(stateMachine, tt);
- TriggerEvent te = new TriggerEvent(tt.getId() + ".entry",
+ nr.fireOnEntry(es, es);
+ nr.fireOnEntry(stateMachine, es);
+ TriggerEvent te = new TriggerEvent(es.getId() + ".entry",
TriggerEvent.CHANGE_EVENT);
internalEvents.add(te);
// actions in initial transition (if any) and .done events
- if (tt instanceof State) {
- State ts = (State) tt;
+ if (es instanceof State) {
+ State ts = (State) es;
Initial ini = ts.getInitial();
if (ts.isComposite() && ini != null) { // TODO: use step.getDefaultEntrySet().contains(tt) instead
executeContent(ini.getTransition(), evtDispatcher, errRep, scInstance, internalEvents);
}
- if (ts.isFinal()) {
- State parent = (State) ts.getParent();
- String prefix = "";
- if (parent != null) {
- prefix = parent.getId();
- }
- te = new TriggerEvent(prefix + ".done",
- TriggerEvent.CHANGE_EVENT);
- internalEvents.add(te);
- if (parent != null) {
- scInstance.setDone(parent, true);
- }
- if (parent != null && parent.isRegion()) {
- //3.4 we got a region, which is finalized
- //let's check its siblings too
- Parallel p = (Parallel) parent.getParent();
- int finCount = 0;
- int pCount = p.getChildren().size();
- for (TransitionTarget ttreg : p.getChildren()) {
- State reg = (State) ttreg;
- if (scInstance.isDone(reg)) {
- finCount++;
- }
- }
- if (finCount == pCount) {
- te = new TriggerEvent(p.getId() + ".done",
- TriggerEvent.CHANGE_EVENT);
- internalEvents.add(te);
- scInstance.setDone(p, true);
+ }
+ else if (es instanceof Final) {
+ State parent = (State)es.getParent();
+ String prefix = "";
+ if (parent != null) {
+ prefix = parent.getId();
+ }
+ te = new TriggerEvent(prefix + ".done",
+ TriggerEvent.CHANGE_EVENT);
+ internalEvents.add(te);
+ if (parent != null) {
+ scInstance.setDone(parent, true);
+ }
+ if (parent != null && parent.isRegion()) {
+ //3.4 we got a region, which is finalized
+ //let's check its siblings too
+ Parallel p = (Parallel) parent.getParent();
+ int finCount = 0;
+ int pCount = p.getChildren().size();
+ for (TransitionTarget ttreg : p.getChildren()) {
+ State reg = (State) ttreg;
+ if (scInstance.isDone(reg)) {
+ finCount++;
}
}
+ if (finCount == pCount) {
+ te = new TriggerEvent(p.getId() + ".done",
+ TriggerEvent.CHANGE_EVENT);
+ internalEvents.add(te);
+ scInstance.setDone(p, true);
+ }
}
}
}
@@ -338,24 +328,18 @@ public class SCXMLSemanticsImpl implemen
public void determineInitialStates(final Step step, final SCXML stateMachine, final ErrorReporter errRep,
final SCInstance scInstance)
throws ModelException {
- Transition t = stateMachine.getInitialTransition();
+ SimpleTransition t = stateMachine.getInitialTransition();
if (t == null) {
errRep.onError(ErrorConstants.NO_INITIAL,
"SCXML initialstate is missing!", stateMachine);
} else {
- Set<TransitionTarget> targets = step.getAfterStatus().getStates();
- targets.addAll(t.getTargets());
- determineTargetStates(targets, errRep, scInstance);
+ Set<EnterableState> states = step.getAfterStatus().getStates();
+ states.addAll(determineTargetStates(new HashSet<TransitionTarget>(t.getTargets()), errRep, scInstance));
//set of ALL entered states (even if initialState is a jump-over)
- Set<TransitionTarget> onEntry = SCXMLHelper.getAncestorClosure(targets, null);
- // sort onEntry according state hierarchy
- TransitionTarget[] oen = onEntry.toArray(new TransitionTarget[onEntry.size()]);
- onEntry.clear();
- Arrays.sort(oen, getTTComparator());
- // we need to impose reverse order for the onEntry list
- List<TransitionTarget> entering = Arrays.asList(oen);
- Collections.reverse(entering);
- step.getEntryList().addAll(entering);
+ Set<EnterableState> onEntry = SCXMLHelper.getAncestorClosure(states, null);
+ step.getEntryList().addAll(onEntry);
+ // sort onEntry according state hierarchy, in reverse order
+ Collections.sort(step.getEntryList(), DocumentOrder.reverseDocumentOrderComparator);
}
}
@@ -399,18 +383,20 @@ public class SCXMLSemanticsImpl implemen
// prevents adding the same transition multiple times
Set<Transition> transSet = new HashSet<Transition>();
// prevents visiting the same state multiple times
- Set<TransitionTarget> stateSet = new HashSet<TransitionTarget>(step.getBeforeStatus().getStates());
+ Set<EnterableState> stateSet = new HashSet<EnterableState>(step.getBeforeStatus().getStates());
// breath-first search to-do list
- LinkedList<TransitionTarget> todoList = new LinkedList<TransitionTarget>(stateSet);
+ LinkedList<EnterableState> todoList = new LinkedList<EnterableState>(stateSet);
while (!todoList.isEmpty()) {
- TransitionTarget tt = todoList.removeFirst();
- for (Transition t : tt.getTransitionsList()) {
- if (!transSet.contains(t)) {
- transSet.add(t);
- step.getTransitList().add(t);
+ EnterableState es = todoList.removeFirst();
+ if (es instanceof TransitionalState) {
+ for (Transition t : ((TransitionalState)es).getTransitionsList()) {
+ if (!transSet.contains(t)) {
+ transSet.add(t);
+ step.getTransitList().add(t);
+ }
}
}
- TransitionTarget parent = tt.getParent();
+ EnterableState parent = es.getParent();
if (parent != null && !stateSet.contains(parent)) {
stateSet.add(parent);
todoList.addLast(parent);
@@ -475,8 +461,10 @@ public class SCXMLSemanticsImpl implemen
if (SCXMLHelper.isStringEmpty(expr)) {
rslt = Boolean.TRUE;
} else {
+ // Note: a History Transition may NOT have a cond or event specified, so here we are ensured that
+ // only EnterableState Transitions are evaluated
try {
- Context ctx = scInstance.getContext(t.getParent());
+ Context ctx = scInstance.getContext((EnterableState)t.getParent());
ctx.setLocal(NAMESPACES_KEY, t.getNamespaces());
rslt = scInstance.getEvaluator().evalCond(ctx,
t.getCond());
@@ -566,22 +554,21 @@ public class SCXMLSemanticsImpl implemen
* ErrorReporter callback [inout]
* @return Set The target set
*/
- public Set<TransitionTarget> seedTargetSet(final Set<TransitionTarget> residual,
+ public Set<TransitionTarget> seedTargetSet(final Set<EnterableState> residual,
final List<Transition> transitList, final ErrorReporter errRep) {
Set<TransitionTarget> seedSet = new HashSet<TransitionTarget>();
- Set<TransitionTarget> regions = new HashSet<TransitionTarget>();
+ Set<EnterableState> regions = new HashSet<EnterableState>();
for (Transition t : transitList) {
//iterate over transitions and add target states
if (t.getTargets().size() > 0) {
seedSet.addAll(t.getTargets());
}
- //build a set of all entered regions
+ //also add all to be entered regions
for (Path p : t.getPaths()) {
if (p.isCrossRegion()) {
List<State> regs = p.getRegionsEntered();
for (State region : regs) {
- regions.addAll(((Parallel) region.getParent()).
- getChildren());
+ regions.addAll(((Parallel)region.getParent()).getChildren());
}
}
}
@@ -589,18 +576,13 @@ public class SCXMLSemanticsImpl implemen
//check whether all active regions have their siblings active too
Set<TransitionTarget> allStates = new HashSet<TransitionTarget>(residual);
allStates.addAll(seedSet);
- allStates = SCXMLHelper.getAncestorClosure(allStates, null);
- regions.removeAll(allStates);
- //iterate over inactive regions and visit them implicitly using initial
- for (TransitionTarget tt : regions) {
- State reg = (State) tt;
- seedSet.add(reg);
- }
+ regions.removeAll(SCXMLHelper.getAncestorClosure(allStates, null));
+ seedSet.addAll(regions);
return seedSet;
}
/**
- * @param states
+ * @param targets
* a set seeded in previous step [inout]
* @param errRep
* ErrorReporter callback [inout]
@@ -609,19 +591,18 @@ public class SCXMLSemanticsImpl implemen
* @throws ModelException On illegal configuration
* @see #seedTargetSet(Set, List, ErrorReporter)
*/
- public void determineTargetStates(final Set<TransitionTarget> states,
+ public Set<EnterableState> determineTargetStates(final Set<TransitionTarget> targets,
final ErrorReporter errRep, final SCInstance scInstance)
throws ModelException {
- LinkedList<TransitionTarget> wrkSet = new LinkedList<TransitionTarget>(states);
- // clear the seed-set - will be populated by leaf states
- states.clear();
+ LinkedList<TransitionTarget> wrkSet = new LinkedList<TransitionTarget>(targets);
+ Set<EnterableState> states = new HashSet<EnterableState>();
while (!wrkSet.isEmpty()) {
TransitionTarget tt = wrkSet.removeFirst();
- if (tt instanceof State) {
+ if (tt instanceof Final) {
+ states.add((Final)tt);
+ }
+ else if (tt instanceof State) {
State st = (State) tt;
- //state can either have parallel or substates w. initial
- //or it is a leaf state
- // NOTE: Digester has to verify this precondition!
if (st.isSimple()) {
states.add(st); //leaf
} else {
@@ -634,7 +615,7 @@ public class SCXMLSemanticsImpl implemen
Parallel prl = (Parallel) tt;
for (TransitionTarget kid : prl.getChildren()) {
//fork
- wrkSet.addLast(kid);
+ wrkSet.add(kid);
}
} else if (tt instanceof History) {
History h = (History) tt;
@@ -648,6 +629,7 @@ public class SCXMLSemanticsImpl implemen
+ tt.getClass().getName());
}
}
+ return states;
}
/**
@@ -663,40 +645,30 @@ public class SCXMLSemanticsImpl implemen
*/
public void updateHistoryStates(final Step step,
final ErrorReporter errRep, final SCInstance scInstance) {
- Set<TransitionTarget> oldStates = step.getBeforeStatus().getStates();
- for (TransitionTarget tt : step.getExitList()) {
- if (tt instanceof State || tt instanceof Parallel) {
- if (tt.hasHistory()) {
- Set<TransitionTarget> shallow = null;
- Set<TransitionTarget> deep = null;
- for (History h : tt.getHistory()) {
+ Set<EnterableState> oldStates = step.getBeforeStatus().getStates();
+ for (EnterableState es : step.getExitList()) {
+ if (es instanceof TransitionalState) {
+ TransitionalState ts = (TransitionalState)es;
+ if (ts.hasHistory()) {
+ Set<EnterableState> shallow = null;
+ Set<EnterableState> deep = null;
+ for (History h : ts.getHistory()) {
if (h.isDeep()) {
if (deep == null) {
//calculate deep history for a given state once
- deep = new HashSet<TransitionTarget>();
- for (TransitionTarget ott : oldStates) {
- State os = (State) ott;
- if (SCXMLHelper.isDescendant(os, tt)) {
- deep.add(os);
+ deep = new HashSet<EnterableState>();
+ for (EnterableState ott : oldStates) {
+ if (SCXMLHelper.isDescendant(ott, es)) {
+ deep.add(ott);
}
}
}
scInstance.setLastConfiguration(h, deep);
} else {
if (shallow == null) {
- //calculate shallow history for a given state
- // once
- shallow = new HashSet<TransitionTarget>();
- Collection<TransitionTarget> children;
- if (tt instanceof State) {
- children = ((State) tt).getChildren().
- values();
- } else { // (tt instanceof Parallel) {
- children = ((Parallel) tt).getChildren();
- }
- shallow.addAll(children);
- shallow.retainAll(SCXMLHelper
- .getAncestorClosure(oldStates, null));
+ //calculate shallow history for a given state once
+ shallow = new HashSet<EnterableState>(ts.getChildren());
+ shallow.retainAll(SCXMLHelper.getAncestorClosure(oldStates, null));
}
scInstance.setLastConfiguration(h, shallow);
}
@@ -720,36 +692,31 @@ public class SCXMLSemanticsImpl implemen
public void followTransitions(final Step step,
final ErrorReporter errorReporter, final SCInstance scInstance)
throws ModelException {
- Set<TransitionTarget> currentStates = step.getBeforeStatus().getStates();
+ Set<EnterableState> currentStates = step.getBeforeStatus().getStates();
List<Transition> transitions = step.getTransitList();
// DetermineExitedStates (currentStates, transitList) -> exitedStates
Set<TransitionTarget> exitedStates = new HashSet<TransitionTarget>();
for (Transition t : transitions) {
- Set<TransitionTarget> ext = SCXMLHelper.getStatesExited(t, currentStates);
- exitedStates.addAll(ext);
+ exitedStates.addAll(SCXMLHelper.getStatesExited(t, currentStates));
}
// compute residual states - these are preserved from the previous step
- Set<TransitionTarget> residual = new HashSet<TransitionTarget>(currentStates);
+ Set<EnterableState> residual = new HashSet<EnterableState>(currentStates);
residual.removeAll(exitedStates);
// SeedTargetSet (residual, transitList) -> seedSet
Set<TransitionTarget> seedSet = seedTargetSet(residual, transitions, errorReporter);
// DetermineTargetStates (initialTargetSet) -> targetSet
- Set<TransitionTarget> targetSet = step.getAfterStatus().getStates();
- targetSet.addAll(seedSet); //copy to preserve seedSet
- determineTargetStates(targetSet, errorReporter, scInstance);
+ Set<EnterableState> targetSet = step.getAfterStatus().getStates();
+ targetSet.addAll(determineTargetStates(seedSet, errorReporter, scInstance));
// BuildOnEntryList (targetSet, seedSet) -> entryList
- Set<TransitionTarget> entered = SCXMLHelper.getAncestorClosure(targetSet, seedSet);
+ Set<EnterableState> entered = SCXMLHelper.getAncestorClosure(targetSet, seedSet);
seedSet.clear();
for (Transition t : transitions) {
List<Path> paths = t.getPaths();
for (Path p : paths) {
- entered.addAll(p.getDownwardSegment());
- }
- // If target is a History pseudo state, remove from entered list
- List<TransitionTarget> rtargets = t.getRuntimeTargets();
- for (TransitionTarget tt : rtargets) {
- if (tt instanceof History) {
- entered.remove(tt);
+ for (TransitionTarget tt : p.getDownwardSegment()) {
+ if (tt instanceof EnterableState) {
+ entered.add((EnterableState)tt);
+ }
}
}
}
@@ -760,21 +727,15 @@ public class SCXMLSemanticsImpl implemen
throw new ModelException("Illegal state machine configuration!");
}
// sort onEntry and onExit according state hierarchy
- TransitionTarget[] oex = exitedStates.toArray(new TransitionTarget[exitedStates.size()]);
- exitedStates.clear();
- TransitionTarget[] oen = entered.toArray(new TransitionTarget[entered.size()]);
- entered.clear();
- Arrays.sort(oex, getTTComparator());
- Arrays.sort(oen, getTTComparator());
- step.getExitList().addAll(Arrays.asList(oex));
- // we need to impose reverse order for the onEntry list
- List<TransitionTarget> entering = Arrays.asList(oen);
- Collections.reverse(entering);
- step.getEntryList().addAll(entering);
- // reset 'done' flag
- for (TransitionTarget tt : entering) {
- if (tt instanceof State) {
- scInstance.setDone(tt, false);
+ for (TransitionTarget tt : exitedStates) {
+ step.getExitList().add((EnterableState)tt);
+ }
+ Collections.sort(step.getExitList(),DocumentOrder.documentOrderComparator);
+ step.getEntryList().addAll(entered);
+ Collections.sort(step.getEntryList(), DocumentOrder.reverseDocumentOrderComparator);
+ for (EnterableState es : step.getEntryList()) {
+ if (es instanceof State) {
+ scInstance.setDone(es, false);
}
}
}
@@ -796,7 +757,7 @@ public class SCXMLSemanticsImpl implemen
throws ModelException {
Set<TriggerEvent> allEvents = new HashSet<TriggerEvent>();
allEvents.addAll(Arrays.asList(events));
- for (Map.Entry<TransitionTarget, Invoker> iEntry : scInstance.getInvokers().entrySet()) {
+ for (Map.Entry<TransitionalState, Invoker> iEntry : scInstance.getInvokers().entrySet()) {
String parentId = iEntry.getKey().getId();
if (!finalizeMatch(parentId, allEvents)) { // prevent cycles
Invoker inv = iEntry.getValue();
@@ -824,85 +785,87 @@ public class SCXMLSemanticsImpl implemen
final SCInstance scInstance) {
Evaluator eval = scInstance.getEvaluator();
Collection<TriggerEvent> internalEvents = step.getAfterStatus().getEvents();
- for (TransitionTarget tt : step.getAfterStatus().getStates()) {
- State s = (State) tt;
- Context ctx = scInstance.getContext(s);
- Invoke i = s.getInvoke();
- if (i != null && scInstance.getInvoker(s) == null) {
- String src = i.getSrc();
- if (src == null) {
- String srcexpr = i.getSrcexpr();
- Object srcObj;
- try {
- ctx.setLocal(NAMESPACES_KEY, i.getNamespaces());
- srcObj = eval.eval(ctx, srcexpr);
- ctx.setLocal(NAMESPACES_KEY, null);
- src = String.valueOf(srcObj);
- } catch (SCXMLExpressionException see) {
- errRep.onError(ErrorConstants.EXPRESSION_ERROR,
- see.getMessage(), i);
- }
- }
- String source = src;
- PathResolver pr = i.getPathResolver();
- if (pr != null) {
- source = i.getPathResolver().resolvePath(src);
- }
- String type = i.getType();
- Invoker inv;
- try {
- inv = scInstance.newInvoker(type);
- } catch (InvokerException ie) {
- TriggerEvent te = new TriggerEvent(s.getId()
- + ".invoke.failed", TriggerEvent.ERROR_EVENT);
- internalEvents.add(te);
- continue;
- }
- inv.setParentStateId(s.getId());
- inv.setSCInstance(scInstance);
- List<Param> params = i.params();
- Map<String, Object> args = new HashMap<String, Object>();
- for (Param p : params) {
- String argExpr = p.getExpr();
- Object argValue = null;
- ctx.setLocal(NAMESPACES_KEY, p.getNamespaces());
- // Do we have an "expr" attribute?
- if (argExpr != null && argExpr.trim().length() > 0) {
+ for (EnterableState es : step.getAfterStatus().getStates()) {
+ if (es instanceof TransitionalState) {
+ TransitionalState ts = (TransitionalState) es;
+ Context ctx = scInstance.getContext(ts);
+ Invoke i = ts.getInvoke();
+ if (i != null && scInstance.getInvoker(ts) == null) {
+ String src = i.getSrc();
+ if (src == null) {
+ String srcexpr = i.getSrcexpr();
+ Object srcObj;
try {
- argValue = eval.eval(ctx, argExpr);
+ ctx.setLocal(NAMESPACES_KEY, i.getNamespaces());
+ srcObj = eval.eval(ctx, srcexpr);
+ ctx.setLocal(NAMESPACES_KEY, null);
+ src = String.valueOf(srcObj);
} catch (SCXMLExpressionException see) {
errRep.onError(ErrorConstants.EXPRESSION_ERROR,
- see.getMessage(), i);
+ see.getMessage(), i);
}
- } else {
- // No. Does value of "name" attribute refer to a valid
- // location in the data model?
- try {
- argValue = eval.evalLocation(ctx, p.getName());
- if (argValue == null) {
- // Generate error, 4.3.1 in WD-scxml-20080516
- TriggerEvent te = new TriggerEvent(s.getId()
- + ERR_ILLEGAL_ALLOC,
- TriggerEvent.ERROR_EVENT);
- internalEvents.add(te);
+ }
+ String source = src;
+ PathResolver pr = i.getPathResolver();
+ if (pr != null) {
+ source = i.getPathResolver().resolvePath(src);
+ }
+ String type = i.getType();
+ Invoker inv;
+ try {
+ inv = scInstance.newInvoker(type);
+ } catch (InvokerException ie) {
+ TriggerEvent te = new TriggerEvent(ts.getId()
+ + ".invoke.failed", TriggerEvent.ERROR_EVENT);
+ internalEvents.add(te);
+ continue;
+ }
+ inv.setParentStateId(ts.getId());
+ inv.setSCInstance(scInstance);
+ List<Param> params = i.params();
+ Map<String, Object> args = new HashMap<String, Object>();
+ for (Param p : params) {
+ String argExpr = p.getExpr();
+ Object argValue = null;
+ ctx.setLocal(NAMESPACES_KEY, p.getNamespaces());
+ // Do we have an "expr" attribute?
+ if (argExpr != null && argExpr.trim().length() > 0) {
+ try {
+ argValue = eval.eval(ctx, argExpr);
+ } catch (SCXMLExpressionException see) {
+ errRep.onError(ErrorConstants.EXPRESSION_ERROR,
+ see.getMessage(), i);
+ }
+ } else {
+ // No. Does value of "name" attribute refer to a valid
+ // location in the data model?
+ try {
+ argValue = eval.evalLocation(ctx, p.getName());
+ if (argValue == null) {
+ // Generate error, 4.3.1 in WD-scxml-20080516
+ TriggerEvent te = new TriggerEvent(ts.getId()
+ + ERR_ILLEGAL_ALLOC,
+ TriggerEvent.ERROR_EVENT);
+ internalEvents.add(te);
+ }
+ } catch (SCXMLExpressionException see) {
+ errRep.onError(ErrorConstants.EXPRESSION_ERROR,
+ see.getMessage(), i);
}
- } catch (SCXMLExpressionException see) {
- errRep.onError(ErrorConstants.EXPRESSION_ERROR,
- see.getMessage(), i);
}
+ ctx.setLocal(NAMESPACES_KEY, null);
+ args.put(p.getName(), argValue);
}
- ctx.setLocal(NAMESPACES_KEY, null);
- args.put(p.getName(), argValue);
- }
- try {
- inv.invoke(source, args);
- } catch (InvokerException ie) {
- TriggerEvent te = new TriggerEvent(s.getId()
- + ".invoke.failed", TriggerEvent.ERROR_EVENT);
- internalEvents.add(te);
- continue;
+ try {
+ inv.invoke(source, args);
+ } catch (InvokerException ie) {
+ TriggerEvent te = new TriggerEvent(ts.getId()
+ + ".invoke.failed", TriggerEvent.ERROR_EVENT);
+ internalEvents.add(te);
+ continue;
+ }
+ scInstance.setInvoker(ts, inv);
}
- scInstance.setInvoker(s, inv);
}
}
}
Modified: commons/proper/scxml/trunk/src/site/xdoc/guide/scxml-documents.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/site/xdoc/guide/scxml-documents.xml?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/site/xdoc/guide/scxml-documents.xml (original)
+++ commons/proper/scxml/trunk/src/site/xdoc/guide/scxml-documents.xml Sat Mar 22 23:34:20 2014
@@ -62,11 +62,11 @@
version="1.0"
initial="hello">
- <state id="hello" final="true">
+ <final id="hello">
<onentry>
<log expr="'hello world'" />
</onentry>
- </state>
+ </final>
</scxml>
</pre>
@@ -290,11 +290,11 @@
version="1.0"
initial="custom">
- <state id="custom" final="true">
+ <final id="custom">
<onentry>
<my:hello name="world" />
</onentry>
- </state>
+ </final>
</scxml>
</pre>
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/BuiltinTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/BuiltinTest.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/BuiltinTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/BuiltinTest.java Sat Mar 22 23:34:20 2014
@@ -19,8 +19,8 @@ package org.apache.commons.scxml2;
import java.util.HashSet;
import java.util.Set;
+import org.apache.commons.scxml2.model.EnterableState;
import org.apache.commons.scxml2.model.State;
-import org.apache.commons.scxml2.model.TransitionTarget;
import org.junit.Assert;
import org.junit.Test;
@@ -28,17 +28,17 @@ public class BuiltinTest {
@Test
public void testIsMemberEmptySet() {
- Set<TransitionTarget> set = new HashSet<TransitionTarget>();
+ Set<EnterableState> set = new HashSet<EnterableState>();
Assert.assertFalse(Builtin.isMember(set, "on"));
}
@Test
public void testIsMemberFalse() {
- TransitionTarget state = new State();
+ State state = new State();
state.setId("off");
-
- Set<TransitionTarget> set = new HashSet<TransitionTarget>();
+
+ Set<EnterableState> set = new HashSet<EnterableState>();
set.add(state);
Assert.assertFalse(Builtin.isMember(set, "on"));
@@ -46,10 +46,10 @@ public class BuiltinTest {
@Test
public void testIsMemberTrue() {
- TransitionTarget state = new State();
+ State state = new State();
state.setId("on");
-
- Set<TransitionTarget> set = new HashSet<TransitionTarget>();
+
+ Set<EnterableState> set = new HashSet<EnterableState>();
set.add(state);
Assert.assertTrue(Builtin.isMember(set, "on"));
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=1580369&r1=1580368&r2=1580369&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 Sat Mar 22 23:34:20 2014
@@ -22,8 +22,8 @@ import java.util.Set;
import org.apache.commons.scxml2.env.SimpleScheduler;
import org.apache.commons.scxml2.env.Tracer;
import org.apache.commons.scxml2.env.jexl.JexlEvaluator;
+import org.apache.commons.scxml2.model.EnterableState;
import org.apache.commons.scxml2.model.SCXML;
-import org.apache.commons.scxml2.model.TransitionTarget;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -68,7 +68,7 @@ public class EventDataTest {
public void testEventdata01Sample() throws Exception {
exec = SCXMLTestHelper.getExecutor(eventdata01);
Assert.assertNotNull(exec);
- Set<TransitionTarget> currentStates = exec.getCurrentStatus().getStates();
+ Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Assert.assertEquals(1, currentStates.size());
Assert.assertEquals("state1", currentStates.iterator().next().getId());
TriggerEvent te = new TriggerEvent("event.foo",
@@ -93,7 +93,7 @@ public class EventDataTest {
public void testEventdata02Sample() throws Exception {
exec = SCXMLTestHelper.getExecutor(eventdata02);
Assert.assertNotNull(exec);
- Set<TransitionTarget> currentStates = exec.getCurrentStatus().getStates();
+ Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Assert.assertEquals(1, currentStates.size());
Assert.assertEquals("state0", currentStates.iterator().next().getId());
TriggerEvent te1 = new TriggerEvent("connection.alerting",
@@ -113,7 +113,7 @@ public class EventDataTest {
public void testEventdata03Sample() throws Exception {
exec = SCXMLTestHelper.getExecutor(eventdata03);
Assert.assertNotNull(exec);
- Set<TransitionTarget> currentStates = exec.getCurrentStatus().getStates();
+ Set<EnterableState> currentStates = exec.getCurrentStatus().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=1580369&r1=1580368&r2=1580369&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 Sat Mar 22 23:34:20 2014
@@ -19,8 +19,7 @@ package org.apache.commons.scxml2;
import java.net.URL;
import java.util.Set;
-import org.apache.commons.scxml2.model.State;
-import org.apache.commons.scxml2.model.TransitionTarget;
+import org.apache.commons.scxml2.model.EnterableState;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -66,7 +65,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<TransitionTarget> currentStates = exec.getCurrentStatus().getStates();
+ Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Assert.assertEquals(1, currentStates.size());
Assert.assertEquals("ten", currentStates.iterator().next().getId());
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCInstanceTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCInstanceTest.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCInstanceTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCInstanceTest.java Sat Mar 22 23:34:20 2014
@@ -22,6 +22,7 @@ import java.util.Set;
import org.apache.commons.jexl2.JexlContext;
import org.apache.commons.scxml2.env.SimpleContext;
import org.apache.commons.scxml2.env.jexl.JexlEvaluator;
+import org.apache.commons.scxml2.model.EnterableState;
import org.apache.commons.scxml2.model.History;
import org.apache.commons.scxml2.model.State;
import org.apache.commons.scxml2.model.TransitionTarget;
@@ -63,7 +64,7 @@ public class SCInstanceTest {
@Test
public void testGetContext() {
- TransitionTarget target = new State();
+ State target = new State();
target.setId("1");
Context context = new SimpleContext();
@@ -76,7 +77,7 @@ public class SCInstanceTest {
@Test
public void testGetContextNullParent() {
- TransitionTarget target = new State();
+ State target = new State();
target.setId("1");
Context context = new SimpleContext();
@@ -92,7 +93,7 @@ public class SCInstanceTest {
@Test
public void testGetContextParent() {
- TransitionTarget target = new State();
+ State target = new State();
target.setId("1");
State parent = new State();
@@ -115,7 +116,7 @@ public class SCInstanceTest {
public void testGetLastConfigurationNull() {
History history = new History();
- Set<TransitionTarget> returnConfiguration = instance.getLastConfiguration(history);
+ Set<EnterableState> returnConfiguration = instance.getLastConfiguration(history);
Assert.assertEquals(0, returnConfiguration.size());
}
@@ -125,15 +126,15 @@ public class SCInstanceTest {
History history = new History();
history.setId("1");
- Set<TransitionTarget> configuration = new HashSet<TransitionTarget>();
- TransitionTarget tt1 = new State();
- TransitionTarget tt2 = new State();
+ Set<EnterableState> configuration = new HashSet<EnterableState>();
+ EnterableState tt1 = new State();
+ EnterableState tt2 = new State();
configuration.add(tt1);
configuration.add(tt2);
instance.setLastConfiguration(history, configuration);
- Set<TransitionTarget> returnConfiguration = instance.getLastConfiguration(history);
+ Set<EnterableState> returnConfiguration = instance.getLastConfiguration(history);
Assert.assertEquals(2, returnConfiguration.size());
Assert.assertTrue(returnConfiguration.contains(tt1));
@@ -150,8 +151,8 @@ public class SCInstanceTest {
History history = new History();
history.setId("1");
- Set<TransitionTarget> configuration = new HashSet<TransitionTarget>();
- TransitionTarget tt1 = new State();
+ Set<EnterableState> configuration = new HashSet<EnterableState>();
+ EnterableState tt1 = new State();
configuration.add(tt1);
instance.setLastConfiguration(history, configuration);
@@ -163,9 +164,9 @@ public class SCInstanceTest {
public void testReset() {
History history = new History();
history.setId("1");
-
- Set<TransitionTarget> configuration = new HashSet<TransitionTarget>();
- TransitionTarget tt1 = new State();
+
+ Set<EnterableState> configuration = new HashSet<EnterableState>();
+ EnterableState tt1 = new State();
configuration.add(tt1);
instance.setLastConfiguration(history, configuration);