Jboss-jbpm介绍及简单例子
2008-02-03 15:12
579 查看
jbpm是一个工作流框架,现已加入了Jboss组织。
下载地址:http://labs.jboss.com/projects/download/
下面是一个网上收罗过来的个人感觉非常简单的例子,在这里做一个笔记。
本文使用的jbpm版本:3.1.4。
文件结构如下:
![](http://p.blog.csdn.net/images/p_blog_csdn_net/kunshan_shenbin/1.JPG)
processdefinition.xml文件:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<?xml version="1.0" encoding="UTF-8"?>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="example_5">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<start-state name="开始">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<event type="node-leave">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<action name="action1"></action>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</event>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<transition name="tr1" to="工作中"></transition>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<transition name="tr2" to="求学中"></transition>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</start-state>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<state name="工作中">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<event type="node-enter">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<action name="工作" class="com.wide.example5.WorkAction"></action>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</event>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<transition name="" to="终成正果"></transition>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</state>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<state name="求学中">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<event type="node-enter">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<action name="学习" class="com.wide.example5.StudyAction"></action>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</event>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<transition name="" to="终成正果"></transition>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</state>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<end-state name="终成正果">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<event type="node-enter">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<action name="圆满" class="com.wide.example5.EndAction"></action>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</event>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</end-state>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</process-definition>
StartAction.java文件:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
package com.wide.example5;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.apache.commons.logging.Log;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.apache.commons.logging.LogFactory;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.jbpm.graph.def.ActionHandler;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.jbpm.graph.exe.ExecutionContext;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
public class StartAction implements ActionHandler ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private static final long serialVersionUID = 7004254907848592166L;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private static final Log logger = LogFactory.getLog(StartAction.class);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public void execute(ExecutionContext executionContext) throws Exception ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
logger.info("刚开始前途未卜...");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
StudyAction.java文件:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
package com.wide.example5;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.apache.commons.logging.Log;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.apache.commons.logging.LogFactory;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.jbpm.graph.def.ActionHandler;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.jbpm.graph.exe.ExecutionContext;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
public class StudyAction implements ActionHandler ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private static final long serialVersionUID = -4927790934014966410L;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private static final Log logger = LogFactory.getLog(StudyAction.class);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public void execute(ExecutionContext executionContext) throws Exception ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
logger.info("努力学习本领...");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
WorkAction.java文件:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
package com.wide.example5;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.apache.commons.logging.Log;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.apache.commons.logging.LogFactory;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.jbpm.graph.def.ActionHandler;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.jbpm.graph.exe.ExecutionContext;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
public class WorkAction implements ActionHandler ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private static final long serialVersionUID = 9112792586877839879L;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private static final Log logger = LogFactory.getLog(WorkAction.class);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public void execute(ExecutionContext executionContext) throws Exception ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
logger.info("努力工作赚钱...");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
EndAction.java文件:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
package com.wide.example5;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.apache.commons.logging.Log;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.apache.commons.logging.LogFactory;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.jbpm.graph.def.ActionHandler;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.jbpm.graph.exe.ExecutionContext;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
public class EndAction implements ActionHandler ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private static final long serialVersionUID = -3161235991642461706L;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private static final Log logger = LogFactory.getLog(EndAction.class);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public void execute(ExecutionContext executionContext) throws Exception ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
logger.info("善哉,终成正果,往生极乐!");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
Example5.java测试代码:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
package com.wide;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.jbpm.graph.def.ProcessDefinition;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.jbpm.graph.exe.ProcessInstance;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.jbpm.graph.exe.Token;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
public class Example5 ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public static void main(String[] argv)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("processdefinition.xml");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ProcessInstance ProcessInstance = new ProcessInstance(processDefinition);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Token token = ProcessInstance.getRootToken();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
System.out.println(token.getNode().getName());
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
token.signal("tr2");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
System.out.println(token.getNode().getName());
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
token.signal();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
System.out.println(token.getNode().getName());
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
更多资源:
http://jbpm-x.javaeye.com/category/19561
http://www.blogjava.net/chengang/category/12967.html
下载地址:http://labs.jboss.com/projects/download/
下面是一个网上收罗过来的个人感觉非常简单的例子,在这里做一个笔记。
本文使用的jbpm版本:3.1.4。
文件结构如下:
processdefinition.xml文件:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<?xml version="1.0" encoding="UTF-8"?>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="example_5">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<start-state name="开始">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<event type="node-leave">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<action name="action1"></action>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</event>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<transition name="tr1" to="工作中"></transition>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<transition name="tr2" to="求学中"></transition>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</start-state>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<state name="工作中">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<event type="node-enter">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<action name="工作" class="com.wide.example5.WorkAction"></action>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</event>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<transition name="" to="终成正果"></transition>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</state>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<state name="求学中">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<event type="node-enter">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<action name="学习" class="com.wide.example5.StudyAction"></action>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</event>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<transition name="" to="终成正果"></transition>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</state>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<end-state name="终成正果">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<event type="node-enter">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<action name="圆满" class="com.wide.example5.EndAction"></action>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</event>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</end-state>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</process-definition>
StartAction.java文件:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
package com.wide.example5;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.apache.commons.logging.Log;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.apache.commons.logging.LogFactory;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.jbpm.graph.def.ActionHandler;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.jbpm.graph.exe.ExecutionContext;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
public class StartAction implements ActionHandler ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private static final long serialVersionUID = 7004254907848592166L;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private static final Log logger = LogFactory.getLog(StartAction.class);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public void execute(ExecutionContext executionContext) throws Exception ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
logger.info("刚开始前途未卜...");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
StudyAction.java文件:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
package com.wide.example5;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.apache.commons.logging.Log;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.apache.commons.logging.LogFactory;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.jbpm.graph.def.ActionHandler;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.jbpm.graph.exe.ExecutionContext;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
public class StudyAction implements ActionHandler ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private static final long serialVersionUID = -4927790934014966410L;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private static final Log logger = LogFactory.getLog(StudyAction.class);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public void execute(ExecutionContext executionContext) throws Exception ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
logger.info("努力学习本领...");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
WorkAction.java文件:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
package com.wide.example5;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.apache.commons.logging.Log;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.apache.commons.logging.LogFactory;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.jbpm.graph.def.ActionHandler;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.jbpm.graph.exe.ExecutionContext;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
public class WorkAction implements ActionHandler ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private static final long serialVersionUID = 9112792586877839879L;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private static final Log logger = LogFactory.getLog(WorkAction.class);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public void execute(ExecutionContext executionContext) throws Exception ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
logger.info("努力工作赚钱...");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
EndAction.java文件:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
package com.wide.example5;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.apache.commons.logging.Log;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.apache.commons.logging.LogFactory;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.jbpm.graph.def.ActionHandler;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.jbpm.graph.exe.ExecutionContext;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
public class EndAction implements ActionHandler ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private static final long serialVersionUID = -3161235991642461706L;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private static final Log logger = LogFactory.getLog(EndAction.class);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public void execute(ExecutionContext executionContext) throws Exception ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
logger.info("善哉,终成正果,往生极乐!");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
Example5.java测试代码:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
package com.wide;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.jbpm.graph.def.ProcessDefinition;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.jbpm.graph.exe.ProcessInstance;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.jbpm.graph.exe.Token;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
public class Example5 ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public static void main(String[] argv)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("processdefinition.xml");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ProcessInstance ProcessInstance = new ProcessInstance(processDefinition);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Token token = ProcessInstance.getRootToken();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
System.out.println(token.getNode().getName());
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
token.signal("tr2");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
System.out.println(token.getNode().getName());
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
token.signal();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
System.out.println(token.getNode().getName());
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
更多资源:
http://jbpm-x.javaeye.com/category/19561
http://www.blogjava.net/chengang/category/12967.html
相关文章推荐
- 快照隔离(Snapshot Isolation)简单介绍和例子
- 最简单的JBPM例子
- Sqlite简单介绍与一些常用的例子
- JavaScript正则表达式的简单介绍和一些小例子(一)
- Android ExpandableListActivity的简单介绍及小例子
- Sqlite简单介绍与一些常用的例子
- Android AsyncTask介绍和一个简单的小例子
- socket 简单介绍与例子
- Fragment简单介绍及其类似与tabhost的底部实现例子
- 快照隔离(Snapshot Isolation)简单介绍和例子
- 触发器的介绍及MySQL触发器的简单例子
- 简单介绍MVC,和一个具体的Mvc例子
- Sqlite简单介绍与一些常用的例子
- Sqlite简单介绍与一些常用的例子
- activeMQ学习之一(简单例子介绍,含spring结合)
- .NET学习经典例子:.NET PetShop和Duwamish简单介绍
- python数据挖掘数据分析pandas的介绍及简单例子
- SSE2 Intrinsics各函数介绍 及简单例子
- jBPM的简单介绍
- JBoss 系列九十六:JBoss MSC - 简单介绍及一个简单示例