<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2010-2013 Ning, Inc.
  ~ Copyright 2014-2015 Groupon, Inc
  ~ Copyright 2014-2015 The Billing Project, LLC
  ~
  ~ The Billing Project licenses this file to you under the Apache License, version 2.0
  ~ (the "License"); you may not use this file except in compliance with the
  ~ License.  You may obtain a copy of the License at:
  ~
  ~    http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  ~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
  ~ License for the specific language governing permissions and limitations
  ~ under the License.
  -->

<web-app
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://java.sun.com/xml/ns/javaee"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        version="2.5">
    <filter>
        <filter-name>instrumentedFilter</filter-name>
        <filter-class>com.codahale.metrics.servlet.InstrumentedFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>instrumentedFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter>
        <!-- Filter all requests through Shiro -->
        <filter-name>ShiroFilter</filter-name>
        <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
    </filter>
    <filter-mapping>
        <!-- The Shiro filter-mapping should come first -->
        <filter-name>ShiroFilter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
        <dispatcher>ERROR</dispatcher>
    </filter-mapping>
    <filter>
        <!-- Guice emulates Servlet API with DI -->
        <filter-name>guiceFilter</filter-name>
        <filter-class>org.killbill.billing.server.filters.KillbillGuiceFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>guiceFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <listener>
        <!-- Jersey insists on using java.util.logging (JUL) -->
        <listener-class>org.killbill.commons.skeleton.listeners.JULServletContextListener</listener-class>
    </listener>
    <listener>
        <!-- Context listener: called at startup time and creates the injector -->
        <listener-class>org.killbill.billing.server.listeners.KillbillGuiceListener</listener-class>
    </listener>
    <listener>
        <!-- Context listener: called at shutdown time and performs cleanup tasks -->
        <listener-class>org.killbill.billing.server.listeners.CleanupListener</listener-class>
    </listener>

    <!-- ServletHandler#handle requires a backend servlet. Besides, this will also be used to serve static resources,
         such as the favicon or the welcome page -->
    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>
