一、插件安装说明
1)下载插件后,解压出"dropins"、"jbpm_plugin"两个目录文件夹
2)把jbpm_plugin文件夹复制到eclipse的安装目录
3)将dropins目录下jbpm.link文件复制eclipse的安装目录dropins的文件下
4)点击eclipse菜单文件(File) - 新建(New)- 其他(Other),如下图
二、创建demo项目
1)创建JBoss JProcess Project项目
2) 下载jbpm-jpdl-suite-3.2.2依赖包,并设置用户库User Library(注意下图标箭头的位置不一样)
3)打开processdefinition.xml后,出现下图2的流程图
4)打开processdefinition.xml文件内容,执行完后<message>标签提示
<?xml version="1.0" encoding="UTF-8"?> @b@<process-definition @b@ xmlns="urn:jbpm.org:jpdl-3.2"@b@ name="simple">@b@ <start-state name="start">@b@ <transition name="to_state" to="first">@b@ <action name="action" class="com.sample.action.MessageActionHandler">@b@ <message>Going to the first state!</message>@b@ </action>@b@ </transition>@b@ </start-state>@b@ <state name="first">@b@ <transition name="to_end" to="end">@b@ <action name="action" class="com.sample.action.MessageActionHandler">@b@ <message>About to finish!</message>@b@ </action>@b@ </transition>@b@ </state>@b@ <end-state name="end"></end-state>@b@</process-definition>
5)打开MessageActionHandler.java类,添加System.out.println("message=========="+message);消息提示
package com.sample.action;@b@@b@import org.jbpm.graph.def.ActionHandler;@b@import org.jbpm.graph.exe.ExecutionContext;@b@@b@public class MessageActionHandler implements ActionHandler {@b@@b@ private static final long serialVersionUID = 1L;@b@ @b@ /**@b@ * The message member gets its value from the configuration in the @b@ * processdefinition. The value is injected directly by the engine. @b@ */@b@ String message;@b@@b@ /**@b@ * A message process variable is assigned the value of the message@b@ * member. The process variable is created if it doesn't exist yet.@b@ */@b@ public void execute(ExecutionContext context) throws Exception {@b@ context.getContextInstance().setVariable("message", message);@b@ System.out.println("message=========="+message);@b@ }@b@@b@}
6)运行SimpleProcessTest类,控制台输出对应日志(日志打印“message==========”的按照流程结束提示内容)
01:04:45,112 [main] INFO JbpmConfiguration : using jbpm configuration resource 'jbpm.cfg.xml'@b@01:04:45,116 [main] DEBUG JbpmConfiguration : loading defaults in jbpm configuration@b@01:04:45,171 [main] DEBUG ObjectFactoryImpl : adding object info 'default.jbpm.context'@b@01:04:45,172 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.hibernate.cfg.xml'@b@01:04:45,172 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.business.calendar'@b@01:04:45,173 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.default.modules'@b@01:04:45,173 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.converter'@b@01:04:45,174 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.action.types'@b@01:04:45,174 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.node.types'@b@01:04:45,175 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.parsers'@b@01:04:45,175 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.varmapping'@b@01:04:45,176 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.mail.templates'@b@01:04:45,176 [main] DEBUG ObjectFactoryImpl : adding object info 'jbpm.byte.block.size'@b@01:04:45,177 [main] DEBUG ObjectFactoryImpl : adding object info 'jbpm.task.instance.factory'@b@01:04:45,178 [main] DEBUG ObjectFactoryImpl : adding object info 'jbpm.variable.resolver'@b@01:04:45,178 [main] DEBUG ObjectFactoryImpl : adding object info 'jbpm.mail.smtp.host'@b@01:04:45,178 [main] DEBUG ObjectFactoryImpl : adding object info 'jbpm.mail.address.resolver'@b@01:04:45,178 [main] DEBUG ObjectFactoryImpl : adding object info 'jbpm.mail.from.address'@b@01:04:45,181 [main] DEBUG ObjectFactoryImpl : adding object info 'jbpm.job.executor'@b@01:04:45,182 [main] DEBUG JbpmConfiguration : loading specific configuration...@b@01:04:45,185 [main] DEBUG ObjectFactoryImpl : adding object info 'jbpmConfiguration'@b@01:04:45,190 [main] INFO StaleObjectLogConfigurer : stale object exceptions will be hidden from logging@b@01:04:45,263 [main] DEBUG JpdlParser$JpdlEntityResolver : resolving schema reference publicId(null) systemId(http://jbpm.org/jpdl-3.2.xsd)@b@01:04:45,263 [main] DEBUG JpdlParser$JpdlEntityResolver : providing input source to local 'jpdl-3.2.xsd' resource@b@01:04:45,352 [main] DEBUG NodeTypes : node 'page' will not be available. class 'org.jboss.seam.pageflow.Page' couldn't be loaded@b@01:04:45,353 [main] DEBUG NodeTypes : node 'start-page' will not be available. class 'org.jboss.seam.pageflow.Page' couldn't be loaded@b@01:04:45,399 [main] DEBUG GraphElement : event 'process-start' on 'ProcessDefinition(simple)' for 'Token(/)'@b@01:04:45,401 [main] DEBUG GraphElement : event 'before-signal' on 'StartState(start)' for 'Token(/)'@b@01:04:45,401 [main] DEBUG GraphElement : event 'node-leave' on 'StartState(start)' for 'Token(/)'@b@01:04:45,402 [main] DEBUG GraphElement : event 'transition' on 'Transition(to_state)' for 'Token(/)'@b@01:04:45,402 [main] DEBUG GraphElement : executing action 'action[action]'@b@01:04:45,402 [main] DEBUG Token : token[0] is locked by token[0]@b@01:04:45,415 [main] DEBUG VariableContainer : create variable 'message' in 'TokenVariableMap1e0f4f' with value 'Going to the first state!'@b@01:04:45,436 [main] DEBUG Converters : adding converter 'D', 'org.jbpm.context.exe.converter.DoubleToStringConverter'@b@01:04:45,441 [main] DEBUG Converters : adding converter 'C', 'org.jbpm.context.exe.converter.CharacterToStringConverter'@b@01:04:45,443 [main] DEBUG Converters : adding converter 'B', 'org.jbpm.context.exe.converter.BooleanToStringConverter'@b@01:04:45,444 [main] DEBUG Converters : adding converter 'Y', 'org.jbpm.context.exe.converter.BytesToByteArrayConverter'@b@01:04:45,446 [main] DEBUG Converters : adding converter 'A', 'org.jbpm.context.exe.converter.DateToLongConverter'@b@01:04:45,448 [main] DEBUG Converters : adding converter 'R', 'org.jbpm.context.exe.converter.SerializableToByteArrayConverter'@b@01:04:45,449 [main] DEBUG Converters : adding converter 'I', 'org.jbpm.context.exe.converter.IntegerToLongConverter'@b@01:04:45,450 [main] DEBUG Converters : adding converter 'H', 'org.jbpm.context.exe.converter.ShortToLongConverter'@b@01:04:45,451 [main] DEBUG Converters : adding converter 'G', 'org.jbpm.context.exe.converter.FloatToDoubleConverter'@b@01:04:45,452 [main] DEBUG Converters : adding converter 'F', 'org.jbpm.context.exe.converter.FloatToStringConverter'@b@01:04:45,452 [main] DEBUG Converters : adding converter 'E', 'org.jbpm.context.exe.converter.ByteToLongConverter'@b@message==========Going to the first state!@b@01:04:45,469 [main] DEBUG Token : token[0] is unlocked by token[0]@b@01:04:45,470 [main] DEBUG GraphElement : event 'node-enter' on 'State(first)' for 'Token(/)'@b@01:04:45,471 [main] DEBUG GraphElement : event 'after-signal' on 'StartState(start)' for 'Token(/)'@b@01:04:45,471 [main] DEBUG GraphElement : event 'before-signal' on 'State(first)' for 'Token(/)'@b@01:04:45,471 [main] DEBUG GraphElement : event 'node-leave' on 'State(first)' for 'Token(/)'@b@01:04:45,472 [main] DEBUG GraphElement : event 'transition' on 'Transition(to_end)' for 'Token(/)'@b@01:04:45,472 [main] DEBUG GraphElement : executing action 'action[action]'@b@01:04:45,472 [main] DEBUG Token : token[0] is locked by token[0]@b@01:04:45,475 [main] DEBUG VariableContainer : update variable 'message' in 'TokenVariableMap1e0f4f' to value 'About to finish!'@b@message==========About to finish!@b@01:04:45,475 [main] DEBUG Token : token[0] is unlocked by token[0]@b@01:04:45,476 [main] DEBUG GraphElement : event 'node-enter' on 'EndState(end)' for 'Token(/)'@b@01:04:45,476 [main] DEBUG GraphElement : event 'process-end' on 'ProcessDefinition(simple)' for 'Token(/)'@b@01:04:45,476 [main] DEBUG GraphElement : event 'after-signal' on 'State(first)' for 'Token(/)'@b@=============end
另: 完整代码示例下载