4 Replies Latest reply on May 18, 2007 9:12 PM by gavin.king

    can't access non-Seam variables from jPDL decision condition

    shea.phillips

      Hello,

      After significant amount of troubleshooting, I have discovered that the org.jboss.seam.jbpm.SeamVariableResolver is used when resolving variables in a expression inside jBPM jPDL when the process is started inside of Seam.

      This is fine and very useful in many cases, however, in my scenario, I am doing the following:

      - starting the process from Seam with a single BUSINESS_PROCESS scope String var
      - invoking Seam components from embedded jPDL scripts, which set process context variables (non-Seam), that are subsequently referenced in condition expressions
      - the condition expression evaluation uses the SeamVariableResolver and, as a result does not see the variable I exposed from my script, although other scripts do (apparently they use some different variable resolution strategy)

      Here is my jPDL snippet:

       <node name="establishInterpretationProcess">
       <transition to="decideOnInterpretation">
       <script>
       <expression>
       import org.jboss.seam.Component;
       import com.foo.ECGInterpretationProcessNameResolverService;
      
       System.out.println("ECG ID is '" + ecgId + "'");
      
       lookup = Component.getInstance(ECGInterpretationProcessNameResolverService.NAME, true);
      
       interpretationName = lookup.determineInterpretationProcessName(ecgId);
      
       System.out.println("Interpretation name in establishInterpretationProcess is '" + interpretationName + "'");
       </expression>
       <variable name="ecgId" mapped-name="ecgId" access="read"/>
       <variable name="interpretationName" mapped-name="interpretationName" access="read,write"/>
       </script>
       </transition>
       </node>
      
       <decision name="decideOnInterpretation">
       <transition name="interpret" to="doInterpretation"/>
       <transition name="dontInterpret" to="assignForManualInterpretation">
       <condition>#{interpretationName == null}</condition>
       <script>System.out.println("interpretationName was null!");</script>
       </transition>
       </decision>
      


      The specific behaviour here is that the expression #{interpretationName == null} always evaluates to null, so the associated transition is always taken, regardless of the value of the interpretationName process context variable (as set in the script)

      I tried to outject a value with BUSINESS_PROCESS scope from my component invoked in the script, but this also was not visible by the expression.

      My design goal is to keep the process and the components loosely coupled (the current bsh notwithstanding :P ) such that either can potentially be reused, which is why I am wanting to hold some minimal state in the process context.

      Does anyone have any suggestions about how I might work around this? I have an idea how I might modify the SeamVariableResolver to look in the jBPM contexts as well as its own scopes, but this seems like a big hammer.

      thanks,

      shea.

        • 1. Re: can't access non-Seam variables from jPDL decision condi
          pmuir

          I guess JBPM variables aren't exposed in EL. Have you asked this on the JBPM forum as they might know more? You could file a feature request for this in Seam JIRA

          • 2. Re: can't access non-Seam variables from jPDL decision condi
            shea.phillips

            When used inside Seam, JBPM variables are not visible in EL, as the Seam jbpm component configures its own EL variable resolver that only looks in Seam contexts.

            I am currently experimenting with my own jbpm bootstrap that uses my own VariableResolver implementation that looks in both JBPM and Seam context when resolving variables.

            I will post the results here and potentially file a feature request.

            • 3. Re: can't access non-Seam variables from jPDL decision condi
              shea.phillips

              I have managed to resolve my issue with not being able to access jBPM process context variable from within jPDL EL expressions using the following approach:

              - I implemented an alternate implementation of a jBPM VariableResolver that delegates to the JBPM default variable resolver and the Seam implementation; in my implementation, variables in the JBPM context take precedence; if no value is found for a given variable name in the JBPM context, it looks in the Seam contexts; if there is nothing there, it returns null

              - I implemented a JBPMBootStrap Seam component that I deploy from components.xml with a depdendency on the Seam JBPM component (meaning my component will start after Seam's); in its @Create/start() method, it just calls JbpmExpressionEvaluator.setVariableResolver(new MyNewVariableResolver())

              Seems to be working well so far.

              • 4. Re: can't access non-Seam variables from jPDL decision condi
                gavin.king

                Fixed in CVS. Please let us know if it solves your problem. Thanks.