Link to the project on github for testing
The Payprus Files are here
I'm trying to make a State-Machine with Papyrus. The State Machine should combine two single state-machines to one, as you can see in the first image:
the state machine 1 is defined in the 2nd picture and the state machine 2 is defined in the 3rd picture
I'm consuming the UML with my spring application (scroll down for code)
I tried this with a real simple single state machine (so only something like state machine 1 but with initial and final point) and it worked perfectly, the System.out.println()
was writing the whole code.
But with this 2 state machines, the machine starts in the TOP at the top_inital point and goes then to top_s1. This was expected and working
Than i expected to go over the topExitPoint1 to the sm1EntryPoint -> entering the StateMachine1 -> than to StateMachine2 -> back to top and so on.
But unfortunately the only state in my machine which was used has been the one in top -> the top_s1 state. The console log only shows me this:
2017-09-14 17:41:42.002 INFO 25414 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-09-14 17:41:42.008 INFO 25414 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
State change to top_s1
2017-09-14 17:41:42.070 INFO 25414 --- [ main] o.s.s.support.LifecycleObjectSupport : started org.springframework.statemachine.support.DefaultStateMachineExecutor@4afd21c6
2017-09-14 17:41:42.070 INFO 25414 --- [ main] o.s.s.support.LifecycleObjectSupport : started top_s1 topFinalState top_r2_s1 top_s2 top_FinalState1 sm2_s1 sm2_s2 sm1_s2 sm1_s1 / top_s1 / uuid=e3a76fb9-5d3f-46b2-9c01-17d23eabedea / id=null
2017-09-14 17:41:42.071 INFO 25414 --- [ main] d.j.u.UmlSpringStateMachineApplication : Started UmlSpringStateMachineApplication in 2.584 seconds (JVM running for 2.85)
2017-09-14 17:41:42.073 INFO 25414 --- [ Thread-3] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@1e4a7dd4: startup date [Thu Sep 14 17:41:39 CEST 2017]; root of context hierarchy
2017-09-14 17:41:42.076 INFO 25414 --- [ Thread-3] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase 0
2017-09-14 17:41:42.077 INFO 25414 --- [ Thread-3] o.s.s.support.LifecycleObjectSupport : stopped org.springframework.statemachine.support.DefaultStateMachineExecutor@4afd21c6
2017-09-14 17:41:42.078 INFO 25414 --- [ Thread-3] o.s.s.support.LifecycleObjectSupport : stopped top_s1 topFinalState top_r2_s1 top_s2 top_FinalState1 sm2_s1 sm2_s2 sm1_s2 sm1_s1 / / uuid=e3a76fb9-5d3f-46b2-9c01-17d23eabedea / id=null
2017-09-14 17:41:42.078 INFO 25414 --- [ Thread-3] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2017-09-14 17:41:42.079 INFO 25414 --- [ Thread-3] o.s.s.support.LifecycleObjectSupport : destroy called
I tried so many things in Papyrus to change this behaviour, but nothing changes. Would be cool, if someone can have a look to it, and maybe knows how to help.
Here is the Java Code: My UmlSpringStateMachineApplication
package de.joergi.umlspringstatemachine;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.statemachine.StateMachine;
@SpringBootApplication
public class UmlSpringStateMachineApplication implements CommandLineRunner {
@Autowired
private StateMachine<String, String> stateMachine;
public static void main(String[] args) {
SpringApplication.run(UmlSpringStateMachineApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
stateMachine.start();
}
}
and my StateMachineConfig
looks like this:
package de.joergi.umlspringstatemachine;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.StateMachineConfigurerAdapter;
import org.springframework.statemachine.config.builders.StateMachineConfigurationConfigurer;
import org.springframework.statemachine.config.builders.StateMachineModelConfigurer;
import org.springframework.statemachine.config.model.StateMachineModelFactory;
import org.springframework.statemachine.listener.StateMachineListener;
import org.springframework.statemachine.listener.StateMachineListenerAdapter;
import org.springframework.statemachine.state.State;
import org.springframework.statemachine.uml.UmlStateMachineModelFactory;
@Configuration
@EnableStateMachine
public class StateMachineConfig extends StateMachineConfigurerAdapter<String, String> {
@Override
public void configure(StateMachineConfigurationConfigurer<String, String> config) throws Exception {
config.withConfiguration().autoStartup(false).listener(listener());
}
@Override
public void configure(StateMachineModelConfigurer<String, String> model) throws Exception {
model.
withModel().factory(modelFactoryStateMachine());
}
@Bean
public StateMachineModelFactory<String, String> modelFactoryStateMachine() {
return new UmlStateMachineModelFactory("classpath:papyrus/new_test.uml");
}
@Bean
public StateMachineListener<String, String> listener() {
return new StateMachineListenerAdapter<String, String>() {
@Override
public void stateChanged(State<String, String> from, State<String, String> to) {
System.out.println("State change to " + to.getId());
}
};
}
}
If you want to see how the model explorer looks like:
So, i fixed this, with building two separate State-Machines together in one project and connecting them https://github.com/joergi/uml-spring-state-machine/ see the new push to master