Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 228B910C91 for ; Fri, 18 Apr 2014 12:01:27 +0000 (UTC) Received: (qmail 75696 invoked by uid 500); 18 Apr 2014 12:01:22 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 75448 invoked by uid 500); 18 Apr 2014 12:01:21 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 75441 invoked by uid 99); 18 Apr 2014 12:01:19 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Apr 2014 12:01:19 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Apr 2014 12:01:18 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id F0AAF2388AA7; Fri, 18 Apr 2014 12:00:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1588451 - in /commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2: SCInstance.java SCXMLExecutionContext.java Date: Fri, 18 Apr 2014 12:00:54 -0000 To: commits@commons.apache.org From: ate@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140418120054.F0AAF2388AA7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ate Date: Fri Apr 18 12:00:54 2014 New Revision: 1588451 URL: http://svn.apache.org/r1588451 Log: SCXML-202: move state machine running status management into SCInstance itself, thereby retaining this status after serializing/de-serializing Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCInstance.java commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutionContext.java Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCInstance.java URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCInstance.java?rev=1588451&r1=1588450&r2=1588451&view=diff ============================================================================== --- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCInstance.java (original) +++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCInstance.java Fri Apr 18 12:00:54 2014 @@ -77,6 +77,11 @@ public class SCInstance implements Seria private final Status currentStatus; /** + * Running status for this state machine + */ + private boolean running; + + /** * The SCXML I/O Processor for the internal event queue */ private transient SCXMLIOProcessor internalIOProcessor; @@ -136,6 +141,7 @@ public class SCInstance implements Seria * @throws ModelException if the state machine hasn't been setup for this instance */ protected void initialize() throws ModelException { + running = false; if (stateMachine == null) { throw new ModelException(ERR_NO_STATE_MACHINE); } @@ -293,6 +299,26 @@ public class SCInstance implements Seria return currentStatus; } + + /** + * @return Returns if the state machine is running + */ + public boolean isRunning() { + return running; + } + + /** + * Sets the running status of the state machine + * @param running flag indicating the running status of the state machine + * @throws IllegalStateException Exception thrown if trying to set the state machine running when in a Final state + */ + protected void setRunning(final boolean running) throws IllegalStateException { + if (!this.running && running && currentStatus.isFinal()) { + throw new IllegalStateException("The state machine is in a Final state and cannot be set running again"); + } + this.running = running; + } + /** * Get the root context. * 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=1588451&r1=1588450&r2=1588451&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 Fri Apr 18 12:00:54 2014 @@ -100,11 +100,6 @@ public class SCXMLExecutionContext imple private final Map invokers = new HashMap(); /** - * Running status for this state machine - */ - private boolean running; - - /** * Constructor * * @param externalIOProcessor The external IO Processor @@ -143,14 +138,14 @@ public class SCXMLExecutionContext imple * @return Returns true if this state machine is running */ public boolean isRunning() { - return running; + return scInstance.isRunning(); } /** * Stop a running state machine */ public void stopRunning() { - this.running = false; + scInstance.setRunning(false); } /** @@ -160,7 +155,6 @@ public class SCXMLExecutionContext imple * @throws ModelException if the state machine instance failed to initialize. */ public void initialize() throws ModelException { - running = false; if (!invokeIds.isEmpty()) { for (Invoke invoke : new ArrayList(invokeIds.keySet())) { cancelInvoker(invoke); @@ -168,7 +162,7 @@ public class SCXMLExecutionContext imple } internalEventQueue.clear(); scInstance.initialize(); - running = true; + scInstance.setRunning(true); } /** @@ -245,7 +239,6 @@ public class SCXMLExecutionContext imple } catch (ModelException me) { // won't happen - return; } } @@ -306,7 +299,6 @@ public class SCXMLExecutionContext imple } catch (ModelException me) { // should not happen - return; } } }