关闭

Activiti工作流配置在项目Web中的始化和销毁

68人阅读 评论(0) 收藏 举报
分类:

       在项目启动的时候需要启动相关的activiti服务,在activiti通过使用servletcontextlistener实现在项目启动相关的服务。
package org.activiti.rest.servlet;

 

import java.util.logging.Level;

import java.util.logging.Logger;

 

import javax.servlet.ServletContextEvent;

import javax.servlet.ServletContextListener;

 

import org.activiti.engine.ProcessEngine;

import org.activiti.engine.ProcessEngines;

import org.activiti.engine.impl.util.LogUtil;

 

/**

 * @author Tijs Rademakers

 */

public class ActivitiServletContextListener implements ServletContextListener {

 

  //Initialise logging

  static {

    LogUtil.readJavaUtilLoggingConfigFromClasspath();

  }

 

  protected static final Logger LOGGER = Logger.getLogger(ActivitiServletContextListener.class.getName());

 

  public void contextInitialized(ServletContextEvent event) {

    ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();

    if (processEngine == null) {

      LOGGER.log(Level.SEVERE,"Could not start the Activiti Engine");

    }

  }

 

  public void contextDestroyed(ServletContextEvent event) {

    ProcessEngines.destroy();

  }

 

}

web.xml配置如下:
<?xml version="1.0" encoding="UTF-8"?> 

<web-app id="WebApp_ID" version="2.4" 

            xmlns="http://java.sun.com/xml/ns/j2ee" 

            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

            xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 

                 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 

 

  <display-name>Activiti REST</display-name>

  

  <listener>

    <listener-class>org.activiti.rest.servlet.ActivitiServletContextListener</listener-class>

  </listener>

 

  <!-- Restlet adapter --> 

  <servlet> 

    <servlet-name>RestletServlet</servlet-name> 

    <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>

    <init-param>

      <!-- Application class name -->

      <param-name>org.restlet.application</param-name>

      <param-value>org.activiti.rest.application.ActivitiRestApplication</param-value>

    </init-param>

  </servlet>

 

  <!-- Catch all requests --> 

  <servlet-mapping> 

    <servlet-name>RestletServlet</servlet-name> 

    <url-pattern>/service/*</url-pattern> 

  </servlet-mapping> 

</web-app>

 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:22093次
    • 积分:710
    • 等级:
    • 排名:千里之外
    • 原创:38篇
    • 转载:75篇
    • 译文:0篇
    • 评论:0条
    文章分类