commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r668850 - in /commons/proper/scxml/branches/J6: 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
Date Tue, 17 Jun 2008 22:06:27 GMT
Author: rahul
Date: Tue Jun 17 15:06:26 2008
New Revision: 668850

URL: http://svn.apache.org/viewvc?rev=668850&view=rev
Log:
Port r668848 from trunk.
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/branches/J6/pom.xml
    commons/proper/scxml/branches/J6/project.xml
    commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/model/Send.java
    commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/actions-test.xml
    commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/send-01.xml

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

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

Modified: commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/model/Send.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/model/Send.java?rev=668850&r1=668849&r2=668850&view=diff
==============================================================================
--- commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/model/Send.java
(original)
+++ commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/model/Send.java
Tue Jun 17 15:06:26 2008
@@ -318,7 +318,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)) {
@@ -361,26 +368,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/branches/J6/src/test/java/org/apache/commons/scxml/model/actions-test.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/actions-test.xml?rev=668850&r1=668849&r2=668850&view=diff
==============================================================================
--- commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/actions-test.xml
(original)
+++ commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/actions-test.xml
Tue Jun 17 15:06: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/branches/J6/src/test/java/org/apache/commons/scxml/send-01.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/send-01.xml?rev=668850&r1=668849&r2=668850&view=diff
==============================================================================
--- commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/send-01.xml (original)
+++ commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/send-01.xml Tue
Jun 17 15:06: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">



Mime
View raw message