5 Replies Latest reply on Jun 27, 2007 9:41 AM by kukeltje

    JBPM Decision node implementation with Decision handler

    nageshreddy1981

      Hi,

      I am new to JBPM.
      I am trying to implement decision node in process definiton.
      where can i find the examples for the decision node with the decision handler implemetation.
      Can anybody provide me with examples or links on the same.

      Thanks in advance

        • 1. Re: JBPM Decision node implementation with Decision handler
          dabd

           

          "nageshreddy1981" wrote:
          Hi,

          I am new to JBPM.
          I am trying to implement decision node in process definiton.
          where can i find the examples for the decision node with the decision handler implemetation.
          Can anybody provide me with examples or links on the same.

          Thanks in advance



          I'm a newbie too but here's what I did:

          Implement the interface DecisionHandler and implement the 'decide' method which returns the appropriate transition.

          public class MyDecisionHandler implements DecisionHandler {

          /**
          * Comment for serialVersionUID
          */
          private static final long serialVersionUID = 1L;



          public String decide(ExecutionContext executionContext) throws Exception {
          String lower = (String) executionContext.getContextInstance().getVariable("lower");
          String upper = (String) executionContext.getContextInstance().getVariable("upper");

          if ((Integer.parseInt(upper) - Integer.parseInt(lower)) > 10) {
          return "yes";
          }
          else {
          return "no";
          }

          }


          Currently you can't use the GPD to associate the handler to the decision node, so you have to edit the process definition XML by hand like this:










          • 2. Re: JBPM Decision node implementation with Decision handler
            dabd

             

            "nageshreddy1981" wrote:
            Hi,

            I am new to JBPM.
            I am trying to implement decision node in process definiton.
            where can i find the examples for the decision node with the decision handler implemetation.
            Can anybody provide me with examples or links on the same.

            Thanks in advance



            I'm a newbie too but here's what I did:

            Implement the interface DecisionHandler and implement the 'decide' method which returns the appropriate transition.

            public class MyDecisionHandler implements DecisionHandler {
            
             /**
             * Comment for <code>serialVersionUID</code>
             */
             private static final long serialVersionUID = 1L;
            
            
            
             public String decide(ExecutionContext executionContext) throws Exception {
             String lower = (String) executionContext.getContextInstance().getVariable("lower");
             String upper = (String) executionContext.getContextInstance().getVariable("upper");
            
             if ((Integer.parseInt(upper) - Integer.parseInt(lower)) > 10) {
             return "yes";
             }
             else {
             return "no";
             }
            
             }
            


            Currently you can't use the GPD to associate the handler to the decision node, so you have to edit the process definition XML by hand like this:

            <decision name="checkDiff">
             <transition name="yes" to="doSomething">
             </transition>
             <transition name="nao" to="doSomethingElse"></transition>
             <handler class="com.decisions.MyDecisionHandler"></handler>
             </decision>




            • 3. Re: JBPM Decision node implementation with Decision handler
              nageshreddy1981

              hi,

              i can create the decision handler classes as you have mentioned.
              My question is .
              I would like to create a decision node in my java code and then add a decision handler to it as i am editing my process definition by adding few more node in my through my application.


              -Nagesh

              • 4. Re: JBPM Decision node implementation with Decision handler
                nageshreddy1981

                the above is a new thread

                • 5. Re: JBPM Decision node implementation with Decision handler
                  kukeltje

                  just like in my other post in your other topic... look at the unittests etc... lots of examples there