Modified: 
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/DispatcherHelper.java
URL: 
http://svn.apache.org/viewvc/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/DispatcherHelper.java?rev=694101&r1=694100&r2=694101&view=diff
==============================================================================
--- 
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/DispatcherHelper.java
 (original)
+++ 
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/DispatcherHelper.java
 Wed Sep 10 20:45:49 2008
@@ -27,10 +27,10 @@
 import javax.xml.transform.TransformerFactory;
 
 import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.xml.XMLUtils;
 import org.apache.cocoon.xml.dom.DOMBuilder;
 import org.apache.excalibur.source.SourceNotFoundException;
+import org.apache.excalibur.source.SourceResolver;
 import org.apache.forrest.dispatcher.lenya.xml.NamespaceHelper;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Document;
@@ -53,7 +53,7 @@
 
     private NamespaceHelper namespaceHelper;
 
-    private ServiceManager manager;
+    private SourceResolver resolver;
 
     /**
      * Create a DOM representation of this dispatcher.
@@ -72,7 +72,7 @@
      */
     public Document getDocument(String uri) throws Exception {
         Document doc = org.apache.forrest.dispatcher.util.SourceUtil.readDOM(
-                uri, this.manager);
+                uri, this.resolver);
         if (doc != null) {
             this.namespaceHelper = new NamespaceHelper(
                     DISPATCHER_NAMESPACE_URI, DISPATCHER_PREFIX, doc);
@@ -184,9 +184,9 @@
 
     }
 
-    public DispatcherHelper(ServiceManager manager)
+    public DispatcherHelper(SourceResolver resolver)
             throws ParserConfigurationException {
-        this.manager = manager;
+        this.resolver = resolver;
         this.namespaceHelper = new NamespaceHelper(DISPATCHER_NAMESPACE_URI,
                 DISPATCHER_PREFIX, "foo");
     }

Modified: 
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/acting/RecursiveDirectoryTraversalAction.java
URL: 
http://svn.apache.org/viewvc/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/acting/RecursiveDirectoryTraversalAction.java?rev=694101&r1=694100&r2=694101&view=diff
==============================================================================
--- 
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/acting/RecursiveDirectoryTraversalAction.java
 (original)
+++ 
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/acting/RecursiveDirectoryTraversalAction.java
 Wed Sep 10 20:45:49 2008
@@ -30,37 +30,35 @@
 import org.apache.cocoon.environment.Redirector;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceResolver;
