Return-Path: Delivered-To: apmail-commons-issues-archive@locus.apache.org Received: (qmail 12783 invoked from network); 28 Jul 2008 22:16:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Jul 2008 22:16:59 -0000 Received: (qmail 8678 invoked by uid 500); 28 Jul 2008 22:16:52 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 8628 invoked by uid 500); 28 Jul 2008 22:16:52 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 8614 invoked by uid 99); 28 Jul 2008 22:16:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Jul 2008 15:16:52 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Jul 2008 22:16:05 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id C946B234C174 for ; Mon, 28 Jul 2008 15:16:31 -0700 (PDT) Message-ID: <2093182334.1217283391823.JavaMail.jira@brutus> Date: Mon, 28 Jul 2008 15:16:31 -0700 (PDT) From: "Rahul Akolkar (JIRA)" To: issues@commons.apache.org Subject: [jira] Resolved: (SCXML-78) scxml-listener will not process in a defined order (problem: SCXMLExecutor.addListener based on Set) In-Reply-To: <1524757106.1216327411863.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/SCXML-78?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Rahul Akolkar resolved SCXML-78. -------------------------------- Resolution: Fixed Thanks for the patch. I've applied a variant (most of the casts aren't needed) and added you as a contributor in r680533: http://svn.apache.org/viewvc?rev=680533&view=rev Please try the latest code in SVN to verify the fix. Thanks. > scxml-listener will not process in a defined order (problem: SCXMLExecutor.addListener based on Set) > ---------------------------------------------------------------------------------------------------- > > Key: SCXML-78 > URL: https://issues.apache.org/jira/browse/SCXML-78 > Project: Commons SCXML > Issue Type: Improvement > Affects Versions: 0.8 > Reporter: Daniel Schwager > Priority: Minor > Fix For: 0.9 > > Attachments: scxml-sorted-listeners.diff > > > On 7/11/08, Daniel Schwager wrote: > > Hi Rahul, > > > > i'm running in a problem: i add two listeners to my SCXMLExecutor instance > > - the first one should run some business-methods using reflection (like you do in your watchclock-example) > > - the second one should check the current state and maybe trigger some other fsm's > > > > The order of execution of the listeners is important, because > > - FIRST I want to process the business-methods and > > - SECOND I want to inform other compontents of reaching+processing of business-methods is done > > > > Your implementation of remember the listeners based on java.util.Set - the order in a > > Set is not defined (because it's not an ordered element) - so, regardless of the sequence > > Of adding my two listeners, your code executes the listeners in the wrong order (-: > > > > Did I miss something or is this a feature request ? > > > > In terms of the philosophy behind that piece of code, listeners > shouldn't depend on the order in which they are invoked. Its possible > to think about the scenario you describe as being only one listener, > which you've broken up into two based on some usecase for convenience. > However, in terms of implementation, its good to have predictable > order. So while I still wouldn't recommend listeners that depend on > order (earlier ones could have failed, its not a pipeline or a chain, > various issues), lets make things predictable. > Please open an improvement request in JIRA (and you can attach a patch > [1] if you'd like, its probably not more than a line or two close to > the bits you've identified below -- we'd want a LinkedHashSet, not a > Vector). > -Rahul > [1] http://commons.apache.org/patches.html > > Regards > > Danny > > > > > > > > SCXMLExecutor: > > public void addListener(final SCXML scxml, final SCXMLListener listener) { > > Object observable = scxml; > > scInstance.getNotificationRegistry().addListener(observable, listener); > > } > > > > > > NotificationRegistry > > private synchronized void fireOnEntry(final Object source, > > final TransitionTarget state) { > > > > // ***** SET !!! not a Vector .. > > Set entries = (Set) regs.get(source); > > // ***** SET !!! not a Vector .. > > > > if (entries != null) { > > for (Iterator iter = entries.iterator(); iter.hasNext();) { > > SCXMLListener lst = (SCXMLListener) iter.next(); > > lst.onEntry(state); > > } > > } > > } > > > > Viele Gruesse > > > > Daniel Schwager > > -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.