<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Handling process state
</h3>
<span style="margin-bottom: 10px;">
reply from <a href="http://community.jboss.org/people/jeevdav">David Jeeves</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/545385#545385">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p><strong style=": ; color: #7f0055; font-size: 10pt; "><p align="left">package</p><span style="color: #7f0055; font-size: 10pt; "><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><span style="font-size: 10pt;">com.test;</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p></span><strong style=": ; color: #7f0055; font-size: 10pt; "><p align="left">import</p><span style="color: #7f0055; font-size: 10pt; "><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><span style="font-size: 10pt;">junit.framework.TestCase;</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p></span><strong style=": ; color: #7f0055; font-size: 10pt; "><p align="left">import</p><span style="color: #7f0055; font-size: 10pt; "><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><span style="font-size: 10pt;">org.jbpm.api.Configuration;</span><strong style=": ; color: #7f0055; font-size: 10pt; "><p align="left">import</p><span style="color: #7f0055; font-size: 10pt; "><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><span style="font-size: 10pt;">org.jbpm.api.Execution;</span><strong style=": ; color: #7f0055; font-size: 10pt; "><p align="left">import</p><span style="color: #7f0055; font-size: 10pt; "><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><span style="font-size: 10pt;">org.jbpm.api.ExecutionService;</span><strong style=": ; color: #7f0055; font-size: 10pt; "><p align="left">import</p><span style="color: #7f0055; font-size: 10pt; "><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><span style="font-size: 10pt;">org.jbpm.api.HistoryService;</span><strong style=": ; color: #7f0055; font-size: 10pt; "><p align="left">import</p><span style="color: #7f0055; font-size: 10pt; "><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><span style="font-size: 10pt;">org.jbpm.api.IdentityService;</span><strong style=": ; color: #7f0055; font-size: 10pt; "><p align="left">import</p><span style="color: #7f0055; font-size: 10pt; "><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><span style="font-size: 10pt;">org.jbpm.api.ManagementService;</span><strong style=": ; color: #7f0055; font-size: 10pt; "><p align="left">import</p><span style="color: #7f0055; font-size: 10pt; "><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><span style="font-size: 10pt;">org.jbpm.api.ProcessEngine;</span><strong style=": ; color: #7f0055; font-size: 10pt; "><p align="left">import</p><span style="color: #7f0055; font-size: 10pt; "><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><span style="font-size: 10pt;">org.jbpm.api.ProcessInstance;</span><strong style=": ; color: #7f0055; font-size: 10pt; "><p align="left">import</p><span style="color: #7f0055; font-size: 10pt; "><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><span style="font-size: 10pt;">org.jbpm.api.RepositoryService;</span><strong style=": ; color: #7f0055; font-size: 10pt; "><p align="left">import</p><span style="color: #7f0055; font-size: 10pt; "><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><span style="font-size: 10pt;">org.jbpm.api.TaskService;</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;">  </p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;">  </p></span><strong style=": ; color: #7f0055; font-size: 10pt; "><p align="left">public</p><span style="color: #7f0055; font-size: 10pt; "><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><strong><span style="color: #7f0055; font-size: 10pt; ">class</span><span style="font-size: 10pt;"> TestJBPM </span><strong><span style="color: #7f0055; font-size: 10pt; ">extends</span><span style="font-size: 10pt;"> TestCase</span><span style="font-size: 10pt;"><p align="left">{</p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><strong><span style="color: #7f0055; font-size: 10pt; ">protected</span><span style="font-size: 10pt;"> </span><strong><span style="color: #7f0055; font-size: 10pt; ">static</span><span style="font-size: 10pt;"> ProcessEngine </span><em><span style="color: #0000c0; font-size: 10pt; ">processEngine</span><span style="font-size: 10pt;"> = </span><strong><span style="color: #7f0055; font-size: 10pt; ">null</span><span style="font-size: 10pt;">;</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><strong><span style="color: #7f0055; font-size: 10pt; ">protected</span><span style="font-size: 10pt;"> </span><strong><span style="color: #7f0055; font-size: 10pt; ">static</span><span style="font-size: 10pt;"> RepositoryService </span><em><span style="color: #0000c0; font-size: 10pt; ">repositoryService</span><span style="font-size: 10pt;">;</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><strong><span style="color: #7f0055; font-size: 10pt; ">protected</span><span style="font-size: 10pt;"> </span><strong><span style="color: #7f0055; font-size: 10pt; ">static</span><span style="font-size: 10pt;"> ExecutionService </span><em><span style="color: #0000c0; font-size: 10pt; ">executionService</span><span style="font-size: 10pt;">;</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><strong><span style="color: #7f0055; font-size: 10pt; ">protected</span><span style="font-size: 10pt;"> </span><strong><span style="color: #7f0055; font-size: 10pt; ">static</span><span style="font-size: 10pt;"> ManagementService </span><em><span style="color: #0000c0; font-size: 10pt; ">managementService</span><span style="font-size: 10pt;">;</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><strong><span style="color: #7f0055; font-size: 10pt; ">protected</span><span style="font-size: 10pt;"> </span><strong><span style="color: #7f0055; font-size: 10pt; ">static</span><span style="font-size: 10pt;"> TaskService </span><em><span style="color: #0000c0; font-size: 10pt; ">taskService</span><span style="font-size: 10pt;">;</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><strong><span style="color: #7f0055; font-size: 10pt; ">protected</span><span style="font-size: 10pt;"> </span><strong><span style="color: #7f0055; font-size: 10pt; ">static</span><span style="font-size: 10pt;"> HistoryService </span><em><span style="color: #0000c0; font-size: 10pt; ">historyService</span><span style="font-size: 10pt;">;</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><strong><span style="color: #7f0055; font-size: 10pt; ">protected</span><span style="font-size: 10pt;"> </span><strong><span style="color: #7f0055; font-size: 10pt; ">static</span><span style="font-size: 10pt;"> IdentityService </span><em><span style="color: #0000c0; font-size: 10pt; ">identityService</span><span style="font-size: 10pt;">;</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><span style="color: #646464; font-size: 10pt; ">@Override</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><strong><span style="color: #7f0055; font-size: 10pt; ">protected</span><span style="font-size: 10pt;"> </span><strong><span style="color: #7f0055; font-size: 10pt; ">void</span><span style="font-size: 10pt;"> setUp() </span><strong><span style="color: #7f0055; font-size: 10pt; ">throws</span><span style="font-size: 10pt;"> Exception {</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><strong><span style="color: #7f0055; font-size: 10pt; ">super</span><span style="font-size: 10pt;">.setUp();</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><strong><span style="color: #7f0055; font-size: 10pt; ">if</span><span style="font-size: 10pt;"> (</span><em><span style="color: #0000c0; font-size: 10pt; ">processEngine</span><span style="font-size: 10pt;">==</span><strong><span style="color: #7f0055; font-size: 10pt; ">null</span><span style="font-size: 10pt;">) {</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><em><span style="color: #0000c0; font-size: 10pt; ">processEngine</span><span style="font-size: 10pt;"> = Configuration.<em>getProcessEngine</em>();</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><em><span style="color: #0000c0; font-size: 10pt; ">repositoryService</span><span style="font-size: 10pt;"> = </span><em><span style="color: #0000c0; font-size: 10pt; ">processEngine</span><span style="font-size: 10pt;">.get(RepositoryService.</span><strong><span style="color: #7f0055; font-size: 10pt; ">class</span><span style="font-size: 10pt;">);</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><em><span style="color: #0000c0; font-size: 10pt; ">executionService</span><span style="font-size: 10pt;"> = </span><em><span style="color: #0000c0; font-size: 10pt; ">processEngine</span><span style="font-size: 10pt;">.getExecutionService();</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><em><span style="color: #0000c0; font-size: 10pt; ">historyService</span><span style="font-size: 10pt;"> = </span><em><span style="color: #0000c0; font-size: 10pt; ">processEngine</span><span style="font-size: 10pt;">.getHistoryService();</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><em><span style="color: #0000c0; font-size: 10pt; ">managementService</span><span style="font-size: 10pt;"> = </span><em><span style="color: #0000c0; font-size: 10pt; ">processEngine</span><span style="font-size: 10pt;">.getManagementService();</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><em><span style="color: #0000c0; font-size: 10pt; ">taskService</span><span style="font-size: 10pt;"> = </span><em><span style="color: #0000c0; font-size: 10pt; ">processEngine</span><span style="font-size: 10pt;">.getTaskService();</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><em><span style="color: #0000c0; font-size: 10pt; ">identityService</span><span style="font-size: 10pt;"> = </span><em><span style="color: #0000c0; font-size: 10pt; ">processEngine</span><span style="font-size: 10pt;">.getIdentityService();</span><span style="font-size: 10pt;"><p align="left">}</p><p align="left">}</p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><strong><span style="color: #7f0055; font-size: 10pt; ">public</span><span style="font-size: 10pt;"> </span><strong><span style="color: #7f0055; font-size: 10pt; ">void</span><span style="font-size: 10pt;"> testFindOne() {</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><em><span style="color: #0000c0; font-size: 10pt; ">repositoryService</span><span style="font-size: 10pt;">.createDeployment()</span><span style="font-size: 10pt;"><p align="left">.addResourceFromClasspath(</p><p align="left"><span style="color: #2a00ff; font-size: 10pt; ">"com/test/Proc.jpdl.xml"</span><span style="font-size: 10pt;">)</span><span style="font-size: 10pt;"><p align="left">.deploy();</p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left">ProcessInstance processInstance =</p><p align="left"><em><span style="color: #0000c0; font-size: 10pt; ">executionService</span><span style="font-size: 10pt;">.startProcessInstanceByKey(</span><span style="color: #2a00ff; font-size: 10pt; ">"Proc"</span><span style="font-size: 10pt;">,</span><span style="color: #2a00ff; font-size: 10pt; ">"t"</span><span style="font-size: 10pt;">);</span><span style="font-size: 10pt;"><p align="left">System.</p><p align="left"><em><span style="color: #0000c0; font-size: 10pt; ">out</span><span style="font-size: 10pt;">.println(</span><span style="color: #2a00ff; font-size: 10pt; ">"process id "</span><span style="font-size: 10pt;">+processInstance.getId());</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left">Execution executionInA = processInstance.findActiveExecutionIn(</p><p align="left"><span style="color: #2a00ff; font-size: 10pt; ">"a"</span><span style="font-size: 10pt;">);</span><span style="font-size: 10pt;"><p align="left"><em>assertNotNull</em>(executionInA);</p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><span style="color: #3f7f5f; font-size: 10pt; ">//processInstance = executionService.signalExecutionById(executionInA.getId());</span><span style="font-size: 10pt;"><p align="left">processInstance =</p><p align="left"><em><span style="color: #0000c0; font-size: 10pt; ">executionService</span><span style="font-size: 10pt;">.findProcessInstanceById(</span><span style="color: #2a00ff; font-size: 10pt; ">"Proc.t"</span><span style="font-size: 10pt;">);</span><span style="font-size: 10pt;"><p align="left"><em>assertNotNull</em>(processInstance);</p><p align="left">}</p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><strong><span style="color: #7f0055; font-size: 10pt; ">public</span><span style="font-size: 10pt;"> </span><strong><span style="color: #7f0055; font-size: 10pt; ">void</span><span style="font-size: 10pt;"> testFindTwo() {</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left">ProcessInstance processInstance =</p><p align="left"><em><span style="color: #0000c0; font-size: 10pt; ">executionService</span><span style="font-size: 10pt;">.findProcessInstanceById(</span><span style="color: #2a00ff; font-size: 10pt; ">"Proc.t"</span><span style="font-size: 10pt;">);</span><span style="font-size: 10pt;"><p align="left"><em>assertNotNull</em>(processInstance);</p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left">}</p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><strong><span style="color: #7f0055; font-size: 10pt; ">public</span><span style="font-size: 10pt;"> </span><strong><span style="color: #7f0055; font-size: 10pt; ">void</span><span style="font-size: 10pt;"> testFindThree() {</span><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><em><span style="color: #0000c0; font-size: 10pt; ">repositoryService</span><span style="font-size: 10pt;">.createDeployment()</span><span style="font-size: 10pt;"><p align="left">.addResourceFromClasspath(</p><p align="left"><span style="color: #2a00ff; font-size: 10pt; ">"com/test/Proc.jpdl.xml"</span><span style="font-size: 10pt;">)</span><span style="font-size: 10pt;"><p align="left">.deploy();</p><p align="left">ProcessInstance processInstance =</p><p align="left"><em><span style="color: #0000c0; font-size: 10pt; ">executionService</span><span style="font-size: 10pt;">.findProcessInstanceById(</span><span style="color: #2a00ff; font-size: 10pt; ">"Proc.t"</span><span style="font-size: 10pt;">);</span><span style="font-size: 10pt;"><p align="left"><em>assertNotNull</em>(processInstance);</p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left">}</p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left">}</p></span></em></p></span></p></span></em></p></span></strong></strong></p></span></em></p></span></strong></strong></p></span></em></p></span></p></span></p></span></em></p></span></em></p></span></p></span></em></p></span></strong></strong></p></span></em></em></p></span></em></em></p></span></em></em></p></span></em></em></p></span></em></em></p></span></strong></em></em></p></span></em></p></span></strong></em></strong></p></span></strong></p></span></strong></strong></strong></p></span></p></span></em></strong></strong></p></span></em></strong></strong></p></span></em></strong></strong></p></span></em></strong></strong></p></span></em></strong></strong></p></span></em></strong></strong></p></span></strong></em></strong></strong></p></span></strong></strong></p></span></strong></p></span></strong></p></span></strong></p></span></strong></p></span></strong></p></span></strong></p></span></strong></p></span></strong></p></span></strong></p></span></strong></p></span></strong></p></span></strong></p></span></strong></p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/545385#545385">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>