4 Replies Latest reply on May 2, 2006 5:32 AM by icyjamie

    Passing process variables to delegation configuration

    sarva

      To pass in a process variable to a delegation class(ActionHandler) as a config-type field, can I use the following,

      <node name="Execute Software">
       <action class="MyActionHandler">
       <myvar><variable name="software pk" access="read"></variable></myvar>
       <cargs>dummy</cargs>
       </action>
       <transition name="end" to="end1"></transition>
       </node>


      or using expression the only way,

      <node name="Execute Software">
       <action class="MyActionHandler">
       <myvar>#{contextInstance.getVariable("software pk", token)}</myvar>
       <cargs>dummy</cargs>
       </action>
       <transition name="end" to="end1"></transition>
       </node>



      Also is it possible for my action handler to set a process variable without having to write it explicitly in the handler.execute(context) method?

      I'm trying to write action handlers so they do not refer to process variables in the code but to just bind to the process variables in processdefinition.xml

      Thanks,


        • 1. Re: Passing process variables to delegation configuration
          sarva

          Even #{contextInstance.getVariable("software pk", token)} does not seem to work. Is this possible at all?

          Any help is appreciated.

          What I'm trying to achieve is for example is,

          I want to have two resuable steps,

          1) Convert Document (Input: inputPath, output: outputPath)

          2) Email Document (Input: pathToDoc)


          The process will take 2 input args, doc1 and doc2

          The sequence of steps in the workflow should be,

          1) Convert Document(doc1) ,output=pathToDoc1
          2) Email Document(pathToDoc1)
          3) Convert Document(doc2), output=pathToDoc2
          4) Email Document(pathToDoc2)

          Since the steps are reusable, I do not want to reference the process variables directly by name, I just want to pass in the doc1 as input to the step. Also I want the ConvertDoc step output to be used by the EmailDoc step. And I want the steps to be executed in sequence(In parallel execution I see that I can depend on the token scoping to resolve some issues). In this example it can run in parallel, but in my real use case it has to be in sequence.

          Is this possible to do with jBPM?

          Thanks,

          • 2. Re: Passing process variables to delegation configuration
            icyjamie

            I don't get it exactly, but if you want to configure a process variable using the definition, it is best to make a base class (I created an adapter handling assignment, events and decision), having some general-purpose properties to use e.g. a set of name-value pairs that will be created as variables.
            Alternatively, you could design a special handler to do all sorts of stuff. We had a MapVarActionHandler which could push strings as transients and process variables, read and push stuff from external configurations (like changeable tresholds for decisions), read properties from objects and push them (e.g. an object in a transient variable holding an amount: push the amount as a variable).
            We designed our system by heavily using transients as a parameter passing mechanism:
            - initiate a session
            - push domain objects as transients
            - let jbpm do its job: jbpm calls back business methods using events (here: concern of jbpm is handling flow, not make business decisions in its handlers, otherwise we had an exponential explosion of handlers)

            • 3. Re: Passing process variables to delegation configuration
              tom.baeyens

              nice idea, but not yet supported. in jbpm 4 we plan to harmonize all the bean wiring stuff. that would be a good occasion to include support for this.

              • 4. Re: Passing process variables to delegation configuration
                icyjamie

                In jbpm 3.1 and our extensions, it works too :-)
                We use the command pattern and strategy pattern heavily. Each node and task can lookup the best strategy to perform assignments, execution, priority, swimlane, concerned datablock, etc...
                The lookups are by node-name, or a specified name on the event, using "a" beanfactory (Spring of course).
                Works nicely...

                James