Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: src/main/java/org/apache/commons/scxml2/SCXMLExecutionContext.java
- ===================================================================
- --- src/main/java/org/apache/commons/scxml2/SCXMLExecutionContext.java (Revision 1658973)
- +++ src/main/java/org/apache/commons/scxml2/SCXMLExecutionContext.java (Arbeitskopie)
- @@ -431,6 +431,8 @@
- }
- invokeIds.put(invoke, invokeId);
- invokers.put(invokeId, invoker);
- + ioProcessors.put(String.format(CHILD_IOPROCESSOR_PATTERN, invokeId), invoker.getChildIOProcessor());
- + initializeIOProcessors();
- }
- /**
- @@ -439,6 +441,8 @@
- */
- public void removeInvoker(final Invoke invoke) {
- invokers.remove(invokeIds.remove(invoke));
- + ioProcessors.remove(String.format(CHILD_IOPROCESSOR_PATTERN, invoke.getId()));
- + initializeIOProcessors();
- }
- /**
- @@ -468,6 +472,18 @@
- }
- /**
- + * Allow registering of the parent IO processor if we are being executed
- + * from an invoke instance.
- + *
- + * @param parentIOProcessor The IOProcessor of the parent instance.
- + */
- + public void registerParentIOProcessor(SCXMLIOProcessor parentIOProcessor) {
- + appLog.info("Registering " + SCXML_PARENT_EVENT_PROCESSOR + ": " + parentIOProcessor);
- + ioProcessors.put(SCXML_PARENT_EVENT_PROCESSOR, parentIOProcessor);
- + initializeIOProcessors();
- + }
- +
- + /**
- * Add an event to the internal event queue
- * @param event The event
- */
- Index: src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java
- ===================================================================
- --- src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java (Revision 1658973)
- +++ src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java (Arbeitskopie)
- @@ -323,6 +323,16 @@
- public void unregisterInvokerClass(final String type) {
- exctx.unregisterInvokerClass(type);
- }
- +
- + /**
- + * Register the parent IO Processor, done by the Invoker constructing this instance
- + * to allow communication to the special target #_parent
- + *
- + * @param parentIOProcessor The IOProcessor of the parent instance.
- + */
- + public void registerParentIOProcessor(SCXMLIOProcessor parentIOProcessor) {
- + exctx.registerParentIOProcessor(parentIOProcessor);
- + }
- /**
- * Detach the current SCInstance to allow external serialization.
- Index: src/main/java/org/apache/commons/scxml2/SCXMLIOProcessor.java
- ===================================================================
- --- src/main/java/org/apache/commons/scxml2/SCXMLIOProcessor.java (Revision 1658973)
- +++ src/main/java/org/apache/commons/scxml2/SCXMLIOProcessor.java (Arbeitskopie)
- @@ -31,6 +31,16 @@
- * Default SCXML I/O Event Processor alias
- */
- String SCXML_EVENT_PROCESSOR = "scxml";
- +
- + /**
- + * Default SCXML I/O Event Processor alias
- + */
- + String SCXML_PARENT_EVENT_PROCESSOR = "#_parent";
- +
- + /**
- + * Pattern to construct the IOProcessor key for child instances
- + */
- + String CHILD_IOPROCESSOR_PATTERN = "#_%s";
- /**
- * The name of the internal Event Processor
- Index: src/main/java/org/apache/commons/scxml2/env/SimpleDispatcher.java
- ===================================================================
- --- src/main/java/org/apache/commons/scxml2/env/SimpleDispatcher.java (Revision 1658973)
- +++ src/main/java/org/apache/commons/scxml2/env/SimpleDispatcher.java (Arbeitskopie)
- @@ -185,13 +185,15 @@
- SCXMLIOProcessor ioProcessor;
- boolean internal = false;
- +
- + log.info("Available ioProcessors: " + ioProcessors);
- if (target == null) {
- ioProcessor = ioProcessors.get(SCXMLIOProcessor.SCXML_EVENT_PROCESSOR);
- }
- - else if (SCXMLIOProcessor.INTERNAL_EVENT_PROCESSOR.equals(target)) {
- - ioProcessor = ioProcessors.get(SCXMLIOProcessor.INTERNAL_EVENT_PROCESSOR);
- - internal = true;
- + else if (ioProcessors.containsKey(target)) {
- + ioProcessor = ioProcessors.get(target);
- + internal = SCXMLIOProcessor.INTERNAL_EVENT_PROCESSOR.equals(target);
- }
- else {
- // We know of no other target
- Index: src/main/java/org/apache/commons/scxml2/invoke/Invoker.java
- ===================================================================
- --- src/main/java/org/apache/commons/scxml2/invoke/Invoker.java (Revision 1658973)
- +++ src/main/java/org/apache/commons/scxml2/invoke/Invoker.java (Arbeitskopie)
- @@ -89,6 +89,14 @@
- * @param parentIOProcessor The I/O Processor of the parent state machine.
- */
- void setParentIOProcessor(SCXMLIOProcessor parentIOProcessor);
- +
- + /**
- + * Get the child IO Processor to register for communication with
- + * the parent session.
- + *
- + * @return Child IO Processor
- + */
- + SCXMLIOProcessor getChildIOProcessor();
- /**
- * Set the Evaluator to be used by the child state machine (to ensure/enforce a compatible data model)
- Index: src/main/java/org/apache/commons/scxml2/invoke/SimpleSCXMLInvoker.java
- ===================================================================
- --- src/main/java/org/apache/commons/scxml2/invoke/SimpleSCXMLInvoker.java (Revision 1658973)
- +++ src/main/java/org/apache/commons/scxml2/invoke/SimpleSCXMLInvoker.java (Arbeitskopie)
- @@ -113,6 +113,7 @@
- }
- executor.addListener(scxml, new SimpleSCXMLListener());
- executor.registerInvokerClass("scxml", this.getClass());
- + executor.registerParentIOProcessor(parentIOProcessor);
- try {
- executor.go();
- } catch (ModelException me) {
- @@ -149,5 +150,9 @@
- executor.addEvent(new TriggerEvent("cancel.invoke."+parentStateId, TriggerEvent.CANCEL_EVENT));
- }
- -}
- -
- + @Override
- + public SCXMLIOProcessor getChildIOProcessor() {
- + return executor;
- + }
- +
- +}
- \ No newline at end of file
- Index: src/test/java/org/apache/commons/scxml2/invoke/InvokeParamNameTest.java
- ===================================================================
- --- src/test/java/org/apache/commons/scxml2/invoke/InvokeParamNameTest.java (Revision 1658973)
- +++ src/test/java/org/apache/commons/scxml2/invoke/InvokeParamNameTest.java (Arbeitskopie)
- @@ -121,6 +121,11 @@
- public void setParentIOProcessor(SCXMLIOProcessor parentIOProcessor) {
- // Not needed
- }
- +
- + @Override
- + public SCXMLIOProcessor getChildIOProcessor() {
- + return null;
- + }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement