commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r561998 - in /commons/proper/scxml/trunk: ./ src/main/java/org/apache/commons/scxml/ src/main/java/org/apache/commons/scxml/semantics/ src/test/java/org/apache/commons/scxml/
Date Thu, 02 Aug 2007 02:32:21 GMT
Author: rahul
Date: Wed Aug  1 19:32:18 2007
New Revision: 561998

URL: http://svn.apache.org/viewvc?view=rev&rev=561998
Log:
Conflict resolution for conditionless stay transitions.
 * Stay transitions should have empty set of exit states
 * Since one transition must "win", by definition all candidate transitions are in conflict
with each other
Added a simplified version of test case provided by Ingmar Kliche to the test suite. Added
Ingmar to list of contributors.
SCXML-52

Added:
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-04.xml 
 (with props)
Modified:
    commons/proper/scxml/trunk/pom.xml
    commons/proper/scxml/trunk/project.xml
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLHelper.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/TieBreakerTest.java

Modified: commons/proper/scxml/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/pom.xml?view=diff&rev=561998&r1=561997&r2=561998
==============================================================================
--- commons/proper/scxml/trunk/pom.xml (original)
+++ commons/proper/scxml/trunk/pom.xml Wed Aug  1 19:32:18 2007
@@ -81,6 +81,9 @@
     <contributor>
       <name>Michael Heuer</name>
     </contributor>
+    <contributor>
+      <name>Ingmar Kliche</name>
+    </contributor>
   </contributors>
 
   <dependencies>

Modified: commons/proper/scxml/trunk/project.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/project.xml?view=diff&rev=561998&r1=561997&r2=561998
==============================================================================
--- commons/proper/scxml/trunk/project.xml (original)
+++ commons/proper/scxml/trunk/project.xml Wed Aug  1 19:32:18 2007
@@ -116,6 +116,9 @@
     <contributor>
       <name>Michael Heuer</name>
     </contributor>
+    <contributor>
+      <name>Ingmar Kliche</name>
+    </contributor>
   </contributors>
   
   <dependencies>

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLHelper.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLHelper.java?view=diff&rev=561998&r1=561997&r2=561998
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLHelper.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLHelper.java Wed
Aug  1 19:32:18 2007
@@ -228,6 +228,9 @@
     public static Set getStatesExited(final Transition t,
             final Set currentStates) {
         Set allStates = new HashSet();
+        if (t.getTargets().size() == 0) {
+            return allStates;
+        }
         Path p = (Path) t.getPaths().get(0); // all paths have same upseg
         //the easy part
         allStates.addAll(p.getUpwardSegment());

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java?view=diff&rev=561998&r1=561997&r2=561998
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java
(original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java
Wed Aug  1 19:32:18 2007
@@ -426,7 +426,6 @@
         if (step.getTransitList().size() > 1) {
             // global transition precedence check
             Object[] trans = step.getTransitList().toArray();
-            Set currentStates = step.getBeforeStatus().getStates();
             // non-determinism candidates
             Set nonDeterm = new LinkedHashSet();
             for (int i = 0; i < trans.length; i++) {
@@ -434,23 +433,18 @@
                 TransitionTarget tsrc = t.getParent();
                 for (int j = i + 1; j < trans.length; j++) {
                     Transition t2 = (Transition) trans[j];
-                    boolean conflict = SCXMLHelper.inConflict(t, t2,
-                            currentStates);
-                    if (conflict) {
-                        //potentially conflicting transitions
-                        TransitionTarget t2src = t2.getParent();
-                        if (SCXMLHelper.isDescendant(t2src, tsrc)) {
-                            //t2 takes precedence over t
-                            removeList.add(t);
-                            break; //it makes no sense to waste cycles with t
-                        } else if (SCXMLHelper.isDescendant(tsrc, t2src)) {
-                            //t takes precendence over t2
-                            removeList.add(t2);
-                        } else {
-                            //add both to the non-determinism candidates
-                            nonDeterm.add(t);
-                            nonDeterm.add(t2);
-                        }
+                    TransitionTarget t2src = t2.getParent();
+                    if (SCXMLHelper.isDescendant(t2src, tsrc)) {
+                        //t2 takes precedence over t
+                        removeList.add(t);
+                        break; //it makes no sense to waste cycles with t
+                    } else if (SCXMLHelper.isDescendant(tsrc, t2src)) {
+                        //t takes precendence over t2
+                        removeList.add(t2);
+                    } else {
+                        //add both to the non-determinism candidates
+                        nonDeterm.add(t);
+                        nonDeterm.add(t2);
                     }
                 }
             }

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/TieBreakerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/TieBreakerTest.java?view=diff&rev=561998&r1=561997&r2=561998
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/TieBreakerTest.java
(original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/TieBreakerTest.java
Wed Aug  1 19:32:18 2007
@@ -53,7 +53,7 @@
     }
 
     // Test data
-    private URL tiebreaker01, tiebreaker02, tiebreaker03;
+    private URL tiebreaker01, tiebreaker02, tiebreaker03, tiebreaker04;
     private SCXMLExecutor exec;
 
     /**
@@ -66,13 +66,15 @@
             getResource("org/apache/commons/scxml/tie-breaker-02.xml");
         tiebreaker03 = this.getClass().getClassLoader().
             getResource("org/apache/commons/scxml/tie-breaker-03.xml");
+        tiebreaker04 = this.getClass().getClassLoader().
+            getResource("org/apache/commons/scxml/tie-breaker-04.xml");
     }
 
     /**
      * Tear down instance variables required by this test case.
      */
     public void tearDown() {
-        tiebreaker01 = tiebreaker02 = tiebreaker03 = null;
+        tiebreaker01 = tiebreaker02 = tiebreaker03 = tiebreaker04 = null;
     }
 
     /**
@@ -115,6 +117,15 @@
         assertEquals(1, currentStates.size());
         assertEquals("forty", ((State)currentStates.iterator().
             next()).getId());
+    }
+
+    public void testTieBreaker04() {
+        exec = SCXMLTestHelper.getExecutor(tiebreaker04);
+        assertNotNull(exec);
+        Set currentStates = SCXMLTestHelper.fireEvent(exec, "event_2");
+        assertEquals(1, currentStates.size());
+        currentStates = SCXMLTestHelper.fireEvent(exec, "event_1");
+        assertEquals(1, currentStates.size());
     }
 
     public static void main(String args[]) {

Added: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-04.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-04.xml?view=auto&rev=561998
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-04.xml (added)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-04.xml Wed
Aug  1 19:32:18 2007
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<!--
+ * 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.
+-->
+<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initialstate="s1"> 
+     
+    <state id="s1"> 
+        <initial> 
+            <transition target="s11"/> 
+        </initial> 
+         
+        <transition event="event_1"/>
+        
+        <transition event="event_2" target="s1"/>
+         
+        <state id="s11"> 
+            <transition event="event_1"/>
+            <transition event="event_2" target="s11"/>
+        </state> 
+    </state> 
+     
+    <state id="s2" final="true" /> 
+</scxml> 

Propchange: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-04.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-04.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL



Mime
View raw message