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);
相关推荐
**JBPM5.4详解** JBPM,全称Java Business Process Management,是一个开源的工作流管理系统,专注于业务流程的建模、执行和监控。JBPM5.4是该系统的某一版本,它提供了强大的流程定义和执行能力,适用于企业级应用...
【JBPM5.4 SSH 完整项目整合案例】是一个基于Java企业级开发的实践项目,它涵盖了三个关键的技术栈:Struts2(S),Spring(S)和Hibernate(H),通常称为SSH框架。这个项目旨在展示如何将业务流程管理(BPM)工具...
**JBPM5.4工作流例子详解** JBPM(JBoss Business Process Management)是一个开源的工作流管理系统,主要用于处理业务流程的自动化。JBPM5.4是该系统的一个版本,它在之前的基础上进行了优化和增强,提供了更为...
SSH整合JBPM5.4是将Struts2、Spring3.1、Hibernate4.1这三大主流Java EE框架与业务流程管理(Business Process Management,简称BPM)工具JBPM5.4集成的过程。这个整合旨在提供一个高效、灵活且可扩展的企业级应用...
基于java及JBPM5.4流程引擎技术开发.鉴于JBPM5.4版本较新,而目前网上基本上没有对应的简单实例,更不要说负责案例及项目设计。 本课程是在国内没有任何中文文档的情况下,完全靠翻译国外的英文文档并结合项目应用...
SSH+jBPM5.4是一个基于Java的企业级应用开发框架组合,主要涵盖了Spring、Struts和Hibernate这三大组件,以及业务流程管理(Business Process Management,简称BPM)工具jbpm5.4。这个项目组合提供了从表现层到数据...
最近初学JBPM,费了很大的劲,因为网上的资料要么是代码,要么是文档,看了两天没有头绪,后来静了下来,仔细看代码和文档(通过代码学习文档,通过文档学习代码),再加上前两天知识的积蓄,终于对JBPM5.4,以及Spring+...
jbpm5.4_Final_Api.CHM
**JBPM5.4工作流与Eclipse流程插件安装详解** JBPM(Java Business Process Management)是一款开源的工作流管理系统,它提供了业务流程建模、部署、执行和监控的全面解决方案。JBPM5.4是该系统的一个稳定版本,...
SSH2结合JBPM5.4是企业级应用开发中的一项关键技术组合,主要涉及Spring、Struts2和Hibernate这三个核心框架与Business Process Management System (BPMS)的集成,特别是使用jbpm5.4版本。SSH2提供了强大的后端服务...
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 ...
基于java及JBPM5.4流程引擎技术开发.鉴于JBPM5.4版本较新,而目前网上基本上没有对应的简单实例,更不要说负责案例及项目设计。 本课程是在国内没有任何中文文档的情况下,完全靠翻译国外的英文文档并结合项目应用...
CSDN首发jBPM5.4 API文档,带索引
**JBPM5.4及Eclipse流程插件安装** JBPM(Java Business Process Management)是一个开源的工作流管理系统,主要用于业务流程的建模、部署、执行和监控。版本5.4是其历史上的一个重要里程碑,提供了丰富的功能和...
jbpm5.4与Spring MVC的集成是企业级应用开发中的常见组合,它结合了jbpm(业务流程管理)的强大功能和Spring MVC的灵活控制层架构。以下将详细阐述这一集成涉及的关键知识点: 1. **jbpm5.4**:jbpm是一个开源的...
基于java及JBPM5.4流程引擎技术开发.鉴于JBPM5.4版本较新,而目前网上基本上没有对应的简单实例,更不要说负责案例及项目设计。 本课程是在国内没有任何中文文档的情况下,完全靠翻译国外的英文文档并结合项目应用...
jbpm5.4信用卡发放流程源代码是一款基于jbpm5.4版本的工作流管理系统实现的信用卡审批流程示例。jbPM(Java Business Process Management)是一个开源的企业级工作流和业务流程管理框架,它允许开发者设计、执行和...
【JBPM教程第二部分:安装与配置JBPM5.4及Eclipse流程插件】 JBPM,全称为Java Business Process Management,是一个开源的工作流和业务流程管理(BPM)平台,它提供了完整的流程生命周期管理,包括设计、部署、...