看了這么久jbpm還沒有一個(gè)頭緒,需要繼續(xù)分析。jbpm把流程部署到數(shù)據(jù)庫有好幾種方法,今晚終于調(diào)試通過了java直接部署 的子,僅為述于此,不做分析。
static JbpmConfiguration cfg=JbpmConfiguration.getInstance(); //jbpm一切一切的基礎(chǔ)
public void setUp(){
//cfg.createSchema(); //重建jbpm存儲層..
}
以下是一個(gè)部署的方法
public void testDeployProcessDefinition()throws Exception{
assertNotNull("JbpmConfiguration is null",cfg);
FileInputStream fis = new FileInputStream("src/proc1.xml");
ProcessDefinition pd=ProcessDefinition.parseXmlInputStream(fis);
assertNotNull("definition should not be null",pd);
JbpmContext jc=cfg.createJbpmContext();
try{
jc.deployProcessDefinition(pd);
}finally{
jc.close();
}
}
實(shí)例化并生成流程實(shí)例的方法
public void testLoadProcessAndInstance() throws Exception {
JbpmContext jbpmContext = cfg.createJbpmContext() ;
try {
GraphSession graphSession = jbpmContext.getGraphSession();
ProcessDefinition processDefinition =
graphSession.findLatestProcessDefinition("pro1");
ProcessInstance processInstance =
new ProcessInstance(processDefinition);
Token token = processInstance.getRootToken();
assertEquals("start", token.getNode().getName());
// Let's start the process execution
token.signal();
assertEquals("state1", token.getNode().getName());
jbpmContext.save(processInstance);
} finally {
// Tear down the pojo persistence context.
jbpmContext.close();
}
}
再執(zhí)行上面生成的流程方法
public void testLoadInstanceAndDoActionAndEnd() throws Exception {
JbpmContext jbpmContext = cfg.createJbpmContext() ;
try {
GraphSession graphSession = jbpmContext.getGraphSession();
ProcessDefinition processDefinition = graphSession.findLatestProcessDefinition("pro1");
List processInstances = graphSession.findProcessInstances(processDefinition.getId());
ProcessInstance processInstance = (ProcessInstance) processInstances.get(0);
// this.assertEquals("message",(String)(processInstance.getContextInstance().getVariable("message")));
processInstance.signal();
assertTrue(processInstance.hasEnded());
jbpmContext.save(processInstance);
} finally {
jbpmContext.close();
}
}
實(shí)際上,上面的幾段代碼中寫來寫去就這幾句話吧。加載流程,生成實(shí)例,然后簽收執(zhí)行。
明天繼續(xù)......
posted on 2007-04-09 23:27
有貓相伴的日子 閱讀(1521)
評論(0) 編輯 收藏 所屬分類:
workflow