<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 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">
    <display-name>hand-hap</display-name>
    <description>hand-hap</description>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:/spring/applicationContext*.xml</param-value>
    </context-param>
    <context-param>
        <param-name>spring.profiles.default</param-name>
        <param-value>default</param-value>
    </context-param>
    <context-param>
        <param-name>contextInitializerClasses</param-name>
        <param-value>com.hand.hap.core.CustomApplicationContextInitializer</param-value>
    </context-param>
    <context-param>
        <param-name>propertiesFile</param-name>
        <param-value>classpath:/config.properties</param-value>
    </context-param>

    <listener>
        <listener-class>com.hand.hap.core.web.HapContextLoadListener</listener-class>
    </listener>

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

    <filter>
        <filter-name>cors</filter-name>
        <filter-class>com.hand.hap.security.CORSFilter</filter-class>
        <async-supported>true</async-supported>
        <init-param>
            <param-name>allowedMappings</param-name>
            <param-value>/oauth/**;/api/**;/r/api/**</param-value>
        </init-param>
        <init-param>
            <param-name>allowedHeader</param-name>
            <param-value>*</param-value>
        </init-param>
        <init-param>
            <param-name>allowedOrigin</param-name>
            <param-value>*</param-value>
        </init-param>
        <init-param>
            <param-name>allowedMethod</param-name>
            <param-value>*</param-value>
        </init-param>
        <!--<init-param>-->
            <!--<param-name>allowCredentials</param-name>-->
            <!--<param-value>true</param-value>-->
        <!--</init-param>-->
        <!--<init-param>-->
            <!--<param-name>maxAge</param-name>-->
            <!--<param-value>3600</param-value>-->
        <!--</init-param>-->
        <!--<init-param>-->
        <!--<param-name>exposedHeader</param-name>-->
        <!--<param-value>header1;header2</param-value>-->
        <!--</init-param>-->
    </filter>
    <filter-mapping>
        <filter-name>cors</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter>
        <filter-name>encodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
       <async-supported>true</async-supported>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter>
        <filter-name>hap-enhance</filter-name>
        <filter-class>com.hand.hap.core.web.HapEnhanceFilter</filter-class>
        <async-supported>true</async-supported>
    </filter>
    <filter-mapping>
        <filter-name>hap-enhance</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter>
        <filter-name>spring-session</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        <async-supported>true</async-supported>
        <init-param>
            <param-name>targetBeanName</param-name>
            <param-value>springSession</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>spring-session</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter>
        <filter-name>preRequestFilter</filter-name>
        <filter-class>com.hand.hls.filter.GlobalExceptionFilter</filter-class>
        <async-supported>true</async-supported>
    </filter>
    <filter-mapping>
        <filter-name>preRequestFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <!--spring security配置-->
    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        <async-supported>true</async-supported>
    </filter>

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

    <!-- metrics.servlet -->
    <filter>
        <filter-name>instrumentedFilter</filter-name>
        <filter-class>com.codahale.metrics.servlet.InstrumentedFilter</filter-class>
        <async-supported>true</async-supported>
    </filter>
    <filter-mapping>
        <filter-name>instrumentedFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <!--
    Included to support Single Logout. Note that the SingleSignOutFilter is included in the
    springSecurityFilterChain. However, it could also be placed as the first filter-mapping
    in the web.xml
    启用CAS SSO时添加下面的配置
    -->
    <!--
        <listener>
            <listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListener</listener-class>
        </listener>
     -->
    <!--<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>-->

    <!-- <filter> <filter-name>csrfFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        <async-supported>true</async-supported> </filter> <filter-mapping> <filter-name>csrfFilter</filter-name>
        <url-pattern>/*</url-pattern> </filter-mapping> -->

    <!-- leaf-->
    <servlet>
        <servlet-name>service</servlet-name>
        <servlet-class>leaf.service.http.FacadeServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>autocrud</servlet-name>
        <servlet-class>leaf.service.http.AutoCrudServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>service</servlet-name>
        <url-pattern>*.lview</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>service</servlet-name>
        <url-pattern>*.lsc</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>autocrud</servlet-name>
        <url-pattern>/autocrud/*</url-pattern>
    </servlet-mapping>
    <!-- leaf end-->

    <servlet>
        <servlet-name>CXFServlet</servlet-name>
        <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
        <async-supported>true</async-supported>
    </servlet>
    <servlet-mapping>
        <servlet-name>CXFServlet</servlet-name>
        <url-pattern>/ws/*</url-pattern>
    </servlet-mapping>


    <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:/spring/appServlet/servlet*.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
        <async-supported>true</async-supported>
    </servlet>

    <servlet-mapping>
        <servlet-name>appServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <!-- metrics.servlet -->
    <servlet>
        <servlet-name>metrics</servlet-name>
        <servlet-class>com.codahale.metrics.servlets.AdminServlet</servlet-class>
        <async-supported>true</async-supported>
    </servlet>
    <servlet-mapping>
        <servlet-name>metrics</servlet-name>
        <url-pattern>/metrics/*</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>jacob</servlet-name>
        <servlet-class>hls.plugin.jacob.servlet.OfficeConvertServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>jacob</servlet-name>
        <url-pattern>/jacob/*</url-pattern>
    </servlet-mapping>




    <!--<servlet>-->
        <!--<servlet-name>ureportServlet</servlet-name>-->
        <!--<servlet-class>com.bstek.ureport.console.UReportServlet</servlet-class>-->
    <!--</servlet>-->
    <!--<servlet-mapping>-->
        <!--<servlet-name>ureportServlet</servlet-name>-->
        <!--<url-pattern>/ureport/*</url-pattern>-->
    <!--</servlet-mapping>-->
    <error-page>
        <error-code>400</error-code>
        <location>/500.html</location>
    </error-page>
    <error-page>
        <error-code>401</error-code>
        <location>/500.html</location>
    </error-page>
    <error-page>
        <error-code>404</error-code>
        <location>/500.html</location>
    </error-page>
    <error-page>
        <error-code>403</error-code>
        <location>/500.html</location>
    </error-page>
    <error-page>
        <error-code>500</error-code>
        <location>/500.html</location>
    </error-page>

</web-app>