Author: ate
Date: Thu Feb 12 01:41:40 2015
New Revision: 1659122

URL: http://svn.apache.org/r1659122
Log:
SCXML-226: Support of special send target #_scxml_sessionid

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

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=1659122&r1=1659121&r2=1659122&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:41:40 2015
@@ -125,6 +125,11 @@ public class SCXMLExecutionContext imple
     private boolean checkLegalConfiguration = true;
 
     /**
+     * Local cache of the SCInstance sessionId, to be able to check against 
clear/reinitialization
+     */
+    private String sessionId;
+
+    /**
      * Constructor
      *
      * @param scxmlExecutor The SCXMLExecutor of this SCXMLExecutionContext
@@ -340,6 +345,16 @@ public class SCXMLExecutionContext imple
      */
     protected void initializeIOProcessors() {
         if (scInstance.getEvaluator() != null) {
+            // lazy register/reset #_scxml_sessionId event target
+            String currentSessionId = 
(String)getScInstance().getSystemContext().get(SCXMLSystemContext.SESSIONID_KEY);
+            if (sessionId != null && !sessionId.equals(currentSessionId)) {
+                // remove possible old/stale #_scxml_sessionId target
+                
ioProcessors.remove(SCXMLIOProcessor.SCXML_SESSION_EVENT_PROCESSOR_PREFIX+sessionId);
+            }
+            sessionId = currentSessionId;
+            if 
(!ioProcessors.containsKey(SCXMLIOProcessor.SCXML_SESSION_EVENT_PROCESSOR_PREFIX+sessionId))
 {
+                
ioProcessors.put(SCXMLIOProcessor.SCXML_SESSION_EVENT_PROCESSOR_PREFIX+sessionId,
 getExternalIOProcessor());
+            }
             
getScInstance().getSystemContext().setLocal(SCXMLSystemContext.IOPROCESSORS_KEY,
 Collections.unmodifiableMap(ioProcessors));
         }
     }

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=1659122&r1=1659121&r2=1659122&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:41:40 2015
@@ -38,6 +38,11 @@ public interface SCXMLIOProcessor {
     String SCXML_EVENT_PROCESSOR = "scxml";
 
     /**
+     * Prefix for SCXML I/O (own) Session external Event processor
+     */
+    String SCXML_SESSION_EVENT_PROCESSOR_PREFIX = EVENT_PROCESSOR_ALIAS_PREFIX 
+ "scxml_";
+
+    /**
      * The name of the internal Event Processor
      */
     String INTERNAL_EVENT_PROCESSOR = EVENT_PROCESSOR_ALIAS_PREFIX + 
"internal";


Reply via email to