<?xml version="1.0"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF 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.
-->

<!--
  CVS $Id: sitemap.xmap 433543 2006-08-22 06:22:54Z crossley $

  Event Cache Sample
-->

<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
  <map:components>
    <map:matchers default="wildcard">
        <map:matcher name="host-matcher"
                     logger="sitemap.matcher.wildcard"
                     src="org.apache.cocoon.matching.modular.CachingWildcardMatcher">
          <input-module name="request"/>
          <parameter-name>serverName</parameter-name>
        </map:matcher>
    </map:matchers>
    <map:actions>
      <map:action name="cacheevent" src="org.apache.cocoon.acting.CacheEventAction"/>
      <map:action name="jmsevent"
                  src="org.apache.cocoon.acting.JMSPublisherAction"
                  logger="sitemap.actions.jms">
        <parameter name="connection" value="local-topics"/>
        <parameter name="topic" value="topic1"/>
      </map:action>
    </map:actions>

    <map:pipes default="caching">
    <!-- A pipe must be defined configured to use the EventAware cache. -->
      <map:pipe name="event-aware" src="org.apache.cocoon.components.pipeline.impl.CachingProcessingPipeline">
        <parameter name="cache-role" value="org.apache.cocoon.caching.Cache/EventAware"/>
      </map:pipe>
    </map:pipes>
  </map:components>

  <map:views>
    <map:view from-label="content" name="content">
      <map:serialize type="xml"/>
    </map:view>
  </map:views>

  <map:pipelines>

    <!-- Our content must occur in a pipeline configured to use our Event Aware cache -->
    <map:pipeline type="event-aware">
      <map:match pattern="eventcache">
        <map:generate type="serverpages" src="{0}.xsp"/>
      <map:transform src="context://samples/stylesheets/dynamic-page2html.xsl">
          <map:parameter name="servletPath" value="{request:servletPath}"/>
          <map:parameter name="sitemapURI" value="{request:sitemapURI}"/>
          <map:parameter name="contextPath" value="{request:contextPath}"/>
          <map:parameter name="file" value="{0}.xsp"/>
          <map:parameter name="remove" value="{0}"/>
      </map:transform>
        <map:serialize/>
      </map:match>
    </map:pipeline>

    <map:pipeline>

      <map:match pattern="">
        <map:redirect-to uri="eventcache"/>
      </map:match>

    <map:match pattern="invalidate">
        <map:match type="host-matcher" pattern="localhost">
            <map:act type="cacheevent">
                <map:parameter name="event" value="{request-param:table}"/>
            </map:act>
            <map:read src="invalidated.xml"/>
        </map:match>
        <map:read src="access-error.xml"/>
    </map:match>

    <map:match pattern="jms-invalidate">
        <map:match type="host-matcher" pattern="localhost">
            <map:act type="jmsevent">
                <map:parameter name="message" value="action|{request-param:table}"/>
            </map:act>
            <map:read src="invalidated.xml"/>
        </map:match>
        <map:read src="access-error.xml"/>
    </map:match>

      <map:match pattern="*">
        <map:generate type="serverpages" src="{1}.xsp"/>
      <map:transform src="context://samples/stylesheets/dynamic-page2html.xsl">
          <map:parameter name="servletPath" value="{request:servletPath}"/>
          <map:parameter name="sitemapURI" value="{request:sitemapURI}"/>
          <map:parameter name="contextPath" value="{request:contextPath}"/>
          <map:parameter name="file" value="{1}.xsp"/>
          <map:parameter name="remove" value="{0}"/>
      </map:transform>
        <map:serialize/>
      </map:match>
    </map:pipeline>

  </map:pipelines>
</map:sitemap>

