commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mansour Al Akeel <mansour.alak...@gmail.com>
Subject Re: [SCXML] Next states
Date Fri, 06 May 2016 06:56:37 GMT
Thank you Woonsan,
The use case is to report transition failure or invalid path.
Using the listener is good, but it wont be triggered unless the
transition happens.
For example this was written to test commons SCXML 1:

@Override
    public boolean fireEvent(String event) {
        List<Transition> lst = this.getCurrentState().getTransitionsList(event);
        if (lst == null) {
            System.out.println("unknown event: " + event);
            return false;  // this should return true if final only
        }
        State before = this.getCurrentState();
        boolean evnetFired = super.fireEvent(event);

        State after = this.getCurrentState();

        if (after.equals(before)) {

            Status stauts = this.getEngine().getCurrentStatus();

            Set<State> valid = stauts.getStates();

            System.out.println("We are in " + before.getId() + ".
Possible next states: ");

            for (Transition transition : lst) {
                System.out.println(transition.getTarget().getId());
            }

            List<Transition> transitionList =
this.getCurrentState().getTransitionsList();

            for (Transition transition : transitionList) {
                System.out.println(transition.getTarget().getId());
            }
            // throw new
            // IllegalStateException("Can not complete transition while in " +
            // before.getId());
        } else {
            System.out.println("succefully switched state " +
before.getId() + " -> " + after.getId());
        }
        return evnetFired;
    }


Is there a way to translate it to 2 ?
Thank you


On Wed, May 4, 2016 at 11:58 AM, Woonsan Ko <woonsan@apache.org> wrote:
> Not sure about the use case, but maybe you can add a listener
> (AbstractStateMachine#getEngine()#addListener(stateMachine, new
> MyListener())).
> If you get a TransitionalState in your listener, you may possibly get
> all the available Transitions and TransitionTargets.
>
> Regards,
>
> Woonsan
>
>
> On Sun, May 1, 2016 at 8:19 PM, Mansour Al Akeel
> <mansour.alakeel@gmail.com> wrote:
>> Is there a way to get the next valid states or transitions ?
>> I am working with AbstractStateMachine
>>
>> Thank you
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message