commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r1554895 - in /commons/proper/scxml/trunk/src: main/java/org/apache/commons/scxml2/SCXMLExecutor.java main/java/org/apache/commons/scxml2/system/EventVariable.java test/java/org/apache/commons/scxml2/transitions-event-variable.xml
Date Thu, 02 Jan 2014 20:14:13 GMT
Author: woonsan
Date: Thu Jan  2 20:14:13 2014
New Revision: 1554895

URL: http://svn.apache.org/r1554895
Log:
SCXML-100: correcting _event variable properties. e.g, _event.invokeId -> _event.invokeid.
Also, set 'platform' for error|change trigger events and set 'external' for others based on
the spec 5.10.1.

Modified:
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/system/EventVariable.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/transitions-event-variable.xml

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java?rev=1554895&r1=1554894&r2=1554895&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java
(original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java
Thu Jan  2 20:14:13 2014
@@ -509,8 +509,22 @@ public class SCXMLExecutor implements Se
             if (len == 1) {
                 // we have only one event
                 eventData = evts[0].getPayload();
-                // TODO: determine type, sendid, origin, originType and invokeid based on
context.
-                eventVar = new EventVariable(evts[0].getName(), EventVariable.TYPE_INTERNAL,
null, null, null, null, eventData);
+
+                // NOTE: According to spec 5.10.1, _event.type must be 'platform', 'internal'
or 'external'.
+                //       So, error or variable change trigger events can be translated into
'platform' type event variables.
+                //       However, the Send model for <send> element doesn't support
any target yet, and so
+                //       'internal' type can't supported either.
+                //       All the others must be 'external'.
+
+                String eventType = EventVariable.TYPE_EXTERNAL;
+                final int triggerEventType = evts[0].getType();
+
+                if (triggerEventType == TriggerEvent.ERROR_EVENT || triggerEventType == TriggerEvent.CHANGE_EVENT)
{
+                    eventType = EventVariable.TYPE_PLATFORM;
+                }
+
+                // TODO: determine sendid, origin, originType and invokeid based on context
later.
+                eventVar = new EventVariable(evts[0].getName(), eventType, null, null, null,
null, eventData);
             }
             rootCtx.setLocal(EVENT_DATA, eventData);
             rootCtx.setLocal(EVENT_DATA_MAP, payloadMap);

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/system/EventVariable.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/system/EventVariable.java?rev=1554895&r1=1554894&r2=1554895&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/system/EventVariable.java
(original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/system/EventVariable.java
Thu Jan  2 20:14:13 2014
@@ -55,25 +55,25 @@ public class EventVariable implements Se
     /**
      * The type in an external event.
      */
-    private final String originType;
+    private final String origintype;
 
     /**
      * The invoke id of the invocation that triggered the child process.
      */
-    private final String invokeId;
+    private final String invokeid;
 
     /**
      * Whatever data the sending entity chose to include in the event
      */
     private final Object data;
 
-    public EventVariable(final String name, final String type, final String sendid, final
String origin, final String originType, final String invokeId, final Object data) {
+    public EventVariable(final String name, final String type, final String sendid, final
String origin, final String origintype, final String invokeid, final Object data) {
         this.name = name;
         this.type = type;
         this.sendid = sendid;
         this.origin = origin;
-        this.originType = originType;
-        this.invokeId = invokeId;
+        this.origintype = origintype;
+        this.invokeid = invokeid;
         this.data = data;
     }
 
@@ -93,12 +93,12 @@ public class EventVariable implements Se
         return origin;
     }
 
-    public String getOriginType() {
-        return originType;
+    public String getOrigintype() {
+        return origintype;
     }
 
-    public String getInvokeId() {
-        return invokeId;
+    public String getInvokeid() {
+        return invokeid;
     }
 
     public Object getData() {

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/transitions-event-variable.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/transitions-event-variable.xml?rev=1554895&r1=1554894&r2=1554895&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/transitions-event-variable.xml
(original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/transitions-event-variable.xml
Thu Jan  2 20:14:13 2014
@@ -23,7 +23,7 @@
        initial="closed">
 
   <state id="closed">
-    <transition event="open" cond="_event.name == 'open' and _event.type == 'internal'
and _event.data['keyed']" target="opened" />
+    <transition event="open" cond="_event.name == 'open' and _event.data['keyed']" target="opened"
/>
   </state>
 
   <state id="opened">



Mime
View raw message