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 2015/02/12 02:05:41 UTC

svn commit: r1659114 - in /commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2: SCXMLExecutionContext.java SCXMLIOProcessor.java invoke/Invoker.java invoke/SimpleSCXMLInvoker.java

Author: ate
Date: Thu Feb 12 01:05:40 2015
New Revision: 1659114

URL: http://svn.apache.org/r1659114
Log:
SCXML-226: Support of special send targets #_parent and #_invokeid
- support for #_invokeid, based upon a patch contributed by Michael Goerlich

Modified:
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutionContext.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLIOProcessor.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/invoke/Invoker.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/invoke/SimpleSCXMLInvoker.java

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutionContext.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutionContext.java?rev=1659114&r1=1659113&r2=1659114&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutionContext.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutionContext.java Thu Feb 12 01:05:40 2015
@@ -456,6 +456,8 @@ public class SCXMLExecutionContext imple
         }
         invokeIds.put(invoke, invokeId);
         invokers.put(invokeId, invoker);
+        ioProcessors.put(SCXMLIOProcessor.EVENT_PROCESSOR_ALIAS_PREFIX+invoke.getId(), invoker.getChildIOProcessor());
+        initializeIOProcessors();
     }
 
     /**
@@ -464,6 +466,8 @@ public class SCXMLExecutionContext imple
      */
     public void removeInvoker(final Invoke invoke) {
         invokers.remove(invokeIds.remove(invoke));
+        ioProcessors.remove(SCXMLIOProcessor.EVENT_PROCESSOR_ALIAS_PREFIX+invoke.getId());
+        initializeIOProcessors();
     }
 
     /**

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLIOProcessor.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLIOProcessor.java?rev=1659114&r1=1659113&r2=1659114&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLIOProcessor.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLIOProcessor.java Thu Feb 12 01:05:40 2015
@@ -28,6 +28,11 @@ public interface SCXMLIOProcessor {
     String DEFAULT_EVENT_PROCESSOR = "http://www.w3.org/TR/scxml/#SCXMLEventProcessor";
 
     /**
+     * Prefix for SCXML I/O Event Processor aliases
+     */
+    String EVENT_PROCESSOR_ALIAS_PREFIX = "#_";
+
+    /**
      * Default SCXML I/O Event Processor alias
      */
     String SCXML_EVENT_PROCESSOR = "scxml";
@@ -35,12 +40,12 @@ public interface SCXMLIOProcessor {
     /**
      * The name of the internal Event Processor
      */
-    String INTERNAL_EVENT_PROCESSOR = "#_internal";
+    String INTERNAL_EVENT_PROCESSOR = EVENT_PROCESSOR_ALIAS_PREFIX + "internal";
 
     /**
      * The name of the parent Event Processor
      */
-    String PARENT_EVENT_PROCESSOR = "#_parent";
+    String PARENT_EVENT_PROCESSOR = EVENT_PROCESSOR_ALIAS_PREFIX + "parent";
 
     /**
      * Send an event into the SCXML processor queue

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/invoke/Invoker.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/invoke/Invoker.java?rev=1659114&r1=1659113&r2=1659114&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/invoke/Invoker.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/invoke/Invoker.java Thu Feb 12 01:05:40 2015
@@ -19,6 +19,7 @@ package org.apache.commons.scxml2.invoke
 import java.util.Map;
 
 import org.apache.commons.scxml2.SCXMLExecutor;
+import org.apache.commons.scxml2.SCXMLIOProcessor;
 import org.apache.commons.scxml2.TriggerEvent;
 
 /**
@@ -88,6 +89,14 @@ public interface Invoker {
     void setParentSCXMLExecutor(SCXMLExecutor scxmlExecutor);
 
     /**
+     * Get the child IO Processor to register for communication with
+     * the parent session.
+     *
+     * @return Child IO Processor
+     */
+    SCXMLIOProcessor getChildIOProcessor();
+
+    /**
      * Begin this invocation.
      *
      * @param source The source URI of the activity being invoked.
@@ -121,6 +130,5 @@ public interface Invoker {
      */
     void cancel()
     throws InvokerException;
-
 }
 

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/invoke/SimpleSCXMLInvoker.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/invoke/SimpleSCXMLInvoker.java?rev=1659114&r1=1659113&r2=1659114&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/invoke/SimpleSCXMLInvoker.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/invoke/SimpleSCXMLInvoker.java Thu Feb 12 01:05:40 2015
@@ -25,6 +25,7 @@ import javax.xml.stream.XMLStreamExcepti
 
 import org.apache.commons.scxml2.Context;
 import org.apache.commons.scxml2.SCXMLExecutor;
+import org.apache.commons.scxml2.SCXMLIOProcessor;
 import org.apache.commons.scxml2.TriggerEvent;
 import org.apache.commons.scxml2.env.SimpleSCXMLListener;
 import org.apache.commons.scxml2.io.SCXMLReader;
@@ -52,6 +53,7 @@ public class SimpleSCXMLInvoker implemen
     /**
      * {@inheritDoc}.
      */
+    @Override
     public String getInvokeId() {
         return parentStateId;
     }
@@ -59,6 +61,7 @@ public class SimpleSCXMLInvoker implemen
     /**
      * {@inheritDoc}.
      */
+    @Override
     public void setInvokeId(final String invokeId) {
         this.parentStateId = invokeId;
         this.cancelled = false;
@@ -67,6 +70,7 @@ public class SimpleSCXMLInvoker implemen
     /**
      * {@inheritDoc}.
      */
+    @Override
     public void setParentSCXMLExecutor(SCXMLExecutor parentSCXMLExecutor) {
         this.parentSCXMLExecutor = parentSCXMLExecutor;
     }
@@ -74,6 +78,16 @@ public class SimpleSCXMLInvoker implemen
     /**
      * {@inheritDoc}.
      */
+    @Override
+    public SCXMLIOProcessor getChildIOProcessor() {
+        // not used
+        return executor;
+    }
+
+    /**
+     * {@inheritDoc}.
+     */
+    @Override
     public void invoke(final String source, final Map<String, Object> params)
     throws InvokerException {
         SCXML scxml;
@@ -112,6 +126,7 @@ public class SimpleSCXMLInvoker implemen
     /**
      * {@inheritDoc}.
      */
+    @Override
     public void parentEvent(final TriggerEvent evt)
     throws InvokerException {
         if (cancelled) {
@@ -128,11 +143,11 @@ public class SimpleSCXMLInvoker implemen
     /**
      * {@inheritDoc}.
      */
+    @Override
     public void cancel()
     throws InvokerException {
         cancelled = true;
         executor.addEvent(new TriggerEvent("cancel.invoke."+parentStateId, TriggerEvent.CANCEL_EVENT));
     }
-
 }