<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2010-2013 Ning, Inc.
  ~
  ~ Ning 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 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>com.ning.jetty.core.listeners.SetupJULBridge</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>

    <!-- 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>