+import org.apache.forrest.dispatcher.DispatcherException;
 
 /**
- * Selects the first of a set of Sources that exists in the context.
+ * Calculates which location to return for a given directory.
+ * Here we are traversing the tree till we reach its root. 
  * <p>
- * For example, we could define a SourceExistsSelector with:
- * 
- * <pre>
- * 
- *  &lt;map:selector name=&quot;exists&quot;
- *                logger=&quot;sitemap.selector.source-exists&quot;
- *                
src=&quot;org.apache.cocoon.selection.SourceExistsSelector&quot; /&gt;
- *  
- * </pre>
- * 
- * And use it to build a PDF from XSL:FO or a higher-level XML format with:
- * 
- * <pre>
+ * We are looking first in the request string and then using a 
+ * fallback algorithm to find alternative fallbacks.
+ * <p> 
+ * e.g. the request is "sample/index". First choice is to find: 
+ * {$projectDir}sample/index{$projectExtension}<br>
+ * If the file does not exist we will try with the fallback file
+ * {$projectDir}sample/{$projectFallback}{$projectExtension}<br>
+ * The last file we will try in our example is 
+ * {$projectDir}{$projectFallback}{$projectExtension}.<br>
+ * With this we have reached the root directory and we cannot find the
+ * requested file the action will return null.
+ * <p>
+ * &lt;map:act type="RecursiveDirectoryTraversalAction"&gt;<br>
+ *   &lt;map:parameter value="{../1}{1}" name="request"/&gt;<br>
+ *   &lt;map:parameter value="{properties:dispatcher.theme}" 
name="projectFallback"/&gt;<br>
+ *   &lt;map:parameter value="{properties:dispatcher.theme-ext}" 
+ *                     name="projectExtension"/&gt;<br>
+ *   &lt;map:parameter value="{properties:resources}structurer/url/" 
+ *                     name="projectDir"/&gt;<br>
+ * &lt;!--  url project-based theme-based = directory-based / parent-directory 
based (recursively) --&gt;<br>
+ *         &lt;map:location src="{uri}" /&gt;<br>
+ *  &lt;/map:act&gt;
  * 
- *   &lt;map:match pattern=&quot;**.pdf&quot;&gt;
- *     &lt;map:select type=&quot;exists&quot;&gt;
- *        &lt;map:when test=&quot;context/xdocs/{1}.fo&quot;&gt;
- *           &lt;map:generate src=&quot;content/xdocs/{1}.fo&quot; /&gt;
- *        &lt;/map:when&gt;
- *        &lt;map:otherwise&gt;
- *          &lt;map:generate src=&quot;content/xdocs/{1}.xml&quot; /&gt;
- *          &lt;map:transform src=&quot;stylesheets/document2fo.xsl&quot; /&gt;
- *        &lt;/map:otherwise&gt;
- *     &lt;/map:select&gt;
- *     &lt;map:serialize type=&quot;fo2pdf&quot; /&gt;
- *  
- * </pre>
  */
 public class RecursiveDirectoryTraversalAction extends ServiceableAction
         implements ThreadSafe, Serviceable {
@@ -121,17 +119,13 @@
             } else {
                 return null;
             }
-        } catch (MalformedURLException e) {
-            getLogger().warn(
-                    "Selector URL '" + uri + "' is not a valid Source URL");
-            return null;
-        } catch (IOException e) {
+        } catch (DispatcherException e) {
             getLogger().warn(
                     "Error reading from source '" + uri + "': "
                             + e.getMessage());
             return null;
         } finally {
-            resolver.release(src);
+            release(src);
         }
     }
 
@@ -159,14 +153,13 @@
      * is overriding this view. This override can be used for directories
      * (default.fv) and/or files (*.fv). That means that the root view is the
      * default view as long no other view can be found in the requested child.
-     * @throws IOException
-     * @throws MalformedURLException
+     * @throws DispatcherException 
      *  
      */
