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

    Composite execution problem

    Chen Kent Newbie


      public void testSequence(){
       ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
       .startActivity("sequence", new Sequence())
       .startActivity("one", new WaitState())
       .startActivity("two", new WaitState())
       .startActivity("three", new WaitState())
       .startActivity("end", new WaitState())
       ClientExecution execution = processDefinition.startProcessInstance();

      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?

        • 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())
             ) {
             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);
             if (index < activities.size()) {
             Activity next = activities.get(index);

            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")

            It works fine.

            But the structure is

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