Jim, thanks for you answer. I'm aware of the handler you are refering to. It 
was the base for my first solution, which currently seems to work, but I'm not 
sure if I use jBPM's API correctly ... 

My handler look's like :

 public void execute(ExecutionContext executionContext) throws Exception {
  |   Token this_token = executionContext.getToken();
  |   Node this_node = executionContext.getNode();
  |   // fetch the XML document on which
  |   // we are about to iterate
  |   String xmlDocument = (String)executionContext.getVariable(inputVariable);
  |   XmlObject xmlObject = XmlObject.Factory.parse(xmlDocument);
  |   XmlCursor cursor = xmlObject.newCursor();
  |   cursor.toFirstChild();
  |   cursor.push();
  |   // apply an XPath 
  |   cursor.selectPath(repeatingElement);
  |   // iterate on selections
  |   while(cursor.toNextSelection()) {
  |     executionContext.getContextInstance().setVariable(iterationVariable, 
cursor.getTextValue(), this_token);
  |     // execute the "foreach" body
  |     this_node.leave(executionContext, "iterate");
  |   }
  |   // no more items left, leave the foreach iteration
  |   this_node.leave(executionContext, NO_MORE_ITERATION);
  | }
  | 

My testing process definition look's like:

<node name="user iterator">
  |   <action class="xxxx.xxxx.ForEachAction">
  |     <inputVariable>users</inputVariable>
  |     <iterationVariable>a_user</iterationVariable>
  |     <repeatingElement>$this//name</repeatingElement>
  |   </action>
  |   <transition name="iterate" to="process_user"></transition>
  |   <transition name="finish-iteration" 
to="end_of_user_iteration"></transition>
  | </node>
  | 
  | <node name="process_user">
  |   <script>
  |     <expression>System.err.println("I'm processing user : 
"+a_user)</expression>
  |   </script>
  |   <transition name="" to="end_of_user_iteration"></transition>
  | </node>
  | 
  | <join name="end_of_user_iteration">
  |   <transition name="" to="end1"></transition>
  | </join>

The outcome of the process execution is the expected. I'm just not sure if the 
usage of the API is correct, especially in the part where I use the node 
instance to specify the execution path.

What do you think ? Is it valid ?

Regards
Slavikos

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3923123#3923123

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3923123


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to