JBPM5.4配置参考: http://panyongzheng.iteye.com/blog/1879279
本文参考: https://community.jboss.org/thread/201336
发送邮件的功能,只有三个控件,开始事件,邮件事件,结束时间。
dpmn文件:
java代码:
EmailWorkItemHandler emailHandler1 = new EmailWorkItemHandler();
emailHandler1.setConnection("smtp.163.com", "25", "abc@163.com", "123");
emailHandler1.getConnection().setStartTls(true);
ksession.getWorkItemManager().registerWorkItemHandler("Email", emailHandler1);
本文参考: https://community.jboss.org/thread/201336
发送邮件的功能,只有三个控件,开始事件,邮件事件,结束时间。
dpmn文件:
- <?xml version="1.0" encoding="UTF-8"?>
- <definitions id="Definition"
- targetNamespace="http://www.jboss.org/drools"
- typeLanguage="http://www.java.com/javaTypes"
- expressionLanguage="http://www.mvel.org/2.0"
- xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"
- xmlns:g="http://www.jboss.org/drools/flow/gpd"
- xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
- xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
- xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
- xmlns:tns="http://www.jboss.org/drools">
- <process processType="Private" isExecutable="true" id="com.sample.email.bpmn" name="Sample Process" tns:packageName="defaultPackage" >
- <!-- nodes -->
- <startEvent id="_1" name="StartProcess" />
- <endEvent id="_2" name="End" >
- <terminateEventDefinition/>
- </endEvent>
- <task id="_3" name="Email" tns:taskName="Email" >
- <ioSpecification>
- <dataInput id="_3_BodyInput" name="Body" />
- <dataInput id="_3_SubjectInput" name="Subject" />
- <dataInput id="_3_ToInput" name="To" />
- <dataInput id="_3_FromInput" name="From" />
- <inputSet>
- <dataInputRefs>_3_BodyInput</dataInputRefs>
- <dataInputRefs>_3_SubjectInput</dataInputRefs>
- <dataInputRefs>_3_ToInput</dataInputRefs>
- <dataInputRefs>_3_FromInput</dataInputRefs>
- </inputSet>
- <outputSet>
- </outputSet>
- </ioSpecification>
- <dataInputAssociation>
- <targetRef>_3_BodyInput</targetRef>
- <assignment>
- <from xsi:type="tFormalExpression">This is a test mail.</from>
- <to xsi:type="tFormalExpression">_3_BodyInput</to>
- </assignment>
- </dataInputAssociation>
- <dataInputAssociation>
- <targetRef>_3_SubjectInput</targetRef>
- <assignment>
- <from xsi:type="tFormalExpression">JBPM5.4 Email Event</from>
- <to xsi:type="tFormalExpression">_3_SubjectInput</to>
- </assignment>
- </dataInputAssociation>
- <dataInputAssociation>
- <targetRef>_3_ToInput</targetRef>
- <assignment>
- <from xsi:type="tFormalExpression">1453261799@qq.com</from>
- <to xsi:type="tFormalExpression">_3_ToInput</to>
- </assignment>
- </dataInputAssociation>
- <dataInputAssociation>
- <targetRef>_3_FromInput</targetRef>
- <assignment>
- <from xsi:type="tFormalExpression">pandy_test@163.com</from>
- <to xsi:type="tFormalExpression">_3_FromInput</to>
- </assignment>
- </dataInputAssociation>
- </task>
- <!-- connections -->
- <sequenceFlow id="_3-_2" sourceRef="_3" targetRef="_2" />
- <sequenceFlow id="_1-_3" sourceRef="_1" targetRef="_3" />
- </process>
- <bpmndi:BPMNDiagram>
- <bpmndi:BPMNPlane bpmnElement="com.sample.email.bpmn" >
- <bpmndi:BPMNShape bpmnElement="_1" >
- <dc:Bounds x="47" y="157" width="48" height="48" />
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape bpmnElement="_2" >
- <dc:Bounds x="704" y="150" width="48" height="48" />
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape bpmnElement="_3" >
- <dc:Bounds x="349" y="156" width="100" height="48" />
- </bpmndi:BPMNShape>
- <bpmndi:BPMNEdge bpmnElement="_3-_2" >
- <di:waypoint x="399" y="180" />
- <di:waypoint x="728" y="174" />
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge bpmnElement="_1-_3" >
- <di:waypoint x="71" y="181" />
- <di:waypoint x="399" y="180" />
- </bpmndi:BPMNEdge>
- </bpmndi:BPMNPlane>
- </bpmndi:BPMNDiagram>
- </definitions>
<?xml version="1.0" encoding="UTF-8"?> <definitions id="Definition" targetNamespace="http://www.jboss.org/drools" typeLanguage="http://www.java.com/javaTypes" expressionLanguage="http://www.mvel.org/2.0" xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" xmlns:g="http://www.jboss.org/drools/flow/gpd" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.jboss.org/drools"> <process processType="Private" isExecutable="true" id="com.sample.email.bpmn" name="Sample Process" tns:packageName="defaultPackage" > <!-- nodes --> <startEvent id="_1" name="StartProcess" /> <endEvent id="_2" name="End" > <terminateEventDefinition/> </endEvent> <task id="_3" name="Email" tns:taskName="Email" > <ioSpecification> <dataInput id="_3_BodyInput" name="Body" /> <dataInput id="_3_SubjectInput" name="Subject" /> <dataInput id="_3_ToInput" name="To" /> <dataInput id="_3_FromInput" name="From" /> <inputSet> <dataInputRefs>_3_BodyInput</dataInputRefs> <dataInputRefs>_3_SubjectInput</dataInputRefs> <dataInputRefs>_3_ToInput</dataInputRefs> <dataInputRefs>_3_FromInput</dataInputRefs> </inputSet> <outputSet> </outputSet> </ioSpecification> <dataInputAssociation> <targetRef>_3_BodyInput</targetRef> <assignment> <from xsi:type="tFormalExpression">This is a test mail.</from> <to xsi:type="tFormalExpression">_3_BodyInput</to> </assignment> </dataInputAssociation> <dataInputAssociation> <targetRef>_3_SubjectInput</targetRef> <assignment> <from xsi:type="tFormalExpression">JBPM5.4 Email Event</from> <to xsi:type="tFormalExpression">_3_SubjectInput</to> </assignment> </dataInputAssociation> <dataInputAssociation> <targetRef>_3_ToInput</targetRef> <assignment> <from xsi:type="tFormalExpression">1453261799@qq.com</from> <to xsi:type="tFormalExpression">_3_ToInput</to> </assignment> </dataInputAssociation> <dataInputAssociation> <targetRef>_3_FromInput</targetRef> <assignment> <from xsi:type="tFormalExpression">pandy_test@163.com</from> <to xsi:type="tFormalExpression">_3_FromInput</to> </assignment> </dataInputAssociation> </task> <!-- connections --> <sequenceFlow id="_3-_2" sourceRef="_3" targetRef="_2" /> <sequenceFlow id="_1-_3" sourceRef="_1" targetRef="_3" /> </process> <bpmndi:BPMNDiagram> <bpmndi:BPMNPlane bpmnElement="com.sample.email.bpmn" > <bpmndi:BPMNShape bpmnElement="_1" > <dc:Bounds x="47" y="157" width="48" height="48" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="_2" > <dc:Bounds x="704" y="150" width="48" height="48" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="_3" > <dc:Bounds x="349" y="156" width="100" height="48" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge bpmnElement="_3-_2" > <di:waypoint x="399" y="180" /> <di:waypoint x="728" y="174" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="_1-_3" > <di:waypoint x="71" y="181" /> <di:waypoint x="399" y="180" /> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </definitions>
java代码:
- package com.gds.web;
- import static org.springframework.web.bind.annotation.RequestMethod.GET;
- import static org.springframework.web.bind.annotation.RequestMethod.POST;
- import static org.springframework.web.bind.annotation.RequestMethod.PUT;
- import java.io.ByteArrayOutputStream;
- import java.io.IOException;
- import java.io.ObjectOutputStream;
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.List;
- import java.util.Map;
- import javax.annotation.Resource;
- import org.apache.log4j.Logger;
- import org.drools.command.Context;
- import org.drools.command.impl.GenericCommand;
- import org.drools.command.impl.KnowledgeCommandContext;
- import org.drools.runtime.StatefulKnowledgeSession;
- import org.drools.runtime.process.WorkflowProcessInstance;
- import org.jbpm.process.core.context.variable.VariableScope;
- import org.jbpm.process.instance.context.variable.VariableScopeInstance;
- import org.jbpm.process.workitem.email.EmailWorkItemHandler;
- import org.jbpm.process.workitem.wsht.LocalHTWorkItemHandler;
- import org.jbpm.task.Task;
- import org.jbpm.task.TaskData;
- import org.jbpm.task.TaskService;
- import org.jbpm.task.query.TaskSummary;
- import org.jbpm.task.service.ContentData;
- import org.jbpm.task.utils.ContentMarshallerHelper;
- import org.springframework.beans.factory.annotation.Qualifier;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.Model;
- import org.springframework.web.bind.annotation.ModelAttribute;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RequestMapping;
- import com.gds.jbpm.MyLocalTaskService;
- import com.gds.jbpm.Order;
- @Controller
- public class EmailController {
- private Logger log = Logger.getLogger(this.getClass());
- @Resource
- @Qualifier("myLocalTaskService")
- private MyLocalTaskService myLocalTaskService;
- @Resource
- @Qualifier("ksession")
- private StatefulKnowledgeSession ksession;
- public void registerWorkItemHandler() {
- LocalHTWorkItemHandler humanTaskHandler = new LocalHTWorkItemHandler(
- myLocalTaskService.getLocalTaskService(), ksession);
- humanTaskHandler.setLocal(true);
- humanTaskHandler.connect();
- ksession.getWorkItemManager().registerWorkItemHandler("Human Task",
- humanTaskHandler);
- System.out
- .println("----------------------------------------------------->LocalHTWorkItemHandler");
- EmailWorkItemHandler emailHandler1 = new EmailWorkItemHandler();
- emailHandler1.setConnection("smtp.163.com", "25", "abc@163.com", "123");
- emailHandler1.getConnection().setStartTls(true);
- ksession.getWorkItemManager().registerWorkItemHandler("Email", emailHandler1);
- System.out
- .println("----------------------------------------------------->EmailWorkItemHandler");
- }
- @RequestMapping(value = "email.do", method = { GET, POST, PUT })
- public String doCreate(Model model) {
- System.out.println("JBPM5.4的邮件测试");
- ksession = myLocalTaskService.getKsession();
- registerWorkItemHandler();
- ksession.startProcess("com.sample.email.bpmn");
- ksession.fireAllRules();
- model.addAttribute("message", "process created!");
- return "create";
- }
- }
package com.gds.web; import static org.springframework.web.bind.annotation.RequestMethod.GET; import static org.springframework.web.bind.annotation.RequestMethod.POST; import static org.springframework.web.bind.annotation.RequestMethod.PUT; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import javax.annotation.Resource; import org.apache.log4j.Logger; import org.drools.command.Context; import org.drools.command.impl.GenericCommand; import org.drools.command.impl.KnowledgeCommandContext; import org.drools.runtime.StatefulKnowledgeSession; import org.drools.runtime.process.WorkflowProcessInstance; import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.process.instance.context.variable.VariableScopeInstance; import org.jbpm.process.workitem.email.EmailWorkItemHandler; import org.jbpm.process.workitem.wsht.LocalHTWorkItemHandler; import org.jbpm.task.Task; import org.jbpm.task.TaskData; import org.jbpm.task.TaskService; import org.jbpm.task.query.TaskSummary; import org.jbpm.task.service.ContentData; import org.jbpm.task.utils.ContentMarshallerHelper; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import com.gds.jbpm.MyLocalTaskService; import com.gds.jbpm.Order; @Controller public class EmailController { private Logger log = Logger.getLogger(this.getClass()); @Resource @Qualifier("myLocalTaskService") private MyLocalTaskService myLocalTaskService; @Resource @Qualifier("ksession") private StatefulKnowledgeSession ksession; public void registerWorkItemHandler() { LocalHTWorkItemHandler humanTaskHandler = new LocalHTWorkItemHandler( myLocalTaskService.getLocalTaskService(), ksession); humanTaskHandler.setLocal(true); humanTaskHandler.connect(); ksession.getWorkItemManager().registerWorkItemHandler("Human Task", humanTaskHandler); System.out .println("----------------------------------------------------->LocalHTWorkItemHandler"); EmailWorkItemHandler emailHandler1 = new EmailWorkItemHandler(); emailHandler1.setConnection("smtp.163.com", "25", "abc@163.com", "123"); emailHandler1.getConnection().setStartTls(true); ksession.getWorkItemManager().registerWorkItemHandler("Email", emailHandler1); System.out .println("----------------------------------------------------->EmailWorkItemHandler"); } @RequestMapping(value = "email.do", method = { GET, POST, PUT }) public String doCreate(Model model) { System.out.println("JBPM5.4的邮件测试"); ksession = myLocalTaskService.getKsession(); registerWorkItemHandler(); ksession.startProcess("com.sample.email.bpmn"); ksession.fireAllRules(); model.addAttribute("message", "process created!"); return "create"; } }
EmailWorkItemHandler emailHandler1 = new EmailWorkItemHandler();
emailHandler1.setConnection("smtp.163.com", "25", "abc@163.com", "123");
emailHandler1.getConnection().setStartTls(true);
ksession.getWorkItemManager().registerWorkItemHandler("Email", emailHandler1);
相关推荐
基于java及JBPM5.4流程引擎技术开发.鉴于JBPM5.4版本较新,而目前网上基本上没有对应的简单实例,更不要说负责案例及项目设计。 本课程是在国内没有任何中文文档的情况下,完全靠翻译国外的英文文档并结合项目应用...
这些是JBPM5.4 的一些例子。 jbpm5.4 资料实在少的可怜 希望可以帮助到大家学习
整合struts2.3,spring3.1,hibernate4.1,jbpm5.4,mysql5.1.22部署到jboss7.1上的所有jar包
最近初学JBPM,费了很大的劲,因为网上的资料要么是代码,要么是文档,看了两天没有头绪,后来静了下来,仔细看代码和文档(通过代码学习文档,通过文档学习代码),再加上前两天知识的积蓄,终于对JBPM5.4,以及Spring+...
jbpm5.4_Final_Api.CHM
JBPM5.4例子,已经能够运行。使用MYSQL数据库。
jbpm教程 第二部分、(安装和配置JBPM5.4及Eclipse流程插件安装)
jBPM is a flexible Business Process Management (BPM) Suite. It's light-weight, fully open-source (distributed under Apache license) and written in Java. It allows you to model, execute and monitor ...
完整项目案例 包含完整架包 和数据库表结构 以及完整数据 在eclipse和myeclipse都可以完美运行 下载后遇到问题 可以给我留言解决
基于java及JBPM5.4流程引擎技术开发.鉴于JBPM5.4版本较新,而目前网上基本上没有对应的简单实例,更不要说负责案例及项目设计。 本课程是在国内没有任何中文文档的情况下,完全靠翻译国外的英文文档并结合项目应用...
CSDN首发jBPM5.4 API文档,带索引
基于java及JBPM5.4流程引擎技术开发.鉴于JBPM5.4版本较新,而目前网上基本上没有对应的简单实例,更不要说负责案例及项目设计。 本课程是在国内没有任何中文文档的情况下,完全靠翻译国外的英文文档并结合项目应用...
jbpm5.4 spring mvc 集成开发 Jetty maven JTA 事务等配置!
第四部分、SSH2结合JBPM5.4
本套JBPM5.4工作流是在国内没有任何中文文档的情况下,完全靠翻译国外的英文文档并结合项目应用进行开发的,是一套绝对的经典课程。
JBPM教程 第四部分、SSH2结合JBPM5.4
安装和配置JBPM5.4及Eclipse流程插件安装
jbpm5.4信用卡发放流程源代码 演示: 信用卡发放流程测试 请输入您的月收入: 6000 您的收入是:6000元,恭喜,您符合信用卡发放条件!
安装和配置JBPM5.4及Eclipse流程插件安装。这个课程本来是收费的,我买了以后免费提供给网友们学习。