<web-app xmlns="http://caucho.com/ns/resin">
  <!-- 
    - Instantiate an instance of PeriodTaskImpl and store it in jndi.
    - 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.
    -->
  <bean class="example.PeriodicTask"
        name="periodicTask"
        mbean-name="type=PeriodicTask"
        mbean-interface="example.PeriodicTask">
    <init>
      <estimated-average-time>5</estimated-average-time>
    </init>
  </bean>

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