public void testHelloWorldProcess() { // This method shows a process definition and one execution// of the process definition. The process definition has // 3 nodes: an unnamed start-state, a state 's' and an // end-state named 'end'.// The next line parses a piece of xml text into a// ProcessDefinition. A ProcessDefinition is the formal // description of a process represented as a java object. ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( "<process-definition>" + " <start-state>" + " <transition to='s' />" + " </start-state>" + " <state name='s'>" + " <transition to='end' />" + " </state>" + " <end-state name='end' />" + "</process-definition>" ); // The next line creates one execution of the process definition.// After construction, the process execution has one main path// of execution (=the root token) that is positioned in the// start-state. ProcessInstance processInstance = new ProcessInstance(processDefinition); // After construction, the process execution has one main path// of execution (=the root token). Token token = processInstance.getRootToken(); // Also after construction, the main path of execution is positioned// in the start-state of the process definition. assertSame(processDefinition.getStartState(), token.getNode()); // Let's start the process execution, leaving the start-state // over its default transition. token.signal(); // The signal method will block until the process execution // enters a wait state.// The process execution will have entered the first wait state// in state 's'. So the main path of execution is now // positioned in state 's' assertSame(processDefinition.getNode("s"), token.getNode()); // Let's send another signal. This will resume execution by // leaving the state 's' over its default transition. token.signal(); // Now the signal method returned because the process instance // has arrived in the end-state. assertSame(processDefinition.getNode("end"), token.getNode()); }更详细的例子可以看参考,里面有很详细的操作说明。下面是根据参考例子测试时出现的一些问题及说明。一、关于数据库,首先要修改数据库连接,然后创建数据库,里面的表格jBPM提供相应的API去创建。public void testDeployProcessDefinition() throws FileNotFoundException { // 从 jbpm.cfg.xml 取得 jbpm 的配置 JbpmConfiguration config = JbpmConfiguration.getInstance(); config.dropSchema();//删除数据表结构 config.createSchema();//创建数据表结构 // 创建一个 jbpm 容器 JbpmContext jbpmContext = config.createJbpmContext(); // 由 processdefinition.xml 生成相对应的流程定义类 ProcessDefinition InputStream is = new FileInputStream("processes/simple/processdefinition.xml"); ProcessDefinition processDefinition = ProcessDefinition.parseXmlInputStream(is); // 利用容器的方法将流程定义数据部署到数据库上 jbpmContext.deployProcessDefinition(processDefinition); // 关闭 jbpmContext jbpmContext.close(); }这个是根据流程配置文件最后生成的数据库信息的测试方法,刚开始我还有一个疑问,数据库和数据表是系统自动创建还是要手动创建,数据库是要手动创建的,数据表可以自动创建的
posted on 2007-01-18 10:55 风人园 阅读(1001) 评论(0) 编辑 收藏 所属分类: jBPM
Powered by: BlogJava Copyright © 风人园