commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Schwager (JIRA)" <>
Subject [jira] Created: (SCXML-78) scxml-listener will not process in a defined order (problem: SCXMLExecutor.addListener based on Set)
Date Thu, 17 Jul 2008 20:43:31 GMT
scxml-listener will not process in a defined order (problem: SCXMLExecutor.addListener based
on Set)

                 Key: SCXML-78
             Project: Commons SCXML
          Issue Type: Improvement
    Affects Versions: 0.8
            Reporter: Daniel Schwager
            Priority: Minor

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
>  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
>  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



>  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);
>                 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.

View raw message