activiti5.18集成

新版本5.17,5.18与之前版本有点区别,写说说集成。以前版本的集成已经有不少例子了。新版本的集成能够先下载http://repo1.maven.org/maven2/org/activiti activiti-webapp-explorer2 里面的源码,复制到项目便可。因为新版本使用了servlet3.0java配置servlet。若是使用不支持3.0的容器,能够使用手动在web.xml中添加springmvc和spring的配置。java

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0">
    
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:application-context.xml</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!--
        Spring Security Filter Chain. This filter-name must not be changed.
        The <http> namespace creates a Spring bean with this name and the DelegatingFilterProxy
        will use this filter-name to delegate to the bean.
     -->
    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <servlet>
        <servlet-name>RestFulServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/spring-servlet.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    
    <servlet-mapping>
        <servlet-name>RestFulServlet</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>


</web-app>

这里把下载的java文件依旧加入工程,在spring中配置扫描 <context:component-scan base-package="org.activiti.rest" />便可。 这里为了简便直接使用了spring的父容器加载spring mvc的controller,你们在集成的时候能够把spring mvc的分开扫描。web

顺便说一下新版本的接口变化,rest接口,从之前使用restlet框架改为了springmvc,因此在集成modeler的时候使用到接口,从配置restlet改为spring mvc就能够。 不过3.0中的初始化在servlet中加入了异步的属性,如下版本没办法,只能暂时先不配进去,后面你们有什么好方法能够借鉴,还有新版本的接口验证使用spring Security 的basic验证,你们能够考虑着加入。 其实总的来讲从集成上,主要是把spring的配置从xml改为了java配置,并使用了servlet3.0的特性其余基本仍是同样。因此主要从这几个地方作修改便可。spring