Jbpm4.4 Mail配置

一 开发环境

ü  Tomcat6.0

ü  JDK1.6.0_15

ü  Eclipse 3.6.0

ü  JBPM4.4

二 前提

假设你已经把Jbpm ssh 整合到一起了。如果没有,请看我的上一篇文章。

三 步骤

1. 1   Jbpm.cfg.xml文件

<?xml version="1.0" encoding="UTF-8"?>

<jbpm-configuration>

<!--

  <import resource="jbpm.default.cfg.xml" /> -->

   <import resource="jbpm.customer.cfg.xml" /> 

  <import resource="jbpm.businesscalendar.cfg.xml" />

  <import resource ="jbpm.tx.spring.cfg.xml" />

  <import resource="jbpm.jpdl.cfg.xml" />

  <import resource="jbpm.bpmn.cfg.xml" />

  <import resource="jbpm.identity.cfg.xml" />

 

  <!-- Job executor is excluded for running the example test cases. -->

  <!-- To enable timers and messages in production use, this should be included. -->

  <!--

  <import resource="jbpm.jobexecutor.cfg.xml" />

  -->

</jbpm-configuration>

jbpm.default.cfg.xml 文件注释掉是因为要配置 mail-server  的一些属性。

1.2 jbpm.customer.cfg.xml

复制 jbpm.default.cfg.xml内容到 Jbpm.customer.cfg.xml配置文件。并替换如下地方。

 

<mail-session>

       <mail-server>

         <session-properties resource= "jbpm.mail.properties"  />

         <authenticator class= "com.framework.mail.MyAuthenticator" >

          <field name= "userName" ><string value= " test " /></field>

          <field   name= "passWord" ><string value= " 123 " /></field>

         </authenticator>

       </mail-server>

     </mail-session>

1.3  MyAuthenticator

package  com.framework.mail;

 

import  javax.mail.Authenticator;

import  javax.mail.PasswordAuthentication;

 

public   class  MyAuthenticator  extends  Authenticator {

 

public  MyAuthenticator(){

System. out .println( "自定义验证器加载..." );

}

 

private   String   userName ;

private   String   passWord ;

 

 

/**

 *  @param  userName the userName to set

 */

public   void  setUserName( String  userName) {

this . userName  = userName;

}

 

 

/**

 *  @param  passWord the passWord to set

 */

public   void  setPassWord( String  passWord) {

this . passWord  = passWord;

}

 

 

/* (non- Javadoc )

 * @see javax.mail.Authenticator#getPasswordAuthentication()

 */

@Override

protected  PasswordAuthentication getPasswordAuthentication() {

 

return   new  PasswordAuthentication( userName , passWord );

}

 

}

 

1.4 Jbpm.mail.properties

mail.smtp.host= smtp .163. com

mail.smtp.port= 25

mail.from= lyfvslw @163. com

mail.smtp.auth=  true

1.5 流程定义文件 mail.jpdl.xml

<? xml   version = "1.0"   encoding = "UTF-8" ?>

 

< process   name = "TemplateMail"   xmlns = "http://jbpm.org/4.4/jpdl" >

 

   < start   g = "20,25,80,40" >

     < transition   to = "send rectify note" />

   </ start >

 

   < mail   g = "99,25,115,45"   name = "send rectify note"   template = "rectify-template" >

     < transition   to = "wait" />

   </ mail >

 

   < state   g = "240,25,98,45"   name = "wait" />

 

</process>

1.6 测试类。

package com.tds.jbpm.mail;

 

import java.util.Date;

import java.util.HashMap;

import java.util.Map;

 

import org.jbpm.api.ExecutionService;

import org.jbpm.api.ProcessEngine;

import org.jbpm.api.ProcessInstance;

import org.jbpm.api.TaskService;

import org.springframework.context.support.ClassPathXmlApplicationContext;

 

public class Test {

 

public static void main(String[] args) {

ClassPathXmlApplicationContext applicationContext =new ClassPathXmlApplicationContext("applicationContext.xml");

applicationContext.start();

    ProcessEngine processEngine = (ProcessEngine)applicationContext.getBean("processEngine");

    ExecutionService executionService = processEngine.getExecutionService();

    TaskService taskService = processEngine.getTaskService();

 

    //发布流程

   /* String deploymentId = processEngine.getRepositoryService().createDeployment()

    .addResourceFromClasspath("mail.jpdl.xml").deploy();

    System.out.println("流程发布 ID:"+deploymentId);*/

    

    String addressee = "350372916@qq.com";

    String newspaper="恭喜你 ";

    Date date=new Date();

    String details="继续加油吧 ";

    

    Map<String,Object> variables =new HashMap<String,Object>();

    variables.put("addressee", addressee);

    variables.put("newspaper", newspaper);

    variables.put("date", date);

    variables.put("details", details);

    

    //启动一个流程实例

    ProcessInstance processInstance = executionService.startProcessInstanceByKey("TemplateMail",variables);

    System.out.println("流程实例 ID:" + processInstance.getId());

}

}

 

以上就是JBPM 邮件的配置。

 

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值