You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ra...@apache.org on 2008/06/18 00:03:26 UTC

svn commit: r668848 - in /commons/proper/scxml/trunk: pom.xml project.xml src/main/java/org/apache/commons/scxml/model/Send.java src/test/java/org/apache/commons/scxml/model/actions-test.xml src/test/java/org/apache/commons/scxml/send-01.xml

Author: rahul
Date: Tue Jun 17 15:03:26 2008
New Revision: 668848

URL: http://svn.apache.org/viewvc?rev=668848&view=rev
Log:
The "delay" attribute of the <send> element is a value expression.
Thanks to Elaine Wong <wongkl AT ihpc DOT a-star DOT edu DOT sg>.
Also added Elaine to list of contributors.
SCXML-73

Modified:
    commons/proper/scxml/trunk/pom.xml
    commons/proper/scxml/trunk/project.xml
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Send.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/actions-test.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/send-01.xml

Modified: commons/proper/scxml/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/pom.xml?rev=668848&r1=668847&r2=668848&view=diff
==============================================================================
--- commons/proper/scxml/trunk/pom.xml (original)
+++ commons/proper/scxml/trunk/pom.xml Tue Jun 17 15:03:26 2008
@@ -105,6 +105,9 @@
     <contributor>
       <name>Tony Seebregts</name>
     </contributor>
+    <contributor>
+      <name>Elaine Wong</name>
+    </contributor>
   </contributors>
 
   <dependencies>

Modified: commons/proper/scxml/trunk/project.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/project.xml?rev=668848&r1=668847&r2=668848&view=diff
==============================================================================
--- commons/proper/scxml/trunk/project.xml (original)
+++ commons/proper/scxml/trunk/project.xml Tue Jun 17 15:03:26 2008
@@ -152,6 +152,9 @@
     <contributor>
       <name>Tony Seebregts</name>
     </contributor>
+    <contributor>
+      <name>Elaine Wong</name>
+    </contributor>
   </contributors>
   
   <dependencies>

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Send.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Send.java?rev=668848&r1=668847&r2=668848&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Send.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Send.java Tue Jun 17 15:03:26 2008
@@ -316,7 +316,14 @@
                 params.put(varName, varObj);
             }
         }
-        long wait = parseDelay(appLog);
+        long wait = 0L;
+        if (!SCXMLHelper.isStringEmpty(delay)) {
+            Object delayValue = eval.eval(ctx, delay);
+            if (delayValue != null) {
+                String delayString = delayValue.toString();
+                wait = parseDelay(delayString, appLog);
+            }
+        }
         // Lets see if we should handle it ourselves
         if (targettypeValue != null
               && targettypeValue.trim().equalsIgnoreCase(TARGETTYPE_SCXML)) {
@@ -359,26 +366,27 @@
     /**
      * Parse delay.
      *
+     * @param delayString The String value of the delay, in CSS2 format
      * @param appLog The application log
      * @return The parsed delay in milliseconds
      * @throws SCXMLExpressionException If the delay cannot be parsed
      */
-    private long parseDelay(final Log appLog)
+    private long parseDelay(final String delayString, final Log appLog)
     throws SCXMLExpressionException {
 
         long wait = 0L;
         long multiplier = 1L;
 
-        if (!SCXMLHelper.isStringEmpty(delay)) {
+        if (!SCXMLHelper.isStringEmpty(delayString)) {
 
-            String trimDelay = delay.trim();
+            String trimDelay = delayString.trim();
             String numericDelay = trimDelay;
             if (trimDelay.endsWith(MILLIS)) {
                 numericDelay = trimDelay.substring(0, trimDelay.length() - 2);
             } else if (trimDelay.endsWith(SECONDS)) {
                 multiplier = MILLIS_IN_A_SECOND;
                 numericDelay = trimDelay.substring(0, trimDelay.length() - 1);
-            } else if (trimDelay.endsWith(MINUTES)) {
+            } else if (trimDelay.endsWith(MINUTES)) { // Not CSS2
                 multiplier = MILLIS_IN_A_MINUTE;
                 numericDelay = trimDelay.substring(0, trimDelay.length() - 1);
             }

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/actions-test.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/actions-test.xml?rev=668848&r1=668847&r2=668848&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/actions-test.xml (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/actions-test.xml Tue Jun 17 15:03:26 2008
@@ -36,7 +36,7 @@
       <cs:var name="eat" expr="flies" />
       <send sendid="send12345" target="freddy" targettype="frog"
        event="croak" namelist="drink eat" hints="h2o bzz"
-       delay="1000" />
+       delay="${1000+500}" />
       <cancel sendId="send12345"/>
       <log expr="leaving" label="entry001" />
       <event name="event.test"/>

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/send-01.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/send-01.xml?rev=668848&r1=668847&r2=668848&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/send-01.xml (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/send-01.xml Tue Jun 17 15:03:26 2008
@@ -21,7 +21,7 @@
 
     <state id="ten">
         <transition event="ten.done" target="twenty">
-            <send sendid="send1" delay="0"
+            <send sendid="send1" delay="'0'"
              target="'http://localhost:8080/VXMLInterpreter'" targettype="'v3'"
              xmlns:v3="http://foo.bar.com/vxml3"
              xmlns:test="http://my.test.namespace">