I need a subprocess looping based on the "do until" or "while' condition. So, an acitivity inside of the subprocess returns a value, and based on the value, a gateway inside of the subprocess decides the looping.
I modfied the code to include a sub-process here.
http://community.jboss.org/people/bpmn2user/blog/2011/03/01/jbpm5--subproces-loop-example
The loop condition can be set inside the sub-process, though it is passed as a paramter from the parent process in this example.