<web-app xmlns="http://caucho.com/ns/resin"
        xmlns:ee="urn:java:ee"
        xmlns:example="urn:java:example">
  <!-- 
    - Instantiate an instance of PeriodTaskImpl and store it in Java Injection
    - The periodic task is then available for use in the various ways
    - illustrated below.
    -
    - The interface for PeriodicTaskImpl is PeriodicTask, which is the
    - view of the object provided to users of the service.
    -->
  <example:PeriodicTask>
    <ee:Named>periodicTask</ee:Named>
    <!--
        mbean-name="type=PeriodicTask"
        mbean-interface="example.PeriodicTask">
      -->
    <estimated-average-time>5</estimated-average-time>
  </example:PeriodicTask>

  <!-- 
     - servlet to manage the PeriodicTask
    -->

  <servlet>
    <servlet-name>PeriodicTaskServlet</servlet-name>
    <servlet-class>example.PeriodicTaskServlet</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>PeriodicTaskServlet</servlet-name>
    <url-pattern>/admin/periodictask</url-pattern>
  </servlet-mapping>

  <!-- 
     - run() the PeriodicTask every minute 
    -->
  <scheduled-task class="example.PeriodicTask">
    <cron>*</cron>
  </scheduled-task>

  <!-- 
     - filter to show an unavailable page if the PeriodicTask is active 
    -->

  <filter>
    <filter-name>PeriodicTaskFilter</filter-name>
    <filter-class>example.PeriodicTaskFilter</filter-class>
    <init>
      <periodic-task>${periodicTask}</periodic-task>
      <!-- optional url, if not specified a 503 response is sent. -->
      <url>/unavailable.jsp</url>
    </init>
  </filter>

  <filter-mapping>
    <!-- regexp to match all urls except /admin and /index.xtp-->
    <filter-name>PeriodicTaskFilter</filter-name>
    <url-regexp>^(?!/admin|/index.xtp)+</url-regexp>
  </filter-mapping>

</web-app>
