commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rahul Akolkar (JIRA)" <>
Subject [jira] Resolved: (SCXML-156) Need a better way of setting initial state in instances of SCXMLExecutor
Date Fri, 27 Aug 2010 14:27:56 GMT


Rahul Akolkar resolved SCXML-156.

    Resolution: Not A Problem

This can simply be done along these lines (Java 1.4):

  public void setCurrentState(SCXMLExecutor exec, String state) {
    Set states = exec.getCurrentStatus().getStates();
    TransitionTarget tt = (TransitionTarget) exec.getStateMachine().getTargets().get(state);

You can find a more resilient version of the above method here which uses generics (search
for "setCurrentState"):

WRT the AbstractStateMachine class, that was built as the simplest pattern, I wouldn't put
it to any serious use.

> Need a better way of setting initial state in instances of SCXMLExecutor
> ------------------------------------------------------------------------
>                 Key: SCXML-156
>                 URL:
>             Project: Commons SCXML
>          Issue Type: Improvement
>    Affects Versions: 0.9
>         Environment: local j2se
>            Reporter: Ant Kutschera
>            Priority: Minor
> Example:
> I have states RESERVED->BOOKED->PAID.  The initial state is RESERVED.  I create
a business entity which has this state and I need to persist it in state BOOKED.
> I persist the state as a varchar / String.  I don't want to persist a state machine in
my database.
> When I load the entity in order to update the state to "PAID", I need to instantiate
the state machine, and update the state to "BOOKED", since that is the status my object really
> I can do this, only by modifying the InitialTarget of the SCXML using the API.  That
isn't nice, because I only want one instance of SCXML, because loading the XML is expensive
in terms of time/cpu etc.  The solution I've used now is to do the update in a synchronized
block, while being synchronized on the SCXML instance, and then after I instantiate the SCXMLExecutor,
I put the state back in the SCXML to the original initial state.
> Ideally, I would be able to pass the "starting state" to the constructor of the SCXMLExecutor,
to indicate that I am starting from a partially run workflow, if that makes sense.
> See this blog article too:

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message