-    private void computeResponseURI(String uri, Source src)
-            throws MalformedURLException, IOException {
-        src = resolver.resolveURI(uri);
-        if (src.exists()) {
+    private void computeResponseURI(String uri, Source src) throws 
DispatcherException{
+        try {
+          src = resolver.resolveURI(uri);
+          if (src.exists()) {
             this.map.put("uri", uri);
         } else {
             if (this.getRest().lastIndexOf("/") > -1) {
@@ -185,8 +178,23 @@
                 }
             }
         }
+        } catch (MalformedURLException e) {
+         throw new DispatcherException(e);
+        } catch (IOException e) {
+          throw new DispatcherException(e);
+        }finally{
+          release(src);
+        }
+        
+    }
+    /**
+     * @see 
org.apache.excalibur.source.SourceFactory#release(org.apache.excalibur.source.Source)
 
+     */
+   public void release(Source source) {
+     if(source!=null){
+       resolver.release(source);
+     }
     }
-
     public void prepare(Parameters parameters, String src) {
         this.setRequest(parameters.getParameter("request", src));
         this.setProjectFallback(parameters.getParameter("projectFallback",

Modified: 
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/acting/ResourceTypeAction.java
URL: 
http://svn.apache.org/viewvc/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/acting/ResourceTypeAction.java?rev=694101&r1=694100&r2=694101&view=diff
==============================================================================
--- 
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/acting/ResourceTypeAction.java
 (original)
+++ 
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/acting/ResourceTypeAction.java
 Wed Sep 10 20:45:49 2008
@@ -17,22 +17,23 @@
 package org.apache.forrest.dispatcher.acting;
 /**
  * Looks up a meta data file to determine which resource type should be 
returned. 
- */
-/**
- * component declaration (lm and sitemap)
+ * Will parse the document and looks for the {$resourceTypeElement}.
+ * If found the action returns {$resourceTypeBase}{$resourceTypeElement}.
+ * <p>
+ * component declaration (lm and sitemap):<br>
  * &lt;action name="resourceTypeAction" 
  *      src="org.apache.forrest.dispatcher.acting.ResourceTypeAction"/&gt;
- *
- *pipline usage lm
-*  &lt;act type="resourceTypeAction"&gt;
-*     &lt;parameter value="{1}" name="request"/&gt;
-*     &lt;parameter value="{project:content.xdocs}" name="projectDir"/&gt;
-*     &lt;parameter value="lm://dispatcher.structurer.resourceType." 
name="resourceTypeBase"/&gt;
-*     &lt;parameter value=".xml.meta" name="metaExtension"/&gt;
-*     &lt;parameter value="resourceType" name="resourceTypeElement"/&gt;
-*     &lt;parameter value="http://apache.org/cocoon/lenya/page-envelope/1.0"; 
name="resourceTypeElementNS"/&gt;
-*     &lt;!--  Meta data based --&gt;
-*     &lt;location src="{uri}" /&gt;
+ *<p>
+ *pipline usage lm<br>
+*  &lt;act type="resourceTypeAction"&gt;<br>
+*     &lt;parameter value="{1}" name="request"/&gt;<br>
+*     &lt;parameter value="{project:content.xdocs}" name="projectDir"/&gt;<br>
+*     &lt;parameter value="lm://dispatcher.structurer.resourceType." 
name="resourceTypeBase"/&gt;<br>
+*     &lt;parameter value=".xml.meta" name="metaExtension"/&gt;<br>
+*     &lt;parameter value="resourceType" name="resourceTypeElement"/&gt;<br>
+*     &lt;parameter value="http://apache.org/cocoon/lenya/page-envelope/1.0"; 
name="resourceTypeElementNS"/&gt;<br>
+*     &lt;!--  Meta data based --&gt;<br>
+*     &lt;location src="{uri}" /&gt;<br>
  * &lt;/act&gt;
  */
 import java.io.IOException;
@@ -49,6 +50,7 @@
 import org.apache.cocoon.environment.Redirector;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceResolver;
+import org.apache.forrest.dispatcher.DispatcherException;
 import org.w3c.dom.Document;
 import org.w3c.dom.NodeList;
 
@@ -106,31 +108,23 @@
             } else {
                 return null;
             }
-        } catch (MalformedURLException e) {
-            getLogger().warn(
-                    "Selector URL '" + uri + "' is not a valid Source URL");
-            return null;
-        } catch (IOException e) {
-            getLogger().warn(
-                    "Error reading from source '" + uri + "': "
-                            + e.getMessage());
-            return null;
-        } catch (Exception e) {
+        }  catch (Exception e) {
             getLogger().warn(
                     "Error reading from source '" + uri + "': "
                             + e.getMessage());
             return null;
         }finally {
-            resolver.release(src);
+            release(src);
         }
     }
        
        private void computeResponseURI(String uri, Source src)
-            throws Exception {
-        src = resolver.resolveURI(uri);
-        if (src.exists()) {
+            throws DispatcherException {
+        try {
+          src = resolver.resolveURI(uri);
+          if (src.exists()) {
             Document rawData =  
org.apache.forrest.dispatcher.util.SourceUtil.readDOM(
-                    uri, this.manager);
+                    uri, resolver);
             NodeList type = 
rawData.getElementsByTagNameNS(getResourceTypeElementNS(),getResourceTypeElement());
             String typeString = type.item(0).getFirstChild().getNodeValue();
             Source typeSource = 
resolver.resolveURI(resourceTypeBase+typeString);
@@ -138,8 +132,21 @@
                 this.map.put("uri", typeSource.getURI());
             }
         }
+        } catch (Exception e) {
+          throw new DispatcherException(e);
+        }finally{
+          release(src);
+        }
+        
     }
-
+       /**
+        * @see 
org.apache.excalibur.source.SourceFactory#release(org.apache.excalibur.source.Source)
 
+        */
+      public void release(Source source) {
+        if(source!=null){
+          resolver.release(source);
+        }
+       }
     public void prepare(Parameters parameters, String src) {
         this.setRequest(parameters.getParameter("request", src));
         this.setMetaExtension(parameters.getParameter("metaExtension",

Modified: 
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherTransformer.java
URL: 
http://svn.apache.org/viewvc/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherTransformer.java?rev=694101&r1=694100&r2=694101&view=diff
==============================================================================
--- 
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherTransformer.java
 (original)
+++ 
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherTransformer.java
 Wed Sep 10 20:45:49 2008
@@ -23,6 +23,7 @@
 import java.util.Iterator;
 import java.util.Map;
 
+import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.URIResolver;
@@ -44,6 +45,7 @@
 import org.apache.cocoon.xml.dom.DOMUtil;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceException;
+import org.apache.excalibur.source.SourceNotFoundException;
 import org.apache.excalibur.source.SourceValidity;
 import org.apache.excalibur.source.impl.validity.AggregatedValidity;
 import org.apache.excalibur.xml.xpath.XPathProcessor;
@@ -51,6 +53,7 @@
 import org.apache.forrest.dispatcher.ContractBeanDOMImpl;
 import org.apache.forrest.dispatcher.DispatcherException;
 import org.apache.forrest.dispatcher.DispatcherHelper;
+import org.apache.forrest.dispatcher.lenya.xml.DocumentHelper;
 import org.apache.forrest.dispatcher.lenya.xml.NamespaceHelper;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Document;
@@ -190,7 +193,7 @@
 
   private HashMap parameterHelper;
 
-  private SourceResolver m_resolver;
+  private org.apache.excalibur.source.SourceResolver m_resolver;
 
   private String requestId;
 
@@ -243,12 +246,16 @@
     // You can either request URL?dispatcher.caching=off
     // or add this property to forrest.properties.xml
     // to force a SourceValidity.INVALID
-    if (null != validityFile & !(validityOverride.equals(CACHING_OFF))) {
+    if (null != validityFile && !(validityOverride.equals(CACHING_OFF))) {
       this.validity = new AggregatedValidity();
+      Source resolveSource=null;
       try {
-        this.validity.add(m_resolver.resolveURI(validityFile).getValidity());
+        resolveSource= m_resolver.resolveURI(validityFile);
+        this.validity.add(resolveSource.getValidity());
       } catch (Exception e) {
         getLogger().error(e.getMessage());
+      }finally{
+        release(resolveSource);
       }
     } else
       this.validity = null;
@@ -256,6 +263,15 @@
   }
 
   /**
+   * @see 
org.apache.excalibur.source.SourceFactory#release(org.apache.excalibur.source.Source)
 
+   */
+ public void release(Source source) {
+   if(source!=null){
+     m_resolver.release(source);
+   }
+  }
+  
+  /**
    * @see 
org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
    */
   public void service(ServiceManager manager) throws ServiceException {
@@ -332,7 +348,7 @@
     parameterHelper.put(HOOKS_TRANSFORMER_PARAMETER, hooksXSL);
     if (null == m_resolver)
       try {
-        m_resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+        m_resolver = (org.apache.excalibur.source.SourceResolver) 
manager.lookup(SourceResolver.ROLE);
       } catch (ServiceException e) {
         throw new ProcessingException(e);
       }
@@ -352,7 +368,7 @@
       throws SAXException {
     // Process start element event
     // Are we inside of properties? If so we need to record the elements.
-    if (this.insideProperties & this.includeNodes) {
+    if (this.insideProperties && this.includeNodes) {
       try {
         this.builder.startElement(uri, name, raw, attr);
       } catch (SAXException e) {
@@ -373,19 +389,19 @@
       }
       if (STRUCTURER_ELEMENT.equals(name))
         structurerProcessingStart(attr);
-      else if (DISPATCHER_HOOK_ELEMENT.equals(name) & this.includeNodes)
+      else if (DISPATCHER_HOOK_ELEMENT.equals(name) && this.includeNodes)
         hookProcessingStart(name, raw, attr);
-      else if (ContractBean.CONTRACT_ELEMENT.equals(name) & this.includeNodes)
+      else if (ContractBean.CONTRACT_ELEMENT.equals(name) && this.includeNodes)
         contractProcessingStart(attr);
-      else if (ContractBean.PROPERTY_ELEMENT.equals(name) & this.includeNodes) 
{
+      else if (ContractBean.PROPERTY_ELEMENT.equals(name) && 
this.includeNodes) {
         this.insideProperties = true;
         propertyProcessingStart(uri, name, raw, attr);
       }
     } else {
-      if (!this.insideProperties & this.includeNodes & this.insideStructurer
-          & this.allowMarkup)
+      if (!this.insideProperties && this.includeNodes && this.insideStructurer
+          && this.allowMarkup)
         super.startElement(uri, name, raw, attr);
-      if (!this.insideProperties & this.includeNodes & !this.insideStructurer)
+      if (!this.insideProperties && this.includeNodes && 
!this.insideStructurer)
         super.startElement(uri, name, raw, attr);
     }
   }
@@ -474,18 +490,18 @@
     } else if (DispatcherHelper.DISPATCHER_NAMESPACE_URI.equals(uri)) {
       if (STRUCTURER_ELEMENT.equals(name))
         structurerProcessingEnd(raw);
-      else if (ContractBean.CONTRACT_ELEMENT.equals(name) & this.includeNodes)
+      else if (ContractBean.CONTRACT_ELEMENT.equals(name) && this.includeNodes)
         contractProcessingEnd();
-      else if (DISPATCHER_HOOK_ELEMENT.equals(name) & this.includeNodes)
+      else if (DISPATCHER_HOOK_ELEMENT.equals(name) && this.includeNodes)
         if (path.lastIndexOf("/") > -1)
           path = path.substring(0, path.lastIndexOf("/"));
         else
           path = null;
     } else {
-      if (!this.insideProperties & this.includeNodes & this.insideStructurer
-          & this.allowMarkup)
+      if (!this.insideProperties && this.includeNodes && this.insideStructurer
+          && this.allowMarkup)
         super.endElement(uri, name, raw);
-      if (!this.insideProperties & this.includeNodes & !this.insideStructurer)
+      if (!this.insideProperties && this.includeNodes && 
!this.insideStructurer)
         super.endElement(uri, name, raw);
     }
   }
@@ -506,10 +522,10 @@
         currentFormat = value;
       }
       if (localName.equals(STRUCTURER_HOOK_XPATH_ATTRIBUTE)) {
-        if ("/".equals(String.valueOf(value.charAt(0))) & value.length() != 1) 
{
+        if ("/".equals(String.valueOf(value.charAt(0))) && value.length() != 
1) {
           path = "result" + value;
         } else if ("/".equals(String.valueOf(value.charAt(0)))
-            & value.length() == 1) {
+            && value.length() == 1) {
           path = "result";
         } else {
           path = "result/" + value;
@@ -520,7 +536,7 @@
       localRecycle();
       try {
         if (null == this.dispatcherHelper)
-          this.dispatcherHelper = new DispatcherHelper(manager);
+          this.dispatcherHelper = new DispatcherHelper(m_resolver);
         if (null == this.processor)
           this.processor = (XPathProcessor) this.manager
               .lookup(XPathProcessor.ROLE);
@@ -533,7 +549,7 @@
       String propertyURI = "cocoon://" + requestId + ".props";
       try {
         this.defaultProperties = org.apache.forrest.dispatcher.util.SourceUtil
-            .readDOM(propertyURI, this.manager);
+            .readDOM(propertyURI, m_resolver);
       } catch (Exception e1) {
         String error = "dispatcherError:\n" + "Could not get the properties 
for "
             + propertyURI + "\n DispatcherStack: " + e1;
@@ -640,7 +656,7 @@
   private void contractProcessingStart(Attributes attr) throws SAXException {
     try {
       if (contract == null)
-        contract = new ContractBeanDOMImpl(this.manager, parameterHelper,
+        contract = new ContractBeanDOMImpl(m_resolver, parameterHelper,
             defaultProperties, (URIResolver) this);
     } catch (Exception e) {
       String error = DispatcherException.ERROR_500 + "\n"
@@ -658,19 +674,21 @@
         contract.setContractName(value);
         String contractUri = ContractBean.CONTRACT_RESOLVE_PREFIX + "."
             + currentFormat + "." + value;
+        Source contractSource = null;
         try {
           // Adding the contract to the validity object.
           // As soon the contract changes we want a rebuild of
           // the page and not the cached object.
-          if (!validityOverride.equals(CACHING_OFF) & null != this.validity) {
-            SourceValidity contractValidityId = 
m_resolver.resolveURI(contractUri)
+          if (!validityOverride.equals(CACHING_OFF) && null != this.validity) {
+            contractSource = m_resolver.resolveURI(contractUri);
+            SourceValidity contractValidityId = contractSource
                 .getValidity();
             // we cannot allow null in an AggregatedValidity
             if (null != contractValidityId)
               this.validity.add(contractValidityId);
           }
           Document doc = org.apache.forrest.dispatcher.util.SourceUtil.readDOM(
-              contractUri, this.manager);
+              contractUri, m_resolver);
           contract.setContractImpl(doc, contractUri);
           // contract.setContractImpl(contractUri);
         } catch (Exception e) {
@@ -683,6 +701,8 @@
               + contractUri + "\".\n\n" + "dispatcherErrorStack:\n" + e;
           getLogger().error(error);
           throw new SAXException(error);
+        }finally{
+          release(contractSource);
         }
         if (getLogger().isDebugEnabled()) {
           getLogger().debug(
@@ -692,19 +712,21 @@
       } else if (ContractBean.CONTRACT_NUGGET_ATTRIBUTE.equals(localName)) {
         // contract is a nugget-contract
         contract.setNugget(true);
+        Source contractRawSource =null;
         try {
           // Adding the raw data to the validity object.
           // As soon the raw data changes we want a rebuild of
           // the page and not the cached object.
-          if (!validityOverride.equals(CACHING_OFF) & null != this.validity) {
-            SourceValidity contractValidityRaw = m_resolver.resolveURI(value)
+          if (!validityOverride.equals(CACHING_OFF) && null != this.validity) {
+            contractRawSource = m_resolver.resolveURI(value);
+            SourceValidity contractValidityRaw = contractRawSource
                 .getValidity();
             // we cannot allow null in an AggregatedValidity
             if (null != contractValidityRaw)
               this.validity.add(contractValidityRaw);
           }
           Document doc = org.apache.forrest.dispatcher.util.SourceUtil.readDOM(
-              value, this.manager);
+              value, m_resolver);
           contract.setContractRawData(doc);
           // contract.setNuggetUri(value);
         } catch (Exception e) {
@@ -714,6 +736,8 @@
               + value + "\".\n\n" + "dispatcherErrorStack:\n " + e;
           getLogger().error(error);
           throw new SAXException(error);
+        } finally{
+          release(contractRawSource);
         }
         if (getLogger().isDebugEnabled()) {
           getLogger().debug(
@@ -907,23 +931,23 @@
   }
 
   public void characters(char c[], int start, int len) throws SAXException {
-    if (this.insideProperties & this.includeNodes)
+    if (this.insideProperties && this.includeNodes)
       this.builder.characters(c, start, len);
-    else if (!this.insideProperties & this.includeNodes & 
!this.insideStructurer)
+    else if (!this.insideProperties && this.includeNodes && 
!this.insideStructurer)
       super.contentHandler.characters(c, start, len);
   }
 
   public void startCDATA() throws SAXException {
-    if (this.insideProperties & this.includeNodes)
+    if (this.insideProperties && this.includeNodes)
       this.builder.startCDATA();
-    else if (!this.insideProperties & this.includeNodes & 
!this.insideStructurer)
+    else if (!this.insideProperties && this.includeNodes && 
!this.insideStructurer)
       super.lexicalHandler.startCDATA();
   }
 
   public void endCDATA() throws SAXException {
-    if (this.insideProperties & this.includeNodes)
+    if (this.insideProperties && this.includeNodes)
       this.builder.endCDATA();
-    else if (!this.insideProperties & this.includeNodes & 
!this.insideStructurer)
+    else if (!this.insideProperties && this.includeNodes && 
!this.insideStructurer)
       super.lexicalHandler.endCDATA();
   }
 
@@ -931,7 +955,7 @@
 
   public void startPrefixMapping(String prefix, String uri) throws 
SAXException {
     super.startPrefixMapping(prefix, uri);
-    if (this.insideProperties & this.includeNodes) {
+    if (this.insideProperties && this.includeNodes) {
       this.builder.startPrefixMapping(prefix, uri);
     } else {
       storePrefixMapping(prefix, uri);
@@ -1039,7 +1063,7 @@
 
       return null;
     } finally {
-      m_resolver.release(xslSource);
+        release(xslSource);
     }
   }
 
@@ -1057,5 +1081,5 @@
     newObject.setSystemId(source.getURI());
     return newObject;
   }
-
+  
 }

Modified: 
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/util/SourceUtil.java
URL: 
http://svn.apache.org/viewvc/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/util/SourceUtil.java?rev=694101&r1=694100&r2=694101&view=diff
==============================================================================
--- 
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/util/SourceUtil.java
 (original)
+++ 
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/util/SourceUtil.java
 Wed Sep 10 20:45:49 2008
@@ -21,10 +21,9 @@
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.cocoon.environment.SourceResolver;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceNotFoundException;
+import org.apache.excalibur.source.SourceResolver;
 import org.apache.forrest.dispatcher.lenya.xml.DocumentHelper;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
@@ -41,27 +40,20 @@
      * @throws SAXException if an error occurs.
      * @throws IOException if an error occurs.
      */
-    public static Document readDOM(String sourceUri, ServiceManager manager)
+    public static Document readDOM(String sourceUri, SourceResolver resolver)
             throws ServiceException, SourceNotFoundException, 
ParserConfigurationException,
             SAXException, IOException {
-        SourceResolver resolver = null;
         Source source = null;
         Document document = null;
         try {
-
-            resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
             source = resolver.resolveURI(sourceUri);
-
             if (source.exists()) {
                 document = 
DocumentHelper.readDocument(source.getInputStream());
             }
         } finally {
-            if (resolver != null) {
                 if (source != null) {
                     resolver.release(source);
                 }
-                manager.release(resolver);
-            }
         }
         return document;
     }

Modified: 
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.solr/src/java/org/apache/forrest/solr/client/SolrUpdateGenerator.java
URL: 
http://svn.apache.org/viewvc/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.solr/src/java/org/apache/forrest/solr/client/SolrUpdateGenerator.java?rev=694101&r1=694100&r2=694101&view=diff
==============================================================================
--- 
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.solr/src/java/org/apache/forrest/solr/client/SolrUpdateGenerator.java
 (original)
+++ 
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.solr/src/java/org/apache/forrest/solr/client/SolrUpdateGenerator.java
 Wed Sep 10 20:45:49 2008
@@ -51,7 +51,6 @@
     public void generate() throws IOException, SAXException, 
ProcessingException {
         Source inputSource = null;
         try {
-            resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
             inputSource = resolver.resolveURI(this.source);
             if (inputSource.exists()) {
                 post = new PostFile(destination, inputSource.getInputStream());
@@ -68,6 +67,9 @@
           if (null!=post){
             post.releaseConnection();
           }
+          if (inputSource!=null){
+            resolver.release(inputSource);
+          }
         }
         
     }