spring-projects / spring-statemachine

Spring Statemachine is a framework for application developers to use state machine concepts with Spring.
1.52k stars 598 forks source link

withExit with submachine not working #1064

Open blindson76 opened 1 year ago

blindson76 commented 1 year ago

I'm trying .withExit transition on parent machine with submachine's exit state like the code in below. But it isn't working. If spring-statemachine doesn't support this, how can i do this some other way? I think it's important because there may be situation that we need to transition from submachine without knowing about its internal.

... ParentMachine ... {
   ...
    @Override
    public void configure(StateMachineStateConfigurer<String, String> states) throws Exception {
        states
            .withStates()
            .initial("p1")
            .state("sub", subMachineFactory)
            .state("p2");
    }

    @Override
    public void configure(StateMachineTransitionConfigurer<String, String> transitions) throws Exception {
        transitions
            .withExternal()
                .source("p1")
                .target("sub")
                .event("E1")
                .and()
            .withExit()
                .source("sub")
                .target("p2") ;
    }
}

... SubMachine ... {
   ...
    @Override
    public void configure(StateMachineStateConfigurer<String, String> states) throws Exception {
        states
            .withStates()
            .initial("sub_entry")
            .end("sub_exit");

    }

    @Override
    public void configure(StateMachineTransitionConfigurer<String, String> transitions) throws Exception {
        transitions
            .withExternal()
                .source("sub_entry")
                .target("sub_exit")
                .event("E1");
    }
}