8 Replies Latest reply on Sep 5, 2007 6:02 PM by kukeltje

    Superstate-enter event not fired

    jeanbobby

      Hi,

      This is my first usage of super states, as phases in a process.

      here's an extact:


      <start-state name="start">
       <transition to="buildPhase"/>
      </start-state>
      
      <super-state name="buildPhase">
      
       <event type="superstate-enter">
       <action class="com..." />
       </event>
      
      ...
      
       <state name="waitForValidation">
       <transition to="../deliveryPhase"/>
       </state>
      
       <event type="superstate-leave">
       <action class="com..." />
       </event>



      The super state leave event is fired, but enter is not.

      From what I read I cant say the doc is precise about this specific behaviour.
      Looking at the code this seems 'normal' :

      - Transition.take:

      if ( destination.getSuperState()!=null ) {
       ... fire the event ...


      - SuperState.execute :

      Node startNode = (Node) nodes.get(0);
       startNode.enter(executionContext);


      Going from a node to a super-state taking an explicit transition wont cause the event to be fired as dest.getSuperState == null.

      Then the super state will be executed and the first node will be entered without any kind of 'transient' transition being taken.

      What do you guys think about that ?

      AFAIAC I would expect the super-enter event being fired whatever the enter context (thru an innder node, or referencing the super-state itself).

      Thanks for your input.

      Best regards

      Olivier

        • 1. Re: Superstate-enter event not fired
          jeanbobby

          from the doc : (http://docs.jboss.com/jbpm/v3/userguide/processmodelling.html#superstateevents)

          9.6.2. Superstate events
          ...
          These events will be fired no matter over which transitions the node is entered or left respectively


          I cant find anything more precise about the expected behaviour

          • 2. Re: Superstate-enter event not fired

            jb,

            It looks like a bug to me - I'd JIRA it and see what response you get.

            Maybe the intent was to not allow transitions to the superstate. One way or another, though, there's probably something that needs doing.

            -Ed Staub

            • 3. Re: Superstate-enter event not fired
              jeanbobby

              Ok, thanks Ed.
              Copy/paste from the post is detailed enough ?

              • 4. Re: Superstate-enter event not fired

                jb,

                Copy/paste from the post is detailed enough ?


                It would be for me. I'd include the doc reference too.

                -Ed Staub

                • 5. Re: Superstate-enter event not fired
                  jeanbobby
                  • 6. Re: Superstate-enter event not fired
                    tom.baeyens

                    before the test "if (destination.getSuperState()!=null)", look at how the destination is set to the first node inside the superstate:

                    Node destination = to;
                     while (destination instanceof SuperState) {
                     destination = (Node) ((SuperState) destination).getNodes().get(0);
                     }
                    
                     ...
                    
                     // performance optimisation: check if at least there is a candidate superstate to be entered.
                     if ( destination.getSuperState()!=null ) {
                    


                    the following test succeeds:

                    public void testSuperStateEnterViaTransitionToSuperState() {
                     processDefinition = ProcessDefinition.parseXmlString(
                     "<process-definition>" +
                     " <start-state name='start'>" +
                     " <transition to='superstate'/>" +
                     " </start-state>" +
                     " <super-state name='superstate'>" +
                     " <event type='superstate-enter'>" +
                     " <action class='org.jbpm.graph.exe.SuperStateActionExecutionTest$Recorder' />" +
                     " </event>" +
                     " <super-state name='nestedsuperstate'>" +
                     " <event type='superstate-enter'>" +
                     " <action class='org.jbpm.graph.exe.SuperStateActionExecutionTest$Recorder' />" +
                     " </event>" +
                     " <state name='insidenestedsuperstate' />" +
                     " </super-state>" +
                     " </super-state>" +
                     "</process-definition>"
                     );
                     // create the process instance
                     processInstance = new ProcessInstance(processDefinition);
                     processInstance.signal();
                     assertEquals(3, executedActions.size());
                    
                     // the first action called is the superstate-enter on the 'superstate'
                     ExecutedAction executedAction = (ExecutedAction) executedActions.get(0);
                     assertEquals("superstate-enter", executedAction.event.getEventType());
                     assertSame(processDefinition.getNode("superstate"), executedAction.event.getGraphElement());
                     assertSame(processDefinition.getNode("superstate"), executedAction.eventSource);
                     assertSame(processInstance.getRootToken(), executedAction.token);
                     assertNull(executedAction.node);
                    
                     // the second action called is the superstate-enter on the 'nestedsuperstate'
                     executedAction = (ExecutedAction) executedActions.get(1);
                     assertEquals("superstate-enter", executedAction.event.getEventType());
                     assertSame(processDefinition.findNode("superstate/nestedsuperstate"), executedAction.event.getGraphElement());
                     assertSame(processDefinition.findNode("superstate/nestedsuperstate"), executedAction.eventSource);
                     assertSame(processInstance.getRootToken(), executedAction.token);
                     assertNull(executedAction.node);
                    
                     // the third action called is the *propagated* event of the 'nestedsuperstate' to the 'superstate'
                     executedAction = (ExecutedAction) executedActions.get(2);
                     assertEquals("superstate-enter", executedAction.event.getEventType());
                     assertSame(processDefinition.findNode("superstate"), executedAction.event.getGraphElement());
                     assertSame(processDefinition.findNode("superstate/nestedsuperstate"), executedAction.eventSource);
                     assertSame(processInstance.getRootToken(), executedAction.token);
                     assertNull(executedAction.node);
                     }
                    


                    do you see any difference with your scenario ? i can't seem to reproduce like this. i'll give it another try and see if persistenting the execution makes any difference.

                    • 7. Re: Superstate-enter event not fired
                      tom.baeyens

                      persistence seems to make a difference... i'm investigating.

                      • 8. Re: Superstate-enter event not fired
                        kukeltje

                        Tom, persistence seems to make a difference in a lot more cases. See e.g. the combobox test with selectItems.... Sorry for threadjacking ;-)