Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Using 2 different Papyrus statemachines with the spring-statemachine project(I'm trying to use 2 different Papyrus statemachines with the spring-statemachine project)
Using 2 different Papyrus statemachines with the spring-statemachine project [message #1772804] Fri, 15 September 2017 13:19 Go to next message
Joerg L is currently offline Joerg LFriend
Messages: 2
Registered: September 2017
Junior Member

Link to the project on github for testing
The Payprus Files are here in the github projcect

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:

State Machine 1 and State Machine 2 are looking similar but everything beginning with SM2_ instead of SM1_
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]  : Starting beans in phase 0
    State change to top_s1
    2017-09-14 17:41:42.070  INFO 25414 --- [           main]     : started
    2017-09-14 17:41:42.070  INFO 25414 --- [           main]     : 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]  : Stopping beans in phase 0
    2017-09-14 17:41:42.077  INFO 25414 --- [       Thread-3]     : stopped
    2017-09-14 17:41:42.078  INFO 25414 --- [       Thread-3]     : 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]     : 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;
    public class UmlSpringStateMachineApplication implements CommandLineRunner {
    	private StateMachine<String, String> stateMachine;
    	public static void main(String[] args) {, args);
    	public void run(String... args) throws Exception {

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.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;
    public class StateMachineConfig extends StateMachineConfigurerAdapter<String, String> {
        public void configure(StateMachineConfigurationConfigurer<String, String> config) throws Exception {
        public void configure(StateMachineModelConfigurer<String, String> model) throws Exception {
        public StateMachineModelFactory<String, String> modelFactoryStateMachine() {
            return new UmlStateMachineModelFactory("classpath:papyrus/new_test.uml");
        public StateMachineListener<String, String> listener() {
            return new StateMachineListenerAdapter<String, String>() {
                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:

P.S. this is also posted on Stack Overflow, but with no answers yet
  • Attachment: top.png
    (Size: 57.83KB, Downloaded 601 times)
  • Attachment: new_test.di
    (Size: 0.27KB, Downloaded 69 times)
  • Attachment: new_test.notation
    (Size: 51.66KB, Downloaded 111 times)
  • Attachment: new_test.uml
    (Size: 4.88KB, Downloaded 76 times)
  • Attachment: sm1.png
    (Size: 23.21KB, Downloaded 633 times)

[Updated on: Fri, 15 September 2017 13:23]

Report message to a moderator

Re: Using 2 different Papyrus statemachines with the spring-statemachine project [message #1773422 is a reply to message #1772804] Wed, 27 September 2017 16:48 Go to previous message
Joerg L is currently offline Joerg LFriend
Messages: 2
Registered: September 2017
Junior Member

So, i fixed this, with building two separate State-Machines together in one project and connecting them see the new push to master

[Updated on: Wed, 27 September 2017 16:48]

Report message to a moderator

Previous Topic:Using Papyrus in Windows and Linux over svn and Diagramms are not the same
Next Topic:What is the proper use of "Restore Related Elements"
Goto Forum:

Current Time: Sun Jul 05 09:33:53 GMT 2020

Powered by FUDForum. Page generated in 0.01777 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top