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

       在项目启动的时候需要启动相关的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>

 

阅读更多
个人分类: 企业中间件
想对作者说点什么? 我来说一句

Activiti工作流学习demo项目源码

2017年10月30日 93KB 下载

没有更多推荐了,返回首页

不良信息举报

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

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