Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 14648 invoked from network); 19 Apr 2008 00:13:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Apr 2008 00:13:07 -0000 Received: (qmail 37152 invoked by uid 500); 19 Apr 2008 00:13:04 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 37083 invoked by uid 500); 19 Apr 2008 00:13:04 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 37074 invoked by uid 99); 19 Apr 2008 00:13:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Apr 2008 17:13:04 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of rahul.akolkar@gmail.com designates 72.14.220.152 as permitted sender) Received: from [72.14.220.152] (HELO fg-out-1718.google.com) (72.14.220.152) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Apr 2008 00:12:21 +0000 Received: by fg-out-1718.google.com with SMTP id 22so680503fge.24 for ; Fri, 18 Apr 2008 17:12:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=kS1oHc1v3otW3uTapgrTfVwMdcAZZwKc+5QzsfuyC3o=; b=gnPWyjP76AetD+6egdaK0eWGE29NFVyjI0NDy7HNrxHXsEFNhEMLiWH+Ko5EPodCxY50ZFxK5VPRrm/KQvlIshe3hHFTfnzlRMoDyh49wiWnpV/LBCNdRM+/mbRf06+O3rDjgmdCPqrcMINFgJEI6QWrMjjlAFw3S6AK925p+SU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Smp5UBE7wnRcwE0Txdx/gaSQ16+wQmfUNS64dMSUfjhCP3lUdJdHuTIfGPruZbAacfLdsB0JYYe6UEdlbC8uhGD7/4k8wi5GdXp9mGV7Socv3lXPqMmEUYmisFFS+MhE6mE3Ae2zQHBbQ0LUTonqoYjTnGWjAOJZSFRpECKByxw= Received: by 10.82.171.16 with SMTP id t16mr582604bue.55.1208563952656; Fri, 18 Apr 2008 17:12:32 -0700 (PDT) Received: by 10.82.140.18 with HTTP; Fri, 18 Apr 2008 17:12:32 -0700 (PDT) Message-ID: Date: Fri, 18 Apr 2008 20:12:32 -0400 From: "Rahul Akolkar" To: "Jakarta Commons Users List" Subject: Re: [SCXML] State transitions from within handler In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-Virus-Checked: Checked by ClamAV on apache.org On 4/17/08, Ouyang, Landon - ES/RDR -Gil wrote: > Hi Rahul, > > Thanks for your informative response. > > Using your suggestions I created my own state machine class that did not > utilize a listener. I overwrote the Initialize() and fireEvent() > routines to invoke the state methods and utilize an event stack to > process external events. > > The only issue with my implementation is that an event must be fired for > a state method to be invoked. For example, if we make state 4 > automatically (unconditionally) transition to state 5 in the SCXML file, > state5() will not be called. It will only be called if we fire an event > in state 4 to transition to state 5. > > Is there a place where I can call invoke() in the state machine > implementation (without a listener) so that the state handler is called > on a transition regardless of whether an event was fired or not? > You could register a listener simply to track the progress, especially when eventless transitions are involved as you describe (and refer to this list to invoke state "handlers" in order). Alternatively, you could guard the previously eventless transitions with a special event (some event name TBD) that you fire at the end of the preceeding state handler. -Rahul > > -- > Landon Ouyang > Member Technical Staff > ITT Electronics Systems, Radar Systems - Gilfillan > 7821 Orion Ave, > Van Nuys, CA 91406 > (818) 901-2982 > > -----Original Message----- > From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com] > > Sent: Monday, April 14, 2008 12:19 PM > To: Jakarta Commons Users List > > Subject: Re: [SCXML] State transitions from within handler > > On 4/14/08, Ouyang, Landon - ES/RDR -Gil wrote: > > Rahul, > > > > Thanks for your help, I was able to implement the state transition > > method you had described earlier. > > > > The reason for this investigation is that we intend to use the > Commons > > SCXML engine to implement highly complex systems by separating all > the > > "pieces" into atomic modules (states). > > > Makes sense, for very simple systems [scxml] may even be overkill. > > > > However, we would like the > > decision making for the transitions to be done within the application > > code (state handlers) and not the state machine implementation (XML). > We > > foresee problems if the XML document must specifically reference the > > attributes needed to decide which transitions occur (ie > 'result.value' > > in our earlier example). > > > > > OK, though I don't necessarily agree. Couple of points: > > * IMO, in highly complex systems the declarative vocabulary (be it > XML or otherwise) can be thought of as merely a serialization of some > model (such as the domain UML2 state charts) which the developer(s) > maintain. > > * The [scxml] library can be the basis of building components that > serve to wrapper certain conventions in place over the state machine > implementation -- conventions that mitigate problems in having to > "specifically reference the attributes needed". The > AbstractStateMachine is one such simple example (uses a convention to > call "state handlers"). However, it has drawbacks (such as invoking > handlers synchronously while processing events) and is not fit for > complex systems. > > > > The only way I can think around this problem is to create a custom > > transition/event stack in which the next event gets pushed during the > > state handler and popped once we are officially in the current state > > (since the previous state is still being processed while we are in > the > > handler). > > > > > May not be necessary. The following suggested replacements is how I > have understood the sentences in the above paragraph: > > s/officially in a state/at rest in a state/ > s/previous state is being processed/previous event is being processed/ > > > > Is there a better way around this issue? If not, where in > > AbstractStateMachine will I know for a fact that the previous state's > > processing has been completed? > > > > > See this page: > > http://commons.apache.org/scxml/guide/using-commons-scxml.html > > The AbstractStateMachine uses the second pattern. One of the ways to > achieve what you want is using the first pattern, "Mapping states to > activities" (current state --> state handler). > > Create a variant that bootstraps similar to the AbstractStateMachine > class, waits for state machine to come to rest (initially, and when > any subsequent event is triggered on it), looks up current state > (rather than registering a listener that gets called synchronously), > and calls the corresponding state handler. Maintain a queue for > external events, have state handlers add to that queue, trigger events > in order while queue not empty. Adjustments necessary per taste etc. > :-) > > -Rahul > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org