Hi Ronald,
Sorry to send you improper code..As I was in bit hurry to send you I just skipped to resolve compilation issues,below is my modified code..Before you run it I request you to put my processdefintion.xml in src for testing,herein with I am also sending you my xml..
And another thing I want to mention is in my code import org.jbpm.db.AbstractDbTestCase; this import couldnt be resolved as this class in not in my jbpm-jpdl.jar...I am using jbpm version 3.2.3..And the same class is used in java file for which you sent me the link
code of class
package org.jbpm.job.executor;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.context.exe.ContextInstance;
import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.graph.def.Action;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
import org.jbpm.graph.node.DecisionHandler;
public class JobExecutorDbTest extends AbstractDbTestCase {
final JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance("jbpm.cfg.xml");
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
static final int nbrOfConcurrentProcessExecutions = 20;
static final int timeout = 60000;
final Log logger = LogFactory.getLog(getClass());
static Set<String> collectedResults = Collections.synchronizedSet(new TreeSet<String>());
static List<Long> allocatedProcessIds = Collections.synchronizedList(new ArrayList<Long>());
@Override
protected void setUp() throws Exception {
super.setUp();
getJbpmConfiguration().getJobExecutor().setNbrOfThreads(4);
}
@Override
protected void tearDown() throws Exception {
getJbpmConfiguration().getJobExecutor().setNbrOfThreads(1);
super.tearDown();
}
public void testJobExecutor() {
deployProcessDefinition();
try {
ServiceVO serviceVO = new ServiceVO();
serviceVO.setProcessDefinitionName("SuperStateSample");
initiateProcess(serviceVO);
processJobs(timeout);
// assertEquals(getExpectedResults(), collectedResults);
}
finally {
}
}
void deployProcessDefinition() {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("processdefinition.xml");
jbpmContext.deployProcessDefinition(processDefinition);
}
void initiateProcess(ServiceVO serviceVO) {
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
String processName = serviceVO.getProcessDefinitionName();
logger.info("processName==="+processName);
ProcessInstance processInstance = jbpmContext.newProcessInstanceForUpdate(processName);
logger.info("--------------after getting processInstance");
long processInstanceId = processInstance.getId();
Token token = processInstance.getRootToken();
logger.info("--------------after getting token");
ContextInstance contextInstance = processInstance.getContextInstance();
logger.info("--------------after getting contextInstance");
contextInstance.setVariable("serviceVO", serviceVO);
/*if(processVariables!=null){
Set keySet = processVariables.keySet();
Iterator keyIterator = keySet.iterator();
String key = null;
Object obj = null;
while(keyIterator.hasNext()){
key = (String)keyIterator.next();
obj = processVariables.get(key);
contextInstance.setVariable(key,obj);
}
}*/
processInstance.signal();
logger.info("---------after processInstance singal");
logger.info("--------------after signal");
logger.info("--------------after saving token");
jbpmContext.save(processInstance);
logger.info("--------------after saving processInstance");
logger.info("root token======="+token.getId());
jbpmContext.close();
}
}
//start
class ServiceVO implements Serializable{
private String processDefinitionName;
public String getProcessDefinitionName() {
return processDefinitionName;
}
public void setProcessDefinitionName(String processDefinitionName) {
this.processDefinitionName = processDefinitionName;
}
}
//end
//start
class ActionHandler1 implements ActionHandler{
public void execute(ExecutionContext executionContext) throws Exception {
System.out.println("===========>>>>in action handler 1 >>>>>>>>>");
}
}
//end
//start
class DecisionHandler1 implements DecisionHandler {
public String decide(ExecutionContext arg0) throws Exception {
// TODO Auto-generated method stub
System.out.println("--in handler1-");
return "node3";
}
}
//end
//start
class DecisionHandler2 implements DecisionHandler {
public String decide(ExecutionContext arg0) throws Exception {
// TODO Auto-generated method stub
System.out.println("--in handler2-");
return "node4";
}
}
//end
code for processdefinition.xml <?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="SuperStateSample">
<start-state name="start-state1">
<transition to="node1"></transition>
</start-state>
<node name="node1">
<event type="node-enter">
<action name="action1" class="testFolder.ActionHandler1"></action>
</event>
<transition to="super-state1"></transition>
</node>
<super-state name="super-state1">
<node name="node3">
<event type="node-enter">
<action name="action3" class="testFolder.ActionHandler3"></action>
</event>
<transition to="join1"></transition>
</node>
<node name="node4">
<event type="node-enter">
<action name="action4" class="testFolder.ActionHandler4"></action>
</event>
<transition to="join1"></transition>
</node>
<decision name="decision1">
<handler class="testFolder.DecisionHandler1"></handler>
<transition to="node3" name="node3"></transition>
<transition to="join1" name="to join1"></transition>
</decision>
<decision name="decision2">
<handler class="testFolder.DecisionHandler2"></handler>
<transition to="node4" name="node4"></transition>
<transition to="join1" name="to join1"></transition>
</decision>
<join name="join1">
<transition to="node5"></transition>
</join>
<fork name="fork1">
<transition to="decision1"></transition>
<transition to="decision2" name="to decision2"></transition>
</fork>
<node name="node5">
<event type="node-enter">
<action class="testFolder.ActionHandler5"></action>
</event>
</node>
<node name="node2">
<event type="node-enter">
<action name="action2" class="testFolder.ActionHandler2"></action>
</event>
<transition to="fork1"></transition>
</node>
<transition to="end-state1"></transition>
</super-state>
<end-state name="end-state1"></end-state>
</process-definition>
jbpm.cfg.xml
<jbpm-configuration>
<!--
The default configurations can be found in org/jbpm/default.jbpm.cfg.xml
Those configurations can be overwritten by putting this file called
jbpm.cfg.xml on the root of the classpath and put in the customized values.
-->
<jbpm-context>
<service name='persistence' factory='org.jbpm.persistence.db.DbPersistenceServiceFactory' />
<service name='message' factory='org.jbpm.msg.db.DbMessageServiceFactory' />
<service name="tx" factory="org.jbpm.tx.TxServiceFactory" />
<!--<service name='scheduler' factory='org.jbpm.scheduler.db.DbSchedulerServiceFactory' />-->
<service name='logging' factory='org.jbpm.logging.db.DbLoggingServiceFactory' />
<service name='authentication' factory='org.jbpm.security.authentication.DefaultAuthenticationServiceFactory' />
</jbpm-context>
<!-- configuration resource files pointing to default configuration files in jbpm-{version}.jar-->
<string name='resource.hibernate.cfg.xml' value='hibernate.cfg.xml' />
<!-- <string name='resource.hibernate.properties' value='hibernate.properties' /> -->
<string name='resource.business.calendar' value='org/jbpm/calendar/jbpm.business.calendar.properties' />
<string name='resource.default.modules' value='org/jbpm/graph/def/jbpm.default.modules.properties' />
<string name='resource.converter' value='org/jbpm/db/hibernate/jbpm.converter.properties' />
<string name='resource.action.types' value='org/jbpm/graph/action/action.types.xml' />
<string name='resource.node.types' value='org/jbpm/graph/node/node.types.xml' />
<string name='resource.parsers' value='org/jbpm/jpdl/par/jbpm.parsers.xml' />
<string name='resource.varmapping' value='org/jbpm/context/exe/jbpm.varmapping.xml' />
<int name='jbpm.byte.block.size' value="1024" singleton="true" />
<bean name='jbpm.task.instance.factory' class='org.jbpm.taskmgmt.impl.DefaultTaskInstanceFactoryImpl' singleton='true' />
<bean name='jbpm.variable.resolver' class='org.jbpm.jpdl.el.impl.JbpmVariableResolver' singleton='true' />
</jbpm-configuration>
Thanks and Regards
vnm