2 Replies Latest reply on Apr 16, 2009 5:47 AM by Chen Kent

    Composite execution problem

    Chen Kent Newbie

      hello,

      public void testSequence(){
       ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
       .startProcess("propagate")
       .startActivity("sequence", new Sequence())
       .initial().needsPrevious().transition("end")
       .startActivity("one", new WaitState())
       .endActivity()
       .startActivity("two", new WaitState())
       .endActivity()
       .startActivity("three", new WaitState())
       .endActivity()
       .endActivity()
       .startActivity("end", new WaitState())
       .endActivity()
       .endProcess();
      
       ClientExecution execution = processDefinition.startProcessInstance();
       execution.signal();
       execution.signal();
       execution.signal();
      }
      


      Notice the line:.initial().needsPrevious().transition("end")
      I want it execute like this:
      (sequence(one -> two -> three)) -> end
      In fact is sequence->end

      I saw the source code, while activityImpl.createOutgoingTransition, the activity "end" is set to be a defaultTransition: defaultTransition = transition;

      While executionImpl.proceed(), the "sequence" activity has defaultActivity, and will never executed as a block structed node.

      How can PVM support block structed like this?
      http://docs.jboss.org/jbpm/pvm/manual/html_single/images/ch02.transition.inheritence.png



        • 1. Re: Composite execution problem
          Tom Baeyens Master

          structure of the process matches the image. its a matter of building your own ActivityBehaviours that implement what you want.

          it's probably be easier to leverage jpdl instead.

          • 2. Re: Composite execution problem
            Chen Kent Newbie

            Thank you, Tom

            The Sequence class is :test-pojo/EventPropagationTest#Sequence.

            public static class Sequence implements ExternalActivityBehaviour {
             private static final long serialVersionUID = 1L;
             public void execute(ActivityExecution execution) {
             List<Activity> activities = execution.getActivity().getActivities();
             if ( (activities!=null)
             && (!activities.isEmpty())
             ) {
             execution.execute(activities.get(0));
             }
             }
             public void signal(ActivityExecution execution, String signal, Map<String, Object> parameters) {
             Activity previous = execution.getPreviousActivity();
             List<Activity> activities = execution.getActivity().getActivities();
             int index = activities.indexOf(previous);
             index++;
             if (index < activities.size()) {
             Activity next = activities.get(index);
             execution.execute(next);
             }
             }
            


            When I set the transition:.initial().needsPrevious().transition("end"),
            the sequence activity in ExecutionImpl.proceed() will never executed as a block stucted code.

            If I modify the structure like this:
            .startActivity("three", new WaitState()).transition("end")
            .endActivity()
            

            It works fine.

            But the structure is
            http://docs.jboss.org/jbpm/pvm/manual/html_single/images/ch02.transition.out.of.composite.png

            Can you tell me how to write a currect ActivityBehaviour?
            Thank you!