cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jheym...@apache.org
Subject svn commit: r330548 [62/132] - in /cocoon/whiteboard/maven2/cocoon-flat-layout: ./ cocoon-ajax-block/ cocoon-ajax-block/api/ cocoon-ajax-block/api/src/ cocoon-ajax-block/api/src/main/ cocoon-ajax-block/api/src/main/java/ cocoon-ajax-block/api/src/main/...
Date Thu, 03 Nov 2005 14:00:48 GMT
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/WriteDOMSessionTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/WriteDOMSessionTransformer.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/WriteDOMSessionTransformer.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/WriteDOMSessionTransformer.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,201 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ */
+package org.apache.cocoon.transformation;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.Session;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.xml.dom.DOMBuilder;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+
+/**
+ * @cocoon.sitemap.component.documentation
+ * Make a DOM object from SAX events and write it to the session.
+ * 
+ * @cocoon.sitemap.component.name   writeDOMsession
+ * @cocoon.sitemap.component.logger sitemap.transformer.writeDOMsession
+ * 
+ * 
+ * Make a DOM object from SAX events and write it to the session.
+ *
+ * Usage in sitemap:
+ *    <map:transform type="writeDOMsession">
+ *      <map:parameter name="dom-name" value="content"/>
+ *      <map:parameter name="dom-root-element" value="companies"/>
+ *    </map:transform>
+ *
+ * Where:
+ *   dom-name is the name for the DOM object in the session
+ *   dom-root-element is the trigger that will be the root element of the DOM
+ *
+ * @author <a href="mailto:sven.beauprez@the-ecorp.com">Sven Beauprez</a>
+ * @version CVS $Id: WriteDOMSessionTransformer.java 109638 2004-12-03 06:54:28Z crossley $
+ */
+
+public class WriteDOMSessionTransformer
+  extends AbstractTransformer {
+
+    public static final String DOM_NAME = "dom-name";
+    public static final String DOM_ROOT_ELEMENT = "dom-root-element";
+
+    private boolean buildDom = false;
+    private boolean sessionAvailable = false;
+
+    private Session session;
+    private DOMBuilder builder;
+
+    private String DOMName;
+    private String rootElement;
+    private Map storedPrefixMap;
+
+    /**
+     * Recyclable
+     */
+    public void recycle() {
+        super.recycle();
+        this.session = null;
+        this.builder = null;
+        this.buildDom = false;
+        this.sessionAvailable = false;
+    }
+
+    /** BEGIN SitemapComponent methods **/
+
+    public void setup(SourceResolver resolver, Map objectModel,
+                      String source, Parameters parameters)
+    throws ProcessingException, SAXException, IOException {
+      getLogger().debug("WriteSessionTransformer: setup");
+      Request request = ObjectModelHelper.getRequest(objectModel);
+      session = request.getSession(false);
+      if (session != null) {
+        DOMName = parameters.getParameter(WriteDOMSessionTransformer.DOM_NAME,null);
+        rootElement = parameters.getParameter(WriteDOMSessionTransformer.DOM_ROOT_ELEMENT,null);
+        if (DOMName!=null && rootElement!=null)  {
+          //only now we know it is usefull to store something in the session
+          getLogger().debug("WriteSessionTransformer: "+WriteDOMSessionTransformer.DOM_NAME + "=" +
+                            DOMName + "; " + WriteDOMSessionTransformer.DOM_ROOT_ELEMENT + "=" +
+                            rootElement);
+          sessionAvailable = true;
+                    storedPrefixMap = new HashMap();
+        } else  {
+          getLogger().error("WriteSessionTransformer: need " + WriteDOMSessionTransformer.DOM_NAME +
+                            " and " + WriteDOMSessionTransformer.DOM_ROOT_ELEMENT + " parameters");
+        }
+      } else  {
+        getLogger().error("WriteSessionTransformer: no session object");
+      }
+    }
+
+    /** END SitemapComponent methods **/
+
+    /** BEGIN SAX ContentHandler handlers **/
+
+    public void startPrefixMapping(String prefix, String uri)
+    throws SAXException {
+      super.startPrefixMapping(prefix,uri);
+      if (buildDom)  {
+        builder.startPrefixMapping(prefix,uri);
+      } else {
+                storePrefixMapping(prefix,uri);
+            }
+    }
+
+    public void startElement(String uri, String name, String raw, Attributes attributes)
+    throws SAXException {
+        //only build the DOM tree if session is available
+        if (name.equalsIgnoreCase(rootElement) && sessionAvailable)  {
+          getLogger().debug("WriteSessionTransformer: start building DOM tree");
+          buildDom = true;
+          builder = new DOMBuilder();
+          builder.startDocument();
+                    launchStoredMappings();
+          builder.startElement(uri,name,raw,attributes);
+        } else if (buildDom)  {
+          builder.startElement(uri,name,raw,attributes);
+        }
+        super.contentHandler.startElement(uri,name,raw,attributes);
+    }
+
+    public void endElement(String uri, String name, String raw)
+    throws SAXException {
+        if (name.equalsIgnoreCase(rootElement) && sessionAvailable) {
+          buildDom = false;
+          builder.endElement(uri,name,raw);
+          builder.endDocument();
+          getLogger().debug("WriteSessionTransformer: putting DOM tree in session object");
+          session.setAttribute(DOMName,builder.getDocument().getFirstChild());
+          getLogger().debug("WriteSessionTransformer: DOM tree is in session object");
+        } else if (buildDom)  {
+          builder.endElement(uri,name,raw);
+        }
+        super.contentHandler.endElement(uri,name,raw);
+    }
+
+
+    public void characters(char c[], int start, int len)
+    throws SAXException {
+        if (buildDom)  {
+          builder.characters(c,start,len);
+        }
+        super.contentHandler.characters(c,start,len);
+    }
+
+    public void startCDATA()
+    throws SAXException  {
+      if (buildDom)  {
+        builder.startCDATA();
+      }
+      super.lexicalHandler.startCDATA();
+    }
+
+    public void endCDATA()
+    throws SAXException {
+      if (buildDom)  {
+        builder.endCDATA();
+      }
+      super.lexicalHandler.endCDATA();
+    }
+
+    /** END SAX ContentHandler handlers **/
+
+      protected void storePrefixMapping(String prefix, String uri) {
+           storedPrefixMap.put(prefix,uri);
+    }
+
+      protected void launchStoredMappings()
+        throws SAXException {
+            Iterator it = storedPrefixMap.keySet().iterator();
+                while(it.hasNext()) {
+                    String pre = (String)it.next();
+                    String uri = (String)storedPrefixMap.get(pre);
+                    getLogger().debug("WriteSessionTransformer: launching prefix mapping[ pre: "+pre+" uri: "+uri+" ]");
+                    builder.startPrefixMapping(pre,uri);
+                }
+        }
+
+
+
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/WriteDOMSessionTransformer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/XIncludeTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/XIncludeTransformer.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/XIncludeTransformer.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/XIncludeTransformer.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,494 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ */
+package org.apache.cocoon.transformation;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.Serializable; 
+import java.net.MalformedURLException;
+import java.util.Map;
+
+import org.apache.avalon.framework.CascadingException;
+import org.apache.avalon.framework.CascadingRuntimeException;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.ResourceNotFoundException;
+import org.apache.cocoon.caching.CacheableProcessingComponent; 
+import org.apache.cocoon.components.source.SourceUtil;
+import org.apache.cocoon.components.source.impl.MultiSourceValidity; 
+import org.apache.cocoon.components.xpointer.XPointer;
+import org.apache.cocoon.components.xpointer.XPointerContext;
+import org.apache.cocoon.components.xpointer.parser.ParseException;
+import org.apache.cocoon.components.xpointer.parser.XPointerFrameworkParser;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.util.NetUtils;
+import org.apache.cocoon.xml.AbstractXMLPipe;
+import org.apache.cocoon.xml.IncludeXMLConsumer;
+import org.apache.cocoon.xml.XMLBaseSupport;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceException;
+import org.apache.excalibur.source.SourceValidity; 
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
+
+/**
+ * @cocoon.sitemap.component.documentation
+ * Implementation of an XInclude transformer.
+ * 
+ * @cocoon.sitemap.component.name   xinclude
+ * @cocoon.sitemap.component.logger sitemap.transformer.xinclude
+ * 
+ * @cocoon.sitemap.component.pooling.max  16
+ * 
+ * Implementation of an XInclude transformer. It supports xml:base attributes,
+ * XPointer fragment identifiers (see the xpointer package to see what exactly is
+ * supported), fallback elements, and does xinclude processing on the included content
+ * and on the content of fallback elements (with loop inclusion detection).
+ *
+ * @author <a href="mailto:balld@webslingerZ.com">Donald Ball</a> (wrote the original version)
+ * @version SVN $Id: XIncludeTransformer.java 289891 2005-09-18 05:37:11Z antonio $
+ */
+public class XIncludeTransformer extends AbstractTransformer implements Serviceable, CacheableProcessingComponent { 
+    protected SourceResolver resolver;
+    protected ServiceManager manager;
+    private XIncludePipe xIncludePipe;
+
+    public static final String XMLBASE_ATTRIBUTE = "base";
+
+    public static final String XINCLUDE_NAMESPACE_URI = "http://www.w3.org/2001/XInclude";
+    public static final String XINCLUDE_INCLUDE_ELEMENT = "include";
+    public static final String XINCLUDE_FALLBACK_ELEMENT = "fallback";
+    public static final String XINCLUDE_INCLUDE_ELEMENT_HREF_ATTRIBUTE = "href";
+    public static final String XINCLUDE_INCLUDE_ELEMENT_PARSE_ATTRIBUTE = "parse";
+
+    private static final String XINCLUDE_CACHE_KEY = "XInclude"; 
+
+    /** The {@link SourceValidity} instance associated with this request. */ 
+    private MultiSourceValidity validity; 
+
+    public void setup(SourceResolver resolver, Map objectModel, String source, Parameters parameters)
+            throws ProcessingException, SAXException, IOException {
+        this.resolver = resolver;
+        this.validity = new MultiSourceValidity(resolver, MultiSourceValidity.CHECK_ALWAYS); 
+        this.xIncludePipe = new XIncludePipe(); 
+        this.xIncludePipe.enableLogging(getLogger());
+        this.xIncludePipe.init(null);
+        super.setContentHandler(xIncludePipe);
+        super.setLexicalHandler(xIncludePipe);
+    }
+
+    public void setConsumer(XMLConsumer consumer) {
+        xIncludePipe.setConsumer(consumer);
+    }
+
+    public void setContentHandler(ContentHandler handler) {
+        xIncludePipe.setContentHandler(handler);
+    }
+
+    public void setLexicalHandler(LexicalHandler handler) {
+        xIncludePipe.setLexicalHandler(handler);
+    }
+
+    public void service(ServiceManager manager) {
+        this.manager = manager;
+    }
+
+    /** Key to be used for caching */ 
+    public Serializable getKey() { 
+        return XINCLUDE_CACHE_KEY; 
+    } 
+
+    /** Get the validity for this transform */ 
+    public SourceValidity getValidity() { 
+        return this.validity; 
+    } 
+
+    public void recycle()
+    {
+        // Reset all variables to initial state.
+        this.resolver = null;
+        this.validity = null; 
+        this.xIncludePipe = null;
+        super.recycle();
+    }
+
+    /**
+     * XMLPipe that processes XInclude elements. To perform XInclude processing on included content,
+     * this class is instantiated recursively.
+     */
+    private class XIncludePipe extends AbstractXMLPipe {
+        /** Helper class to keep track of xml:base attributes */
+        private XMLBaseSupport xmlBaseSupport;
+        /** Element nesting level when inside an xi:include element. */
+        private int xIncludeLevel = 0;
+        /** Should the content of the fallback element be inserted when it is encountered? */
+        private boolean useFallback = false;
+        /** Element nesting level when inside the fallback element. */
+        private int fallbackLevel;
+        /** In case {@link #useFallback} = true, then this should contain the exception that caused fallback to be needed. */
+        private Exception fallBackException;
+        /**
+         * Locator of the current stream, stored here so that it can be restored after
+         * another document send its content to the consumer.
+         */
+        private Locator locator;
+        /**
+         * Value of the href attribute of the xi:include element that caused the creation of the this
+         * XIncludePipe. Used to detect loop inclusions.
+         * */
+        private String href;
+        private XIncludePipe parent;
+
+        public void init(String uri) {
+            this.href = uri;
+            this.xmlBaseSupport = new XMLBaseSupport(resolver, getLogger());
+        }
+
+        public void setParent(XIncludePipe parent) {
+            this.parent = parent;
+        }
+
+        public XIncludePipe getParent() {
+            return parent;
+        }
+
+        public String getHref() {
+            return href;
+        }
+
+        public void endDocument() throws SAXException { 
+            // We won't be getting any more sources so mark the MultiSourceValidity as finished. 
+            validity.close(); 
+            super.endDocument(); 
+        } 
+
+        public void startElement(String uri, String name, String raw, Attributes attr) throws SAXException {
+            if (xIncludeLevel == 1 && useFallback && XINCLUDE_NAMESPACE_URI.equals(uri) && XINCLUDE_FALLBACK_ELEMENT.equals(name)) {
+                fallbackLevel++;
+
+                // don't need these anymore
+                useFallback = false;
+                fallBackException = null;
+
+                return;
+            } else if (xIncludeLevel > 0 && fallbackLevel < 1) {
+                xIncludeLevel++;
+                return;
+            } else if (xIncludeLevel > 0 && fallbackLevel > 0) {
+                fallbackLevel++;
+            }
+
+            xmlBaseSupport.startElement(uri, name, raw, attr);
+            if (XINCLUDE_NAMESPACE_URI.equals(uri)) {
+                if (XINCLUDE_INCLUDE_ELEMENT.equals(name)) {
+                    String href = attr.getValue("",XINCLUDE_INCLUDE_ELEMENT_HREF_ATTRIBUTE);
+                    if (href == null) {
+                        throw new SAXException(raw + " must have a 'href' attribute at " + getLocation());
+                    }
+
+                    String parse = attr.getValue("",XINCLUDE_INCLUDE_ELEMENT_PARSE_ATTRIBUTE);
+
+                    if (null == parse) parse="xml";
+                    xIncludeLevel++;
+
+                    try {
+                        processXIncludeElement(href, parse);
+                    } catch (ProcessingException e) {
+                        getLogger().debug("Rethrowing exception", e);
+                        throw new SAXException(e);
+                    } catch (IOException e) {
+                        getLogger().debug("Rethrowing exception", e);
+                        throw new SAXException(e);
+                    }
+                    return;
+                }
+
+                throw new SAXException("Unknown XInclude element " + raw + " at " + getLocation());
+
+            } else {
+                super.startElement(uri,name,raw,attr);
+            }
+        }
+
+        public void endElement(String uri, String name, String raw) throws SAXException {
+            if (xIncludeLevel > 0 && fallbackLevel < 1) {
+                xIncludeLevel--;
+                if (xIncludeLevel == 0)
+                    xmlBaseSupport.endElement(uri, name, raw);
+                if (xIncludeLevel == 0 && useFallback) {
+                    // an error was encountered but a fallback element was not found: throw the error now
+                    useFallback = false;
+                    Exception localFallBackException = fallBackException;
+                    fallBackException = null;
+                    fallbackLevel = 0;
+                    getLogger().error("Exception occured during xinclude processing, and did not find a fallback element.", localFallBackException);
+                    throw new SAXException("Exception occured during xinclude processing, and did not find a fallback element.", localFallBackException);
+                }
+                return;
+            }
+
+            if (fallbackLevel > 0) {
+                fallbackLevel--;
+                if (fallbackLevel == 0)
+                    return;
+            }
+
+            xmlBaseSupport.endElement(uri, name, raw);
+            super.endElement(uri,name,raw);
+        }
+
+        public void startPrefixMapping(String prefix, String uri)
+                throws SAXException {
+            if (xIncludeLevel > 0 && fallbackLevel < 1)
+                return;
+            super.startPrefixMapping(prefix, uri);
+        }
+
+        public void endPrefixMapping(String prefix)
+                throws SAXException {
+            if (xIncludeLevel > 0 && fallbackLevel < 1)
+                return;
+            super.endPrefixMapping(prefix);
+        }
+
+        public void characters(char c[], int start, int len)
+                throws SAXException {
+            if (xIncludeLevel > 0 && fallbackLevel < 1)
+                return;
+            super.characters(c, start, len);
+        }
+
+        public void ignorableWhitespace(char c[], int start, int len)
+                throws SAXException {
+            if (xIncludeLevel > 0 && fallbackLevel < 1)
+                return;
+            super.ignorableWhitespace(c, start, len);
+        }
+
+        public void processingInstruction(String target, String data)
+                throws SAXException {
+            if (xIncludeLevel > 0 && fallbackLevel < 1)
+                return;
+            super.processingInstruction(target, data);
+        }
+
+        public void skippedEntity(String name)
+                throws SAXException {
+            if (xIncludeLevel > 0 && fallbackLevel < 1)
+                return;
+            super.skippedEntity(name);
+        }
+
+        public void startEntity(String name)
+                throws SAXException {
+            if (xIncludeLevel > 0 && fallbackLevel < 1)
+                return;
+            super.startEntity(name);
+        }
+
+        public void endEntity(String name)
+                throws SAXException {
+            if (xIncludeLevel > 0 && fallbackLevel < 1)
+                return;
+            super.endEntity(name);
+        }
+
+        public void startCDATA()
+                throws SAXException {
+            if (xIncludeLevel > 0 && fallbackLevel < 1)
+                return;
+            super.startCDATA();
+        }
+
+        public void endCDATA()
+                throws SAXException {
+            if (xIncludeLevel > 0 && fallbackLevel < 1)
+                return;
+            super.endCDATA();
+        }
+
+        public void comment(char ch[], int start, int len)
+                throws SAXException {
+            if (xIncludeLevel > 0 && fallbackLevel < 1)
+                return;
+            super.comment(ch, start, len);
+        }
+
+        public void setDocumentLocator(Locator locator) {
+            try {
+                if (getLogger().isDebugEnabled()) {
+                    getLogger().debug("setDocumentLocator called " + locator.getSystemId());
+                }
+
+                // When using SAXON to serialize a DOM tree to SAX, a locator is passed with a "null" system id
+                if (locator.getSystemId() != null) {
+                    Source source = resolver.resolveURI(locator.getSystemId());
+                    try {
+                        xmlBaseSupport.setDocumentLocation(source.getURI());
+                        // only for the "root" XIncludePipe, we'll have to set the href here, in the other cases
+                        // the href is taken from the xi:include href attribute
+                        if (href == null)
+                            href = source.getURI();
+                    } finally {
+                        resolver.release(source);
+                    }
+                }
+            } catch (Exception e) {
+                throw new CascadingRuntimeException("Error in XIncludeTransformer while trying to resolve base URL for document", e);
+            }
+            this.locator = locator;
+            super.setDocumentLocator(locator);
+        }
+
+        protected void processXIncludeElement(String href, String parse)
+        throws SAXException,ProcessingException,IOException {
+            if (getLogger().isDebugEnabled()) {
+                getLogger().debug("Processing XInclude element: href="+href+", parse="+parse);
+            }
+
+            Source url = null;
+            String suffix = "";
+            try {
+                int fragmentIdentifierPos = href.indexOf('#');
+                if (fragmentIdentifierPos != -1) {
+                    suffix = href.substring(fragmentIdentifierPos + 1);
+                    href = href.substring(0, fragmentIdentifierPos);
+                }
+
+                // an empty href is a reference to the current document -- this can be different than the current base
+                if (href.equals("")) {
+                    if (this.href == null)
+                        throw new SAXException("XIncludeTransformer: encountered empty href (= href pointing to the current document) but the location of the current document is unknown.");
+                    int fragmentIdentifierPos2 = this.href.indexOf('#');
+                    if (fragmentIdentifierPos2 != -1)
+                        href = this.href.substring(0, fragmentIdentifierPos2);
+                    else
+                        href = this.href;
+                }
+
+                url = xmlBaseSupport.makeAbsolute(href);
+                if (getLogger().isDebugEnabled()) {
+                    getLogger().debug("URL: " + url.getURI() + "\nSuffix: " + suffix);
+                }
+
+                // add the source to the SourceValidity 
+                validity.addSource(url); 
+ 
+                // check loop inclusion
+                String canonicURI = url.getURI() + (suffix.length() > 0 ? "#" + suffix: "");
+                if (isLoopInclusion(canonicURI))
+                    throw new ProcessingException("Detected loop inclusion of " + canonicURI);
+
+                if (parse.equals("text")) {
+                    getLogger().debug("Parse type is text");
+                    InputStream input = url.getInputStream();
+                    Reader reader = new BufferedReader(new InputStreamReader(input));
+                    int read;
+                    char ary[] = new char[1024];
+                    if (reader != null) {
+                        while ((read = reader.read(ary)) != -1) {
+                            super.characters(ary,0,read);
+                        }
+                        reader.close();
+                    }
+                } else if (parse.equals("xml")) {
+                    XIncludePipe subPipe = new XIncludePipe();
+                    subPipe.enableLogging(getLogger());
+                    subPipe.init(canonicURI);
+                    subPipe.setConsumer(xmlConsumer);
+                    subPipe.setParent(this);
+
+                    getLogger().debug("Parse type is XML");
+                    try {
+                        if (suffix.length() > 0) {
+                            XPointer xpointer;
+                            xpointer = XPointerFrameworkParser.parse(NetUtils.decodePath(suffix));
+                            XPointerContext context = new XPointerContext(suffix, url, subPipe, getLogger(), manager);
+                            xpointer.process(context);
+                        } else {
+                            SourceUtil.toSAX(url, new IncludeXMLConsumer(subPipe));
+                        }
+                        // restore locator on the consumer
+                        if (locator != null)
+                            xmlConsumer.setDocumentLocator(locator);
+                    } catch (ResourceNotFoundException e) {
+                        useFallback = true;
+                        fallBackException = new CascadingException("Resource not found: " + url.getURI());
+                        getLogger().error("xIncluded resource not found: " + url.getURI(), e);
+                    } catch (ParseException e) {
+                        // this exception is thrown in case of an invalid xpointer expression
+                        useFallback = true;
+                        fallBackException = new CascadingException("Error parsing xPointer expression", e);
+                        fallBackException.fillInStackTrace();
+                        getLogger().error("Error parsing XPointer expression, will try to use fallback.", e);
+                    } catch(SAXException e) {
+                        getLogger().error("Error in processXIncludeElement", e);
+                        throw e;
+                    } catch(ProcessingException e) {
+                        getLogger().error("Error in processXIncludeElement", e);
+                        throw e;
+                    } catch(MalformedURLException e) {
+                        useFallback = true;
+                        fallBackException = e;
+                        getLogger().error("Error processing an xInclude, will try to use fallback.", e);
+                    } catch(IOException e) {
+                        useFallback = true;
+                        fallBackException = e;
+                        getLogger().error("Error processing an xInclude, will try to use fallback.", e);
+                    }
+                }
+            } catch (SourceException se) {
+                throw SourceUtil.handle(se);
+            } finally {
+                if (url != null) {
+                    resolver.release(url);
+                }
+            }
+        }
+
+        public boolean isLoopInclusion(String uri) {
+            if (uri.equals(this.href)) {
+                return true;
+            }
+
+            XIncludePipe parent = getParent();
+            while (parent != null) {
+                if (uri.equals(parent.getHref())) {
+                    return true;
+                }
+                parent = parent.getParent();
+            }
+            return false;
+        }
+
+        private String getLocation() {
+            if (this.locator == null) {
+                return "unknown location";
+            } else {
+                return this.locator.getSystemId() + ":" + this.locator.getColumnNumber() + ":" + this.locator.getLineNumber();
+            }
+        }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/XIncludeTransformer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/DefaultIncludeCacheManager.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/DefaultIncludeCacheManager.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/DefaultIncludeCacheManager.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/DefaultIncludeCacheManager.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,477 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ */
+package org.apache.cocoon.transformation.helpers;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.caching.CachedResponse;
+import org.apache.cocoon.components.sax.XMLDeserializer;
+import org.apache.cocoon.components.sax.XMLSerializer;
+import org.apache.cocoon.components.sax.XMLTeePipe;
+import org.apache.cocoon.components.source.SourceUtil;
+import org.apache.cocoon.components.thread.RunnableManager;
+import org.apache.cocoon.environment.CocoonRunnable;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceException;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.excalibur.source.SourceValidity;
+import org.apache.excalibur.store.Store;
+import org.xml.sax.SAXException;
+import EDU.oswego.cs.dl.util.concurrent.CountDown;
+
+/**
+ * Default implementation of a {@link IncludeCacheManager}.
+ * 
+ * This implementation requires a configuration, if preemptive
+ * loading is used:
+ * &lt;parameter name="preemptive-loader-url" value="some url"/&gt;
+ * 
+ * This is a url inside cocoon, that contains the preemptive loader
+ * url; it must be specified absolute (with http://...)
+ * If this loader cannot be started, only an error is logged into the
+ * log, so actually cached content is never updated!
+ * 
+ *  @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ *  @version CVS $Id: DefaultIncludeCacheManager.java 189934 2005-06-10 09:37:54Z sylvain $
+ *  @since   2.1
+ */
+public final class DefaultIncludeCacheManager
+    extends AbstractLogEnabled
+    implements IncludeCacheManager, 
+                ThreadSafe, 
+                Serviceable, 
+                Disposable,
+                Parameterizable {
+
+    private ServiceManager manager;
+    
+    private SourceResolver   resolver;
+    
+    private Store            store;
+    
+    private IncludeCacheStorageProxy defaultCacheStorage;
+    
+    private String            preemptiveLoaderURI;
+    
+    /**
+     * @see IncludeCacheManager#getSession(org.apache.avalon.framework.parameters.Parameters)
+     */
+    public IncludeCacheManagerSession getSession(Parameters pars) {
+        String sourceURI = pars.getParameter("source", null);
+        IncludeCacheManagerSession session;
+        if ( null == sourceURI ) {
+            session = new IncludeCacheManagerSession(pars, this.defaultCacheStorage);
+        } else {
+            Source source = null;
+            try {
+                source = this.resolver.resolveURI(sourceURI);
+                IncludeCacheStorageProxy proxy = new ModifiableSourceIncludeCacheStorageProxy(this.resolver, source.getURI(), this.getLogger());
+                session = new IncludeCacheManagerSession(pars, proxy);
+            } catch (Exception local) {
+                session = new IncludeCacheManagerSession(pars, this.defaultCacheStorage);
+                this.getLogger().warn("Error creating writeable source.", local);
+            } finally {
+                this.resolver.release(source);
+            }
+        }
+        if (session.isPreemptive()) {
+            if ( null == this.preemptiveLoaderURI ) {
+                this.getLogger().error("Preemptive loading is turned off because the preemptive-loader-url is not configured.");
+                session.setPreemptive(false);
+            } else {
+                if ( !PreemptiveLoader.getInstance().alive ) {
+
+                    if (this.getLogger().isDebugEnabled()) {
+                        this.getLogger().debug("Booting preemptive loader: " + this.preemptiveLoaderURI);
+                    }
+                    PreemptiveBooter thread = new PreemptiveBooter( this.preemptiveLoaderURI );
+                    try
+                    {
+                        final RunnableManager runnableManager = (RunnableManager)this.manager.lookup( RunnableManager.ROLE );
+                        runnableManager.execute( thread );
+                        this.manager.release( runnableManager );
+                    }
+                    catch( final ServiceException se )
+                    {
+                        getLogger().error( "Cannot lookup RunnableManager", se );
+                    }
+                }
+            }
+        } 
+        if (this.getLogger().isDebugEnabled()) {
+            this.getLogger().debug("Creating cache manager session: " + session);
+        }
+        return session;
+    }
+
+    /**
+     * @see IncludeCacheManager#load(java.lang.String, IncludeCacheManagerSession)
+     */
+    public String load(String uri,
+                        IncludeCacheManagerSession session) 
+    throws IOException, SourceException {
+        if (this.getLogger().isDebugEnabled()) {
+            this.getLogger().debug("Load " + uri + " for session " + session);
+        }
+        
+        // first make the URI absolute
+        if ( uri.indexOf("://") == -1) {
+            final Source source = session.resolveURI(uri, this.resolver);
+            uri = source.getURI();
+        }
+        
+        // if we are not processing in parallel (or do preemptive)
+        // then we don't have to do anything in this method - everything
+        // is done in the stream method.
+        
+        // if we are processing in parallel (and not preemptive) then....
+        if ( session.isParallel() && !session.isPreemptive()) {
+            
+            // first look-up if we have a valid stored response
+            IncludeCacheStorageProxy storage = session.getCacheStorageProxy();
+            CachedResponse response = (CachedResponse)storage.get(uri);
+            if ( null != response) {
+                SourceValidity[] validities = response.getValidityObjects();
+                
+                // if we are valid and do not purging
+                if ( !session.isPurging() 
+                      && validities[0].isValid() == SourceValidity.VALID) {
+                    if (this.getLogger().isDebugEnabled()) {
+                        this.getLogger().debug("Using cached response for parallel processing.");
+                    }
+                    session.add(uri, response.getResponse());
+                    return uri;
+                } else {
+                    // response is not used
+                    storage.remove(uri);
+                }
+            }
+
+            if (this.getLogger().isDebugEnabled()) {
+                this.getLogger().debug("Starting parallel thread for loading " + uri);
+            }
+            // now we start a parallel thread, this thread gets all required avalon components
+            // so it does not have to lookup them by itself
+            try {
+                XMLSerializer serializer = (XMLSerializer)this.manager.lookup(XMLSerializer.ROLE);
+                Source source = session.resolveURI(uri, this.resolver);
+
+                LoaderThread loader = new LoaderThread(source, serializer, this.manager);
+                final RunnableManager runnableManager = (RunnableManager)this.manager.lookup( RunnableManager.ROLE );
+                session.add(uri, loader);
+                runnableManager.execute( new CocoonRunnable(loader) );
+                this.manager.release( runnableManager );
+                if (this.getLogger().isDebugEnabled()) {
+                    this.getLogger().debug("Thread started for " + uri);
+                }
+            } catch (ServiceException ce) {
+                throw new SourceException("Unable to lookup thread pool, RunnableManager, or xml serializer.", ce);
+            } catch (Exception e) {
+                throw new SourceException("Unable to get pooled thread.", e);
+            }
+        }
+        return uri;
+    }
+
+    /**
+     * @see IncludeCacheManager#stream(java.lang.String, IncludeCacheManagerSession, XMLConsumer)
+     */
+    public void stream(String uri,
+                        IncludeCacheManagerSession session,
+                        XMLConsumer handler) 
+    throws IOException, SourceException, SAXException {
+
+        if (this.getLogger().isDebugEnabled()) {
+            this.getLogger().debug("Stream " + uri + " for session " + session);
+        }
+
+        // if we are processing in parallel (and not preemptive) then....
+        if ( session.isParallel() && !session.isPreemptive()) {
+            
+            // get either the cached content or the pooled thread
+            Object object = session.get(uri);
+            
+            if ( null == object ) {
+                // this should never happen!
+                throw new SAXException("No pooled thread found for " + uri);
+            }
+            byte[] result;
+            
+            // is this a pooled thread?
+            if (object instanceof LoaderThread) {
+                LoaderThread loader = (LoaderThread)object;
+                
+                if (this.getLogger().isDebugEnabled()) {
+                    this.getLogger().debug("Waiting for pooled thread to finish loading.");
+                }
+
+                // wait for it
+                loader.join();
+
+                if (this.getLogger().isDebugEnabled()) {
+                    this.getLogger().debug("Pooled thread finished loading.");
+                }
+                
+                // did an exception occur? Then reraise it
+                if ( null != loader.exception) {
+                    if ( loader.exception instanceof SAXException ) {
+                        throw (SAXException)loader.exception;
+                    } else if (loader.exception instanceof SourceException ) {
+                        throw (SourceException)loader.exception;
+                    } else if (loader.exception instanceof IOException) {
+                        throw (IOException)loader.exception;
+                    } else {
+                        throw new SAXException("Exception.", loader.exception);
+                    }
+                }
+                
+                if (this.getLogger().isDebugEnabled()) {
+                    this.getLogger().debug("Streaming from pooled thread.");
+                }
+                result = loader.content;
+
+                // cache the response (remember preemptive is off)
+                if (session.getExpires() > 0) {
+                    SourceValidity[] validities = new SourceValidity[1];
+                    validities[0] = session.getExpiresValidity();
+                    CachedResponse response = new CachedResponse(validities, result);
+                    session.getCacheStorageProxy().put(uri, response);
+                }
+            } else {
+                if (this.getLogger().isDebugEnabled()) {
+                    this.getLogger().debug("Streaming from cached response.");
+                }
+
+                // use the response from the cache
+                result = (byte[])object;
+            }
+            
+            // stream the content
+            XMLDeserializer deserializer = null;
+            try {
+                deserializer = (XMLDeserializer)this.manager.lookup( XMLDeserializer.ROLE );
+                deserializer.setConsumer(handler);
+                deserializer.deserialize(result);
+            } catch (ServiceException ce) {
+                throw new SAXException("Unable to lookup xml deserializer.", ce);
+            } finally {
+                this.manager.release( deserializer );
+            }
+            return;
+            
+        } else {
+            // we are not processing parallel
+            
+            // first: test for a cached response
+            IncludeCacheStorageProxy storage = session.getCacheStorageProxy();
+            CachedResponse response = (CachedResponse)storage.get(uri);
+            if ( null != response) {
+                SourceValidity[] validities = response.getValidityObjects();
+                // if purging is turned off and either the cached response is valid or
+                // we are loading preemptive, then use the cached response
+                if ( !session.isPurging() 
+                      && (session.isPreemptive() || validities[0].isValid() == SourceValidity.VALID)) {
+
+                    // stream the content                    
+                    if (this.getLogger().isDebugEnabled()) {
+                        this.getLogger().debug("Streaming from cached response.");
+                    }
+                    XMLDeserializer deserializer = null;
+                    try {
+                        deserializer = (XMLDeserializer)this.manager.lookup( XMLDeserializer.ROLE );
+                        deserializer.setConsumer(handler);
+                        deserializer.deserialize(response.getResponse());
+                    } catch (ServiceException ce) {
+                        throw new SAXException("Unable to lookup xml deserializer.", ce);
+                    } finally {
+                        this.manager.release( deserializer );
+                    }
+                    
+                    // load preemptive if the response is not valid
+                    if ( session.getExpires() > 0
+                         && session.isPreemptive() 
+                         && validities[0].isValid() != SourceValidity.VALID) {
+                        if (this.getLogger().isDebugEnabled()) {
+                            this.getLogger().debug("Add uri to preemptive loader list " + uri);
+                        }
+                        if (!PreemptiveLoader.getInstance().alive) {
+                            this.getLogger().error("Preemptive loader has not started yet.");
+                        }
+                        PreemptiveLoader.getInstance().add(session.getCacheStorageProxy(), uri, session.getExpires());
+                    }
+                    return;
+ 
+                } else {
+                    // cached response is not valid
+                    storage.remove(uri);
+                }
+            }
+        }
+
+        // we are not processing in parallel and have no (valid) cached response
+        XMLSerializer serializer = null;
+        try {
+            final Source source = session.resolveURI(uri, this.resolver);
+            
+            // stream directly (and cache the response)
+            if (this.getLogger().isDebugEnabled()) {
+                this.getLogger().debug("Streaming directly from source.");
+            }
+            if (session.getExpires() > 0) {
+                serializer = (XMLSerializer)this.manager.lookup(XMLSerializer.ROLE);
+                XMLTeePipe tee = new XMLTeePipe(handler, serializer);
+                
+                SourceUtil.toSAX(source, tee);
+                
+                SourceValidity[] validities = new SourceValidity[1];
+                validities[0] = session.getExpiresValidity();
+                CachedResponse response = new CachedResponse(validities,
+                                                             (byte[])serializer.getSAXFragment());
+                session.getCacheStorageProxy().put(uri, response);
+            } else {
+                SourceUtil.toSAX(source, handler);
+            }
+            
+        } catch (ProcessingException pe) {
+            throw new SAXException("ProcessingException", pe);
+        } catch (ServiceException e) {
+            throw new SAXException("Unable to lookup xml serializer.", e);
+        } finally {
+            this.manager.release(serializer);
+        }
+    }
+
+    /**
+     * @see IncludeCacheManager#terminateSession(IncludeCacheManagerSession)
+     */
+    public void terminateSession(IncludeCacheManagerSession session) {
+        if (this.getLogger().isDebugEnabled()) {
+            this.getLogger().debug("Terminating cache manager session " + session);
+        }
+        session.cleanup(this.resolver);
+    }
+
+    /**
+     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+     */
+    public void service(ServiceManager manager) throws ServiceException {
+        this.manager = manager;
+        this.resolver = (SourceResolver)this.manager.lookup(SourceResolver.ROLE);
+    }
+
+    /**
+     * @see org.apache.avalon.framework.activity.Disposable#dispose()
+     */
+    public void dispose() {
+        // stop preemptive loader (if running)
+        PreemptiveLoader.getInstance().stop();
+        if ( null != this.manager ) {
+            this.manager.release( this.resolver);
+            this.manager.release(this.store);
+            this.store = null;
+            this.resolver = null;
+            this.manager = null;
+            this.defaultCacheStorage = null;
+        }
+    }
+
+    /**
+     * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
+     */
+    public void parameterize(Parameters parameters) throws ParameterException {
+        this.preemptiveLoaderURI = parameters.getParameter("preemptive-loader-url", null);
+        if ( null != this.preemptiveLoaderURI 
+             && this.preemptiveLoaderURI.indexOf("://") == -1) {
+            throw new ParameterException("The preemptive-loader-url must be absolute: " + this.preemptiveLoaderURI);
+        }
+        final String storeRole = parameters.getParameter("use-store", Store.ROLE);
+        try {
+            this.store = (Store)this.manager.lookup(storeRole);
+        } catch (ServiceException e) {
+            throw new ParameterException("Unable to lookup store with role " + storeRole, e);
+        }
+        this.defaultCacheStorage = new StoreIncludeCacheStorageProxy(this.store, this.getLogger());
+    }
+    
+    final private static class LoaderThread implements Runnable {
+        
+        private final Source source;
+        private final XMLSerializer serializer;
+        private final CountDown finished;
+        Exception exception;
+        byte[]    content;
+        final private ServiceManager manager;
+        
+        public LoaderThread(Source source, 
+                            XMLSerializer serializer,
+                            ServiceManager manager) {
+            this.source = source;
+            this.serializer = serializer;
+            this.finished = new CountDown( 1 );
+            this.manager = manager;
+        }
+        
+        public void run() {
+            try {
+                SourceUtil.toSAX(this.source, this.serializer);
+                this.content = (byte[])this.serializer.getSAXFragment();
+            } catch (Exception local) {
+                this.exception = local;
+            } finally {
+                this.manager.release( this.serializer );
+                this.finished.release();
+            }
+        }
+        
+        void join() {
+            try {
+                this.finished.acquire();
+            } catch ( final InterruptedException ie) {
+                // ignore
+            }
+        }
+    }
+    
+    final private static class PreemptiveBooter implements Runnable {
+    
+        private final String uri;
+    
+        public PreemptiveBooter( final String uri )
+        {
+            this.uri = uri;
+        }
+        
+        public void run() {
+            try {
+                URL url = new URL(this.uri);
+                url.getContent();
+            } catch (Exception ignore) {
+            }
+        }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/DefaultIncludeCacheManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/FormValidatorHelper.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/FormValidatorHelper.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/FormValidatorHelper.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/FormValidatorHelper.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,510 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ */
+package org.apache.cocoon.transformation.helpers;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.configuration.SAXConfigurationHandler;
+import org.apache.excalibur.source.Source;
+
+import org.apache.cocoon.acting.AbstractValidatorAction;
+import org.apache.cocoon.acting.ConfigurationHelper;
+import org.apache.cocoon.acting.ValidatorActionResult;
+import org.apache.cocoon.components.source.SourceUtil;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.SourceResolver;
+
+import org.apache.avalon.framework.logger.Logger;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * The <code>ValidatorActionResult</code> object helper
+ *
+ * @author <a href="mailto:haul@apache.org">Christian Haul</a>
+ * @version CVS $Id: FormValidatorHelper.java 125963 2005-01-21 21:19:51Z cziegeler $
+ */
+public class FormValidatorHelper {
+
+    private static Map configurations = new HashMap();
+
+    /**
+     * these make it easier for the xsl
+     */
+
+    String current_descriptor = null;
+    boolean current_reloadable = true;
+    Logger current_logger = null;
+    String current_constraint_set = null;
+    String current_parameter = null;
+    SourceResolver current_resolver = null;
+
+    public FormValidatorHelper(String descriptor, boolean reloadable,
+                                  Logger logger, SourceResolver resolver) {
+        current_descriptor = descriptor;
+        current_reloadable = reloadable;
+        current_logger = logger;
+        current_resolver = resolver;
+    }
+
+    public FormValidatorHelper(String descriptor, boolean reloadable,
+                                  Logger logger, SourceResolver resolver,
+                                  String constraintset) {
+        current_descriptor = descriptor;
+        current_reloadable = reloadable;
+        current_logger = logger;
+        current_resolver = resolver;
+        current_constraint_set = constraintset;
+    }
+
+    /**
+     * keep track of current parameter context
+     */
+    public void setParameter(String parameter) {
+        current_parameter = parameter;
+    }
+
+    /**
+     * keep track of current constraint-set context
+     * (probably this is not needed?)
+     */
+    public void setConstraintSet(String constraintset) {
+        current_constraint_set = constraintset;
+    }
+
+    /**
+     * Get the specified attribute
+     *
+     * @param objectModel The Map objectModel
+     * @param name The parameter name
+     */
+    public static Object getAttribute(Map objectModel, String name) {
+        Request request = ObjectModelHelper.getRequest(objectModel);
+        return request.getAttribute(name);
+    }
+
+    /**
+     * Extracts the validation results from the request attribute
+     *
+     * @param objectModel The Map objectModel
+     * @return Map with ValidatorActionResults
+     * @see org.apache.cocoon.acting.ValidatorActionResult
+     */
+    public static Map getResults(Map objectModel) {
+        Request request = ObjectModelHelper.getRequest(objectModel);
+        return (Map) request.getAttribute(AbstractValidatorAction.FORMVALIDATOR_PATH);
+    }
+
+
+    /**
+     * Extracts the validation results from the request attribute
+     * for a specific request parameter
+     *
+     * @param objectModel The Map objectModel
+     * @param name Request parameter's name
+     * @see org.apache.cocoon.acting.ValidatorActionResult
+     */
+    public static ValidatorActionResult getParamResult(Map objectModel,
+                                                       String name) {
+        ValidatorActionResult result = ValidatorActionResult.NOTPRESENT;
+        Map param_result = getResults(objectModel);
+        if (param_result != null) {
+            result = (ValidatorActionResult) param_result.get(name);
+        }
+        return (result != null? result : ValidatorActionResult.NOTPRESENT);
+    }
+
+    /**
+     * Extracts the validation results from the request attribute
+     * for the context's current request parameter
+     *
+     * @param objectModel The Map objectModel
+     * @see org.apache.cocoon.acting.ValidatorActionResult
+     */
+    public ValidatorActionResult getParamResult(Map objectModel) {
+        ValidatorActionResult result = ValidatorActionResult.NOTPRESENT;
+        Map param_result = getResults(objectModel);
+        if (param_result != null) {
+            result = (ValidatorActionResult) param_result.get(current_parameter);
+        }
+        return (result != null? result : ValidatorActionResult.NOTPRESENT);
+    }
+
+
+    /**
+     * Test whether the validation returned no error for this
+     * parameter.
+     *
+     * @param objectModel The Map objectModel
+     * @param name Request parameter's name
+     * @return true only if the parameter was validated and the validation
+     * did not return an error.
+     */
+    public static boolean isOK(Map objectModel, String name) {
+        return getParamResult(objectModel, name).equals(ValidatorActionResult.OK);
+    }
+
+    /**
+     * Test whether the validation returned no error for the
+     * context's current parameter.
+     *
+     * @param objectModel The Map objectModel
+     * @return true only if the parameter was validated and the validation
+     * did not return an error.
+     */
+    public boolean isOK(Map objectModel) {
+        return isOK(objectModel, current_parameter);
+    }
+
+
+    /**
+     * Test whether the validation returned an error for this
+     * parameter.
+     *
+     * @param objectModel The Map objectModel
+     * @param name Request parameter's name
+     * @return true if the parameter was either not validated or the validation
+     * returned an error.
+     */
+    public static boolean isError(Map objectModel, String name) {
+        return getParamResult(objectModel, name).ge(ValidatorActionResult.ERROR);
+    }
+
+    /**
+     * Test whether the validation returned an error for the
+     * context's current parameter.
+     *
+     * @param objectModel The Map objectModel
+     * @return true if the parameter was either not validated or the validation
+     * returned an error.
+     */
+    public boolean isError(Map objectModel) {
+        return isError(objectModel, current_parameter);
+    }
+
+
+    /**
+     * Test whether the validated parameter was null but wasn't allowed to.
+     *
+     * @param objectModel The Map objectModel
+     * @param name Request parameter's name
+     * @return true if the parameter was validated and the validation
+     * returned an error because the parameter was null but wasn't allowd to.
+     */
+    public static boolean isNull(Map objectModel, String name) {
+        return getParamResult(objectModel, name).equals(ValidatorActionResult.ISNULL);
+    }
+
+    /**
+     * Test whether the context's current parameter as validated was null but
+     * wasn't allowed to.
+     *
+     * @param objectModel The Map objectModel
+     * @return true if the parameter was validated and the validation
+     * returned an error because the parameter was null but wasn't allowd to.
+     */
+    public boolean isNull(Map objectModel) {
+        return isNull(objectModel, current_parameter);
+    }
+
+
+    /**
+     * Test whether the validated parameter was too small.
+     *
+     * @param objectModel The Map objectModel
+     * @param name Request parameter's name
+     * @return true if the parameter was validated and the validation
+     * returned an error because either its value or its length was
+     * too small.
+     */
+    public static boolean isTooSmall(Map objectModel, String name) {
+        boolean ok = getParamResult(objectModel, name).equals(ValidatorActionResult.TOOSMALL);
+
+        if (!ok) {
+            ok = isNull(objectModel, name);
+        }
+
+        return ok;
+    }
+
+    /**
+     * Test whether the context's current parameter was too small.
+     *
+     * @param objectModel The Map objectModel
+     * @return true if the parameter was validated and the validation
+     * returned an error because either its value or its length was
+     * too small.
+     */
+    public boolean isTooSmall(Map objectModel) {
+        return isTooSmall(objectModel, current_parameter);
+    }
+
+
+    /**
+     * Test whether the validated parameter was too large.
+     *
+     * @param objectModel The Map objectModel
+     * @param name Request parameter's name
+     * @return true if the parameter was validated and the validation
+     * returned an error because either its value or its length was
+     * too large.
+     */
+    public static boolean isTooLarge(Map objectModel, String name) {
+        return (getParamResult(objectModel, name) == ValidatorActionResult.TOOLARGE);
+    }
+
+    /**
+     * Test whether the context's current parameter was too large.
+     *
+     * @param objectModel The Map objectModel
+     * @return true if the parameter was validated and the validation
+     * returned an error because either its value or its length was
+     * too large.
+     */
+    public boolean isTooLarge(Map objectModel) {
+        return isTooLarge(objectModel, current_parameter);
+    }
+
+
+    /**
+     * Test whether the validated parameter wasn't matched by the requested
+     * regular expression.
+     *
+     * @param objectModel The Map objectModel
+     * @param name Request parameter's name
+     * @return true if the parameter was validated and the validation
+     * returned an error because its value wasn't matched by the requested
+     * regular expression.
+     */
+    public static boolean isNoMatch(Map objectModel, String name) {
+        return getParamResult(objectModel, name).equals(ValidatorActionResult.NOMATCH);
+    }
+
+    /**
+     * Test whether the context's current parameter wasn't matched by the requested
+     * regular expression.
+     *
+     * @param objectModel The Map objectModel
+     * @return true if the parameter was validated and the validation
+     * returned an error because its value wasn't matched by the requested
+     * regular expression.
+     */
+    public boolean isNoMatch(Map objectModel) {
+        return isNoMatch(objectModel, current_parameter);
+    }
+
+
+    /**
+     * Test whether the validated parameter wasn't validated
+     *
+     * @param objectModel The Map objectModel
+     * @param name Request parameter's name
+     * @return true if the parameter was not validated.
+     */
+    public static boolean isNotPresent(Map objectModel, String name) {
+        return getParamResult(objectModel, name).equals(ValidatorActionResult.NOTPRESENT);
+    }
+
+    /**
+     * Test whether the context's current parameter wasn't validated
+     *
+     * @param objectModel The Map objectModel
+     * @return true if the parameter was not validated.
+     */
+    public boolean isNotPresent(Map objectModel) {
+        return isNotPresent(objectModel, current_parameter);
+    }
+
+
+    /**
+     * Set up the complementary configuration file.  Please note that
+     * multiple Actions can share the same configurations.  By using
+     * this approach, we can limit the number of config files.
+     * Also note that the configuration file does not have to be a file.
+     *
+     * This is based on the similar named functions in
+     * org.apache.cocoon.acting.AbstractComplimentaryConfigurableAction
+     * with the addition of reloadable configuration files, reloadable
+     * flagg, manager, and logger  parameter.
+     *
+     * @param descriptor URL of descriptor.xml file @see org.apache.cocoon.acting.AbstractComplimentaryConfigurableAction
+     * @param resolver
+     * @param reloadable set to <code>true</code> if changes of
+     * <code>descriptor</code> should trigger a reload. Note that this
+     * only works if <code>Source</code> is able to determine the
+     * modification time @see org.apache.cocoon.environment.Source
+     * @param logger used to send debug and error messages to
+     * @return up-to-date configuration, either (re)loaded or cached.
+     */
+
+    protected static Configuration getConfiguration(String descriptor, SourceResolver resolver,
+                                                    boolean reloadable, Logger logger)
+            throws ConfigurationException {
+
+        if (descriptor == null) {
+            throw new ConfigurationException("The form descriptor is not set!");
+        }
+
+        ConfigurationHelper conf = null;
+        synchronized (FormValidatorHelper.configurations) {
+            Source source = null;
+            try {
+                source = resolver.resolveURI(descriptor);
+                conf = (ConfigurationHelper) FormValidatorHelper.configurations.get(source.getURI());
+                if (conf == null || (reloadable && conf.lastModified != source.getLastModified())) {
+                    logger.debug("(Re)Loading " + descriptor);
+
+                    if (conf == null) {
+                        conf = new ConfigurationHelper();
+                    }
+
+                    SAXConfigurationHandler builder = new SAXConfigurationHandler();
+                    SourceUtil.toSAX(source, builder);
+
+                    conf.lastModified = source.getLastModified();
+                    conf.configuration = builder.getConfiguration();
+
+                    FormValidatorHelper.cacheConfiguration(source.getURI(), conf);
+                } else {
+                    logger.debug("Using cached configuration for " + descriptor);
+                }
+            } catch (Exception e) {
+                logger.error("Could not configure Database mapping environment", e);
+                throw new ConfigurationException("Error trying to load configurations for resource: " + source.getURI());
+            } finally {
+                resolver.release(source);
+            }
+        }
+
+        return conf.configuration;
+    }
+
+    /**
+     * Cache the configuration so that we can use it later.
+     */
+    private static void cacheConfiguration(String descriptor, ConfigurationHelper conf) {
+        synchronized (FormValidatorHelper.configurations) {
+            FormValidatorHelper.configurations.put(descriptor, conf);
+        }
+    }
+
+    /**
+     * Iterate over a set of configurations and return the one whose
+     * name matches the given one.
+     *
+     * @param conf set of configurations
+     * @param name name of configuration
+     * @param logger
+     * @return specified configuration or <code>null</code> if not found.
+     */
+    protected static Configuration getConfigurationByName(Configuration[] conf,
+                                                          String name,
+                                                          Logger logger
+                                                          ) {
+        int j = 0;
+        boolean found = false;
+        String setname = null;
+        for (j = 0; j < conf.length; j++) {
+            setname = conf[j].getAttribute("name", "");
+            if (name.trim().equals(setname.trim())) {
+                found = true;
+                break;
+            }
+        }
+        if (!found) {
+            logger.debug("FormValidatorHelper.getConfigurationByName: configuration " + name + " not found.");
+            return null;
+        }
+        return conf[j];
+    }
+
+    /**
+     * Get an attribute for a parameter as specified in
+     * descriptor.xml.
+     *
+     * @param descriptor URL of descriptor.xml file @see org.apache.cocoon.acting.AbstractComplimentaryConfigurableAction
+     * @param resolver
+     * @param reloadable set to <code>true</code> if changes of
+     * <code>descriptor</code> should trigger a reload. Note that this
+     * only works if <code>Source</code> is able to determine the
+     * modification time @see org.apache.cocoon.environment.Source
+     * @param logger used to send debug and error messages to
+     * @param attribute attribute name
+     * @return attribute value or <code>null</code>
+     */
+    public static String getParameterAttributes(String descriptor,
+                                                SourceResolver resolver,
+                                                boolean reloadable,
+                                                String constraintset,
+                                                String parameter,
+                                                String attribute,
+                                                Logger logger
+                                                ) {
+        try {
+            Configuration conf = getConfiguration(descriptor, resolver, reloadable, logger);
+            Configuration[] desc = conf.getChildren("parameter");
+            Configuration[] csets = conf.getChildren("constraint-set");
+
+            Configuration cset = getConfigurationByName(csets, constraintset, logger);
+
+            Configuration[] set = cset.getChildren("validate");
+            Configuration constraints = getConfigurationByName(set, parameter, logger);
+            Configuration descr = getConfigurationByName(desc, parameter, logger);
+            return constraints.getAttribute(attribute, descr.getAttribute(attribute, ""));
+        } catch (Exception e) {
+            logger.debug("FormValidatorHelper.getParameterAttributes Exception " + e);
+        }
+        
+        return "";
+    }
+
+
+    /**
+     * Get an attribute for the context's current parameter as specified in
+     * descriptor.xml.
+     *
+     * @param attribute attribute name
+     * @return attribute value or <code>null</code>
+     */
+    public String getParameterAttribute(String attribute) {
+        return FormValidatorHelper.getParameterAttributes(current_descriptor,
+                current_resolver,
+                current_reloadable,
+                current_constraint_set,
+                current_parameter,
+                attribute,
+                current_logger);
+    }
+
+    /**
+     * Get an attribute for a parameter as specified in
+     * descriptor.xml.
+     *
+     * @param attribute attribute name
+     * @return attribute value or <code>null</code>
+     */
+    public String getParameterAttribute(String parameter, String attribute) {
+        return FormValidatorHelper.getParameterAttributes(current_descriptor,
+                current_resolver,
+                current_reloadable,
+                current_constraint_set,
+                parameter,
+                attribute,
+                current_logger);
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/FormValidatorHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/IncludeCacheManager.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/IncludeCacheManager.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/IncludeCacheManager.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/IncludeCacheManager.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,82 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ */
+package org.apache.cocoon.transformation.helpers;
+
+import java.io.IOException;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.apache.excalibur.source.SourceException;
+import org.xml.sax.SAXException;
+
+/**
+ * The include cache manager is a component that can manage included content.
+ * It can eiter load them in parallel or pre-emptive and cache the content
+ * for a given period of time.
+ * 
+ *  @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ *  @version CVS $Id: IncludeCacheManager.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ *  @since   2.1
+ */
+public interface IncludeCacheManager {
+
+    /** Avalon role */
+    String ROLE = IncludeCacheManager.class.getName();
+    
+    /**
+     * Create a session for this request.
+     * This should be invoked first and only one per request. It is required
+     * to terminate the session with {@link #terminateSession(IncludeCacheManagerSession)}
+     * @param pars The configuration
+     * @return CacheManagerSession The session that should be used with all other commands.
+     */
+    IncludeCacheManagerSession getSession(Parameters pars);
+    
+    /**
+     * This informs the manager that a URI should be "loaded".
+     * @param uri     The URI to load (maybe relative)
+     * @param session The corresponding session created by {@link #getSession(Parameters)}
+     * @return String The absolute URI that must be used for {@link #stream(String, IncludeCacheManagerSession, XMLConsumer)}
+     * @throws IOException
+     * @throws SourceException
+     */
+    String load(String  uri, 
+                IncludeCacheManagerSession session)
+    throws IOException, SourceException;
+              
+    /**
+     * Stream the content of the absolute URI.
+     * Depending on the configuration and state of the cache, the
+     * content is either taken from the cache, fetched etc.
+     * @param uri     The absolute URI returned by {@link #load(String, IncludeCacheManagerSession)}
+     * @param session The current session
+     * @param handler The receiver of the SAX events
+     * @throws IOException
+     * @throws SourceException
+     * @throws SAXException
+     */
+    void stream(String uri,
+                 IncludeCacheManagerSession session,
+                 XMLConsumer handler)
+    throws IOException, SourceException, SAXException;
+                 
+    /**
+     * Terminate the session. This method must be executed at the end of the
+     * request.
+     * @param session The caching session.
+     */
+    void terminateSession(IncludeCacheManagerSession session);
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/IncludeCacheManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/IncludeCacheManagerSession.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/IncludeCacheManagerSession.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/IncludeCacheManagerSession.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/IncludeCacheManagerSession.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,196 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ */
+package org.apache.cocoon.transformation.helpers;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.excalibur.source.SourceValidity;
+import org.apache.excalibur.source.impl.validity.ExpiresValidity;
+
+/**
+ * This object encapsulates a "caching session". A caching session has the
+ * duration of one single request.
+ * This object is used by the {@link IncludeCacheManager} and holds all required
+ * configuration for performing the caching of this request.
+ * 
+ * The session can be configured during construction with the following parameters:
+ * - purge (boolean/false) : Turn on/off purging the cache
+ * - preemptive (boolean/false) : Turn on/off preemptive caching
+ * - parallel (boolean/false) : Turn on/off parallel processing
+ * - expires (long/0) : The lifetime of the cached content
+ * 
+ *  @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ *  @version CVS $Id: IncludeCacheManagerSession.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ *  @since   2.1
+ */
+public final class IncludeCacheManagerSession {
+
+    /** The expires information */
+    private long expires;
+    
+    /** Should we purge the cache */
+    private boolean purge;
+    
+    /** Should we load preemptive */
+    private boolean preemptive;
+    
+    /** Should we process everything in parallel */
+    private boolean parallel;
+
+    /** The used {@link IncludeCacheStorageProxy} */
+    private IncludeCacheStorageProxy storage;
+    
+    /** The list of all threads */
+    private Map threadList;
+    
+    /** Cache the expires validity object */
+    private SourceValidity validity;
+    
+    /** Cache the source objects */
+    private Map sourceList = new HashMap(10);
+    
+    /**
+     * Constructor
+     * @param configuration The parameters configuring this session
+     * @param proxy         The proxy used to cache the data
+     */
+    IncludeCacheManagerSession(Parameters configuration, 
+                        IncludeCacheStorageProxy proxy) {
+        this.expires = configuration.getParameterAsLong("expires", 0);
+        this.purge = configuration.getParameterAsBoolean("purge", false);    
+        this.preemptive = configuration.getParameterAsBoolean("preemptive", false);
+        this.parallel = configuration.getParameterAsBoolean("parallel", false);
+        this.storage = proxy;    
+    }
+    
+    /**
+     * Get the used storage proxy
+     */
+    IncludeCacheStorageProxy getCacheStorageProxy() {
+        return this.storage;
+    }
+
+    /**
+     * Get the expiration information
+     */
+    public long getExpires() {
+        return this.expires;
+    }
+
+    public SourceValidity getExpiresValidity() {
+        if ( this.expires > 0 && this.validity == null) {
+            this.validity = new ExpiresValidity( this.expires * 1000 ); // milliseconds
+        }
+        return this.validity;
+    }
+    
+    /**
+     * Is the cache purged?
+     */
+    public boolean isPurging() {
+        return this.purge;
+    }
+
+    /**
+     * Do we use preemptive caching?
+     */
+    public boolean isPreemptive() {
+        return this.preemptive;
+    }
+
+    /**
+     * Do we process the includes in parallel?
+     */
+    public boolean isParallel() {
+        return this.parallel;
+    }
+
+    /**
+     * Add another object to the thread list
+     * @param uri    The absolute URI
+     * @param object The thread
+     */
+    void add(String uri, Object object) {
+        if ( null == this.threadList ) {
+            this.threadList = new HashMap(10);
+        }
+        this.threadList.put(uri, object);
+    }
+    
+    /**
+     * Get the thread object.
+     * @param uri     The URI
+     * @return Object The thread.
+     */
+    Object get(String uri) {
+        if ( null != this.threadList ) {
+            return this.threadList.get( uri );
+        }
+        return null;
+    }
+    
+    /**
+     * Turn off/on preemptive caching
+     */
+    void setPreemptive(boolean value) {
+        this.preemptive = value;
+    }
+    
+    /**
+     * Lookup a source object and cache it
+     * @param uri     Absolute URI
+     * @return Source The source obejct
+     */
+    public Source resolveURI(String uri, SourceResolver resolver) 
+    throws IOException {
+        Source source = (Source)this.sourceList.get(uri);
+        if ( null == source ) {
+            source = resolver.resolveURI( uri );
+            this.sourceList.put( source.getURI(), source );
+        }
+        return source;
+    }
+    
+    /**
+     * Cleanup
+     * @param resolver The source resolver to release cached sources
+     */
+    void cleanup(SourceResolver resolver) {
+        Iterator iter = this.sourceList.values().iterator();
+        while ( iter.hasNext() ) {
+            final Source source = (Source) iter.next();
+            resolver.release( source );   
+        }
+    }
+    
+    /**
+     * Print a representation of this object
+     */
+    public String toString() {
+        return "CacheManagerSession(" + this.hashCode() + ") -" +
+                " expires: " + this.expires +
+                " parallel: " + this.parallel + 
+                " preemptive: " + this.preemptive +
+                " purge: " + this.purge;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/IncludeCacheManagerSession.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/IncludeCacheStorageProxy.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/IncludeCacheStorageProxy.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/IncludeCacheStorageProxy.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/IncludeCacheStorageProxy.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,55 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ */
+package org.apache.cocoon.transformation.helpers;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+/**
+ * A CacheStorageProxy is an interface object between the {@link IncludeCacheManager}
+ * and the real store caching the content.
+ * Currently you can use the {@link StoreIncludeCacheStorageProxy} that uses the
+ * usual store or the {@link ModifiableSourceIncludeCacheStorageProxy} that
+ * uses a configured source.
+ * 
+ *  @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ *  @version CVS $Id: IncludeCacheStorageProxy.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ *  @since   2.1
+ */
+public interface IncludeCacheStorageProxy {
+
+    /**
+     * Get the cached content for the given URI.
+     * @param uri Absolute URI specifying the content
+     * @return Serializable
+     */
+    Serializable get(String uri);
+    
+    /**
+     * Put the content into the cache for the given URI.
+     * @param uri Absolute URI specifying the content
+     * @param object The content
+     * @throws IOException
+     */
+    void put(String uri, Serializable object)
+    throws IOException;
+    
+    /**
+     * Remove the cached content for the given URI
+     * @param uri Absolute URI specifying the content
+     */
+    void remove(String uri);
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/transformation/helpers/IncludeCacheStorageProxy.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message