You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2006/07/14 09:50:34 UTC

svn commit: r421827 - in /cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing: ./ impl/ pipeline/ sitemap/impl/

Author: cziegeler
Date: Fri Jul 14 00:50:33 2006
New Revision: 421827

URL: http://svn.apache.org/viewvc?rev=421827&view=rev
Log:
Minor tweaks to processor api
New idea for pipeline api

Added:
    cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/ProcessingException.java   (with props)
    cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Generator.java   (with props)
    cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/PipelineComponent.java   (with props)
    cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/PipelineComponentConfiguration.java   (with props)
    cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/PipelineComponentParameters.java   (with props)
    cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Serializer.java   (with props)
    cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Transformer.java   (with props)
Modified:
    cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/Processor.java
    cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/impl/MountTableProcessorImpl.java
    cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Producer.java
    cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/sitemap/impl/SitemapProcessor.java

Added: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/ProcessingException.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/ProcessingException.java?rev=421827&view=auto
==============================================================================
--- cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/ProcessingException.java (added)
+++ cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/ProcessingException.java Fri Jul 14 00:50:33 2006
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2006 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.processing;
+
+import java.util.List;
+
+import org.apache.cocoon.util.location.LocatedException;
+import org.apache.cocoon.util.location.LocatedRuntimeException;
+import org.apache.cocoon.util.location.Location;
+import org.apache.cocoon.util.location.MultiLocatable;
+
+/**
+ * This Exception is thrown every time there is a problem in processing
+ * a request.
+ *
+ * @version $Id:$
+ * @since 2.2
+ */
+public class ProcessingException extends LocatedException {
+    
+    /**
+     * Construct a new <code>ProcessingException</code> instance.
+     */
+    public ProcessingException(String message) {
+        super(message);
+    }
+    
+    /**
+     * Creates a new <code>ProcessingException</code> instance.
+     *
+     * @param ex an <code>Exception</code> value
+     */
+    public ProcessingException(Exception ex) {
+        super(ex.getMessage(), ex);
+    }
+    
+    /**
+     * Construct a new <code>ProcessingException</code> that references
+     * a parent Exception.
+     */
+    public ProcessingException(String message, Throwable t) {
+        super(message, t);
+    }
+    
+    /**
+     * Construct a new <code>ProcessingException</code> that has an associated location.
+     */
+    public ProcessingException(String message, Location location) {
+        super(message, location);
+    }
+    
+    /**
+     * Construct a new <code>ProcessingException</code> that has a parent exception
+     * and an associated location.
+     * <p>
+     * This constructor is protected to enforce the use of {@link #throwLocated(String, Throwable, Location)}
+     * which limits exception nesting as far as possible.
+     */
+    protected ProcessingException(String message, Throwable t, Location location) {
+        super(message, t, location);
+    }
+    
+    /**
+     * Throw a located exception given an existing exception and the location where
+     * this exception was catched.
+     * <p>
+     * If the exception is already a <code>ProcessingException</code> or a {@link LocatedRuntimeException},
+     * the location is added to the original exception's location chain and the original exception
+     * is rethrown (<code>description</code> is ignored) to limit exception nesting. Otherwise, a new
+     * <code>ProcessingException</code> is thrown, wrapping the original exception.
+     * <p>
+     * Note: this method returns an exception as a convenience if you want to keep the <code>throw</code>
+     * semantics in the caller code, i.e. write<br>
+     * <code>&nbsp;&nbsp;throw ProcessingException.throwLocated(...);</code><br>
+     * instead of<br>
+     * <code>&nbsp;&nbsp;ProcessingException.throwLocated(...);</code><br>
+     * <code>&nbsp;&nbsp;return;</code>
+     * 
+     * @param message a message (can be <code>null</code>)
+     * @param thr the original exception (can be <code>null</code>)
+     * @param location the location (can be <code>null</code>)
+     * @return a (fake) located exception
+     * @throws ProcessingException or <code>LocatedRuntimeException</code>
+     */
+    public static ProcessingException throwLocated(String message, Throwable thr, Location location) throws ProcessingException {
+        if (thr instanceof ProcessingException) {
+            ProcessingException pe = (ProcessingException)thr;
+            pe.addLocation(location);
+            throw pe;
+
+        } else if (thr instanceof LocatedRuntimeException) {
+            LocatedRuntimeException re = (LocatedRuntimeException)thr;
+            re.addLocation(location);
+            // Rethrow
+            throw re;
+        }
+        
+        throw new ProcessingException(message, thr, location);
+    }
+    
+    /**
+     * Throw a located exception given an existing exception and the locations where
+     * this exception was catched.
+     * <p>
+     * If the exception is already a <code>ProcessingException</code> or a {@link LocatedRuntimeException},
+     * the locations are added to the original exception's location chain and the original exception
+     * is rethrown (<code>description</code> is ignored) to limit exception nesting. Otherwise, a new
+     * <code>ProcessingException</code> is thrown, wrapping the original exception.
+     * <p>
+     * Note: this method returns an exception as a convenience if you want to keep the <code>throw</code>
+     * semantics in the caller code, i.e. write<br>
+     * <code>&nbsp;&nbsp;throw ProcessingException.throwLocated(...);</code><br>
+     * instead of<br>
+     * <code>&nbsp;&nbsp;ProcessingException.throwLocated(...);</code><br>
+     * <code>&nbsp;&nbsp;return;</code>
+     * 
+     * @param message a message (can be <code>null</code>)
+     * @param thr the original exception (can be <code>null</code>)
+     * @param locations the locations (can be <code>null</code>)
+     * @return a (fake) located exception
+     * @throws ProcessingException or <code>LocatedRuntimeException</code>
+     */
+    public static ProcessingException throwLocated(String message, Throwable thr, List locations) throws ProcessingException {
+        MultiLocatable multiloc;
+        if (thr instanceof ProcessingException) {
+            multiloc = (ProcessingException)thr;
+        } else if (thr instanceof LocatedRuntimeException) {
+            multiloc = (LocatedRuntimeException)thr;
+        } else {
+            multiloc = new ProcessingException(message, thr);
+        }
+        
+        if (locations != null) {
+            for (int i = 0; i < locations.size(); i++) {
+                multiloc.addLocation((Location)locations.get(i));
+            }
+        }
+        
+        if (multiloc instanceof LocatedRuntimeException) {
+            throw (LocatedRuntimeException)multiloc;
+        } else {
+            throw (ProcessingException)multiloc;
+        }
+    }
+}

Propchange: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/ProcessingException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/ProcessingException.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/Processor.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/Processor.java?rev=421827&r1=421826&r2=421827&view=diff
==============================================================================
--- cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/Processor.java (original)
+++ cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/Processor.java Fri Jul 14 00:50:33 2006
@@ -15,9 +15,13 @@
  */
 package org.apache.cocoon.processing;
 
+import java.io.IOException;
+
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.xml.sax.SAXException;
+
 /**
  * @version $Id$
  * @since 2.2
@@ -25,5 +29,5 @@
 public interface Processor {
 
     boolean process(HttpServletRequest request, HttpServletResponse response)
-    throws Exception;
+    throws ProcessingException, IOException, SAXException;
 }

Modified: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/impl/MountTableProcessorImpl.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/impl/MountTableProcessorImpl.java?rev=421827&r1=421826&r2=421827&view=diff
==============================================================================
--- cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/impl/MountTableProcessorImpl.java (original)
+++ cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/impl/MountTableProcessorImpl.java Fri Jul 14 00:50:33 2006
@@ -15,6 +15,7 @@
  */
 package org.apache.cocoon.processing.impl;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -24,6 +25,7 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.cocoon.processing.MountableProcessor;
+import org.apache.cocoon.processing.ProcessingException;
 import org.apache.cocoon.processing.Processor;
 import org.apache.cocoon.servlet.RequestUtil;
 import org.springframework.beans.BeansException;
@@ -31,6 +33,7 @@
 import org.springframework.beans.factory.BeanFactoryAware;
 import org.springframework.beans.factory.BeanFactoryUtils;
 import org.springframework.beans.factory.ListableBeanFactory;
+import org.xml.sax.SAXException;
 
 /**
  * A processor that manages a "mount table", allowing to add sitemaps to a Cocoon application
@@ -76,7 +79,7 @@
      * @see org.apache.cocoon.processing.Processor#process(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
      */
     public boolean process(HttpServletRequest request, HttpServletResponse response)
-    throws Exception {
+    throws ProcessingException, IOException, SAXException {
         final String uri = RequestUtil.getCompleteUri(request, response);
         if ( uri == null ) {
             // a redirect occured

Added: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Generator.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Generator.java?rev=421827&view=auto
==============================================================================
--- cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Generator.java (added)
+++ cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Generator.java Fri Jul 14 00:50:33 2006
@@ -0,0 +1,37 @@
+/*
+ * 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.processing.pipeline;
+
+import org.apache.cocoon.processing.ProcessingException;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+
+/**
+ * A generator is the starting point of a pipeline. It "generates" XML
+ * and starts streaming them into the pipeline.
+ * 
+ * @version $Id$
+ * @since 2.2
+ */
+public interface Generator extends Producer, PipelineComponent {
+
+    /**
+     * Generate the XML and stream it into the pipeline
+     */
+    void generate()
+    throws IOException, SAXException, ProcessingException;
+}

Propchange: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Generator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Generator.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/PipelineComponent.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/PipelineComponent.java?rev=421827&view=auto
==============================================================================
--- cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/PipelineComponent.java (added)
+++ cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/PipelineComponent.java Fri Jul 14 00:50:33 2006
@@ -0,0 +1,64 @@
+/*
+ * 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.processing.pipeline;
+
+import org.apache.cocoon.processing.ProcessingException;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * The PipelineComponent identifies the contract between the Sitemap and
+ * your pipeline components that create or transform information.  The types
+ * of components that fit within this umbrella are your Generators,
+ * Transformers, and your Readers.  It is very important to note that all
+ * components impementing this interface must be pooled or created on demand.
+ * This is due to the separation between the setup and the execution.  If you
+ * don't ensure every instance of the component is unique within a pipeline,
+ * or accross pipelines, then the setup process will start killing all the
+ * other setups and you will end up with serious race conditions.  It's not
+ * that they need synchronized keywords applied to the methods, its that the
+ * methods have to be called in a certain order.  This is by design.  If you
+ * really think about it, due to the SAX infrastructure we would still need to
+ * keep them synchronized because the order of SAX events affects the validity
+ * of your XML document.
+ *
+ * @version $Id$
+ * @since 2.2
+ */
+public interface PipelineComponent {
+    
+    /**
+     * The Sitemap will call the setup() method to prepare the component for
+     * use.  This is where you start the process of getting your information
+     * ready to generate your results.  See {@link org.apache.cocoon.environment.ObjectModelHelper} for help with the <code>objectModel</code>.
+     *
+     * @param request
+     * @param response
+     * @param configuration
+     *
+     * @throws SAXException if there is a problem reading a SAX stream.
+     * @throws IOException  if there is a problem reading files.
+     * @throws ProcessingException if there is any other unexpected problem.
+     */
+    void setup(HttpServletRequest             request,
+               HttpServletResponse            response,
+               PipelineComponentConfiguration configuration) 
+    throws ProcessingException, SAXException, IOException;
+}

Propchange: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/PipelineComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/PipelineComponent.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/PipelineComponentConfiguration.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/PipelineComponentConfiguration.java?rev=421827&view=auto
==============================================================================
--- cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/PipelineComponentConfiguration.java (added)
+++ cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/PipelineComponentConfiguration.java Fri Jul 14 00:50:33 2006
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2006 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.processing.pipeline;
+
+import java.io.Serializable;
+
+/**
+ * @version $Id$
+ * @since 2.2
+ */
+public class PipelineComponentConfiguration
+    implements Serializable {
+
+    protected PipelineComponentParameters parameters;
+
+    protected String source;
+
+    protected String mimeType;
+
+    public String getMimeType() {
+        return mimeType;
+    }
+
+    public void setMimeType(String mimeType) {
+        this.mimeType = mimeType;
+    }
+
+    public PipelineComponentParameters getParameters() {
+        return parameters;
+    }
+
+    public void setParameters(PipelineComponentParameters parameters) {
+        this.parameters = parameters;
+    }
+
+    public String getSource() {
+        return source;
+    }
+
+    public void setSource(String source) {
+        this.source = source;
+    }
+}

Propchange: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/PipelineComponentConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/PipelineComponentConfiguration.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/PipelineComponentParameters.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/PipelineComponentParameters.java?rev=421827&view=auto
==============================================================================
--- cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/PipelineComponentParameters.java (added)
+++ cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/PipelineComponentParameters.java Fri Jul 14 00:50:33 2006
@@ -0,0 +1,489 @@
+/*
+ * Copyright 2006 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.processing.pipeline;
+
+import org.apache.cocoon.processing.ProcessingException;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * The <code>PipelineComponentParameters</code> class represents a set of key-value
+ * pairs to configure a component for the current pipeline execution.
+ * <p>
+ * The <code>PipelineComponentParameters</code> object provides a mechanism to obtain
+ * values based on a <code>String</code> name.  There are convenience
+ * methods that allow you to use defaults if the value does not exist,
+ * as well as obtain the value in some other formats like integer, boolean or long.
+ * </p><p>
+ * <strong>Note: this class is not thread safe by default.</strong> If you
+ * require thread safety please synchronize write access to this class to
+ * prevent potential data corruption.
+ * </p>
+ *
+ * @version $Id$
+ * @since 2.2
+ */
+public class PipelineComponentParameters
+    implements Serializable {
+
+    /**
+     * Empty Parameters object
+     */
+    public static final PipelineComponentParameters EMPTY_PARAMETERS;
+
+    /** Static initializer to initialize the empty Parameters object */
+    static {
+        EMPTY_PARAMETERS = new PipelineComponentParameters();
+        EMPTY_PARAMETERS.makeReadOnly();
+    }
+
+    ///Underlying store of parameters
+    private Map parameters = new HashMap();
+
+    private boolean readOnly;
+
+    /**
+     * Set the <code>String</code> value of a specified parameter.
+     * <p />
+     * If the specified value is <b>null</b> the parameter is removed.
+     *
+     * @param name a <code>String</code> value
+     * @param value a <code>String</code> value
+     * @return The previous value of the parameter or <b>null</b>.
+     * @throws IllegalStateException if the Parameters object is read-only
+     */
+    public String setParameter( final String name, final String value )
+    throws IllegalStateException {
+        checkWriteable();
+
+        if( null == name ) {
+            return null;
+        }
+
+        if( null == value ) {
+            return (String)parameters.remove( name );
+        }
+
+        return (String)parameters.put( name, value );
+    }
+
+    /**
+     * Remove a parameter from the parameters object
+     * @param name a <code>String</code> value
+     */
+    public void removeParameter( final String name ) {
+        setParameter( name, null );
+    }
+
+    /**
+     * Retrieve an array of all parameter names.
+     *
+     * @return the parameters names
+     */
+    public Collection getNames() {
+        return parameters.keySet();
+    }
+
+    /**
+     * Test if the specified parameter can be retrieved.
+     *
+     * @param name the parameter name
+     * @return true if parameter is a name
+     */
+    public boolean isParameter( final String name ) {
+        return parameters.containsKey( name );
+    }
+
+    /**
+     * Retrieve the <code>String</code> value of the specified parameter.
+     * <p />
+     * If the specified parameter cannot be found, an exception is thrown.
+     *
+     * @param name the name of parameter
+     * @return the value of parameter
+     * @throws ParameterException if the specified parameter cannot be found
+     */
+    public String getParameter( final String name )
+    throws ProcessingException {
+        if( null == name ) {
+            throw new ProcessingException( "You cannot lookup a null parameter" );
+        }
+
+        final String test = (String)parameters.get( name );
+
+        if( null == test ) {
+            throw new ProcessingException( "The parameter '" + name
+                                          + "' does not contain a value" );
+        } else {
+            return test;
+        }
+    }
+
+    /**
+     * Retrieve the <code>String</code> value of the specified parameter.
+     * <p />
+     * If the specified parameter cannot be found, <code>defaultValue</code>
+     * is returned.
+     *
+     * @param name the name of parameter
+     * @param defaultValue the default value, returned if parameter does not exist
+     *        or parameter's name is null
+     * @return the value of parameter
+     */
+    public String getParameter( final String name, final String defaultValue ) {
+        if( name == null ) {
+            return defaultValue;
+        }
+
+        final String test = (String)parameters.get( name );
+
+        if( test == null ) {
+            return defaultValue;
+        } else {
+            return test;
+        }
+    }
+
+    /**
+     * Parses string represenation of the <code>int</code> value.
+     * <p />
+     * Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary
+     * numbers begin with 0b, all other values are assumed to be decimal.
+     *
+     * @param value the value to parse
+     * @return the integer value
+     * @throws NumberFormatException if the specified value can not be parsed
+     */
+    private int parseInt( final String value )
+        throws NumberFormatException
+    {
+        if( value.startsWith( "0x" ) ) {
+            return Integer.parseInt( value.substring( 2 ), 16 );
+        } else if( value.startsWith( "0o" ) ) {
+            return Integer.parseInt( value.substring( 2 ), 8 );
+        } else if( value.startsWith( "0b" ) ) {
+            return Integer.parseInt( value.substring( 2 ), 2 );
+        } else {
+            return Integer.parseInt( value );
+        }
+    }
+
+    /**
+     * Retrieve the <code>int</code> value of the specified parameter.
+     * <p />
+     * If the specified parameter cannot be found, an exception is thrown.
+     *
+     * Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary
+     * numbers begin with 0b, all other values are assumed to be decimal.
+     *
+     * @param name the name of parameter
+     * @return the integer parameter type
+     * @throws ParameterException if the specified parameter cannot be found
+     *         or is not an Integer value
+     */
+    public int getParameterAsInteger( final String name )
+    throws ProcessingException {
+        try {
+            return parseInt( getParameter( name ) );
+        } catch( final NumberFormatException e ) {
+            throw new ProcessingException( "Could not return an integer value", e );
+        }
+    }
+
+    /**
+     * Retrieve the <code>int</code> value of the specified parameter.
+     * <p />
+     * If the specified parameter cannot be found, <code>defaultValue</code>
+     * is returned.
+     *
+     * Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary
+     * numbers begin with 0b, all other values are assumed to be decimal.
+     *
+     * @param name the name of parameter
+     * @param defaultValue value returned if parameter does not exist or is of wrong type
+     * @return the integer parameter type
+     */
+    public int getParameterAsInteger( final String name, final int defaultValue ) {
+        try {
+            final String value = getParameter( name, null );
+            if( value == null ) {
+                return defaultValue;
+            }
+
+            return parseInt( value );
+        } catch( final NumberFormatException e ) {
+            return defaultValue;
+        }
+    }
+
+    /**
+     * Parses string represenation of the <code>long</code> value.
+     * <p />
+     * Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary
+     * numbers begin with 0b, all other values are assumed to be decimal.
+     *
+     * @param value the value to parse
+     * @return the long value
+     * @throws NumberFormatException if the specified value can not be parsed
+     */
+    private long parseLong( final String value )
+    throws NumberFormatException {
+        if( value.startsWith( "0x" ) ) {
+            return Long.parseLong( value.substring( 2 ), 16 );
+        } else if( value.startsWith( "0o" ) ) {
+            return Long.parseLong( value.substring( 2 ), 8 );
+        } else if( value.startsWith( "0b" ) ) {
+            return Long.parseLong( value.substring( 2 ), 2 );
+        } else {
+            return Long.parseLong( value );
+        }
+    }
+
+    /**
+     * Retrieve the <code>long</code> value of the specified parameter.
+     * <p />
+     * If the specified parameter cannot be found, an exception is thrown.
+     *
+     * Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary
+     * numbers begin with 0b, all other values are assumed to be decimal.
+     *
+     * @param name the name of parameter
+     * @return the long parameter type
+     * @throws ParameterException  if the specified parameter cannot be found
+     *         or is not a Long value.
+     */
+    public long getParameterAsLong( final String name )
+    throws ProcessingException {
+        try {
+            return parseLong( getParameter( name ) );
+        } catch( final NumberFormatException e ) {
+            throw new ProcessingException( "Could not return a long value", e );
+        }
+    }
+
+    /**
+     * Retrieve the <code>long</code> value of the specified parameter.
+     * <p />
+     * If the specified parameter cannot be found, <code>defaultValue</code>
+     * is returned.
+     *
+     * Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary
+     * numbers begin with 0b, all other values are assumed to be decimal.
+     *
+     * @param name the name of parameter
+     * @param defaultValue value returned if parameter does not exist or is of wrong type
+     * @return the long parameter type
+     */
+    public long getParameterAsLong( final String name, final long defaultValue ) {
+        try {
+            final String value = getParameter( name, null );
+            if( value == null ) {
+                return defaultValue;
+            }
+
+            return parseLong( value );
+        } catch( final NumberFormatException e ) {
+            return defaultValue;
+        }
+    }
+
+    /**
+     * Retrieve the <code>float</code> value of the specified parameter.
+     * <p />
+     * If the specified parameter cannot be found,  an exception is thrown.
+     *
+     * @param name the parameter name
+     * @return the value
+     * @throws ParameterException if the specified parameter cannot be found
+     *         or is not a Float value
+     */
+    public float getParameterAsFloat( final String name )
+    throws ProcessingException {
+        try {
+            return Float.parseFloat( getParameter( name ) );
+        } catch( final NumberFormatException e ) {
+            throw new ProcessingException( "Could not return a float value", e );
+        }
+    }
+
+    /**
+     * Retrieve the <code>float</code> value of the specified parameter.
+     * <p />
+     * If the specified parameter cannot be found, <code>defaultValue</code>
+     * is returned.
+     *
+     * @param name the parameter name
+     * @param defaultValue the default value if parameter does not exist or is of wrong type
+     * @return the value
+     */
+    public float getParameterAsFloat( final String name, final float defaultValue ) {
+        try {
+            final String value = getParameter( name, null );
+            if( value == null ) {
+                return defaultValue;
+            }
+
+            return Float.parseFloat( value );
+        } catch( final NumberFormatException pe ) {
+            return defaultValue;
+        }
+    }
+
+    /**
+     * Retrieve the <code>boolean</code> value of the specified parameter.
+     * <p />
+     * If the specified parameter cannot be found, an exception is thrown.
+     *
+     * @param name the parameter name
+     * @return the value
+     * @throws ParameterException if an error occurs
+     * @throws ParameterException
+     */
+    public boolean getParameterAsBoolean( final String name )
+    throws ProcessingException {
+        final String value = getParameter( name );
+
+        if( value.equalsIgnoreCase( "true" ) ) {
+            return true;
+        } else if( value.equalsIgnoreCase( "false" ) ) {
+            return false;
+        } else {
+            throw new ProcessingException( "Could not return a boolean value" );
+        }
+    }
+
+    /**
+     * Retrieve the <code>boolean</code> value of the specified parameter.
+     * <p />
+     * If the specified parameter cannot be found, <code>defaultValue</code>
+     * is returned.
+     *
+     * @param name the parameter name
+     * @param defaultValue the default value if parameter does not exist or is of wrong type
+     * @return the value
+     */
+    public boolean getParameterAsBoolean( final String name, final boolean defaultValue ) {
+        final String value = getParameter( name, null );
+        if( value == null ) {
+            return defaultValue;
+        }
+
+        if( value.equalsIgnoreCase( "true" ) ) {
+            return true;
+        } else if( value.equalsIgnoreCase( "false" ) ) {
+            return false;
+        } else {
+            return defaultValue;
+        }
+    }
+
+    /**
+     * Merge parameters from another <code>Parameters</code> instance
+     * into this.
+     *
+     * @param other the other Parameters
+     * @return This <code>Parameters</code> instance.
+     */
+    public PipelineComponentParameters merge( final PipelineComponentParameters other ) {
+        checkWriteable();
+
+        final Collection names = other.getNames();
+        final Iterator i = names.iterator();
+        while ( i.hasNext() ) {
+            final String name = (String)i.next();
+            String value = null;
+            try {
+                value = other.getParameter( name );
+            } catch( final ProcessingException pe ) {
+                value = null;
+            }
+
+            setParameter( name, value );
+        }
+
+        return this;
+    }
+
+    /**
+     * Make this Parameters read-only so that it will throw a
+     * <code>IllegalStateException</code> if someone tries to
+     * modify it.
+     */
+    public void makeReadOnly() {
+        readOnly = true;
+    }
+
+   /**
+    * Compare this parameters instance with the supplied object for equality.
+    *
+    * The equality is mainly driven by the underlying HashMap which forms the
+    * basis of the class. I.e. if the underlying HashMaps are equal and the
+    * Readonly attributes are equal in the Parameters instances being compared,
+    * then this method returns equality.
+    *
+    * @param other the object to compare this parameters instance with
+    *
+    * @return true if this parameters instance is equal to the supplied object
+    */
+    public boolean equals( Object other ) {
+        if( null == other ) 
+            return false;
+          
+        if( !( other instanceof PipelineComponentParameters ) )
+            return false;
+            
+        PipelineComponentParameters p = (PipelineComponentParameters) other;
+        if( readOnly != p.readOnly )
+            return false;
+        return parameters.equals( p.parameters );
+    }
+
+   /**
+    * Returns a hashed value of the Parameters instance. 
+    * 
+    * This method returns a semi-unique value for all instances, yet an
+    * identical value for instances where equals() returns true.
+    *
+    * @since 4.3
+    *
+    * @return a hashed value of the instance
+    */
+    public int hashCode() {
+        int hash = parameters.hashCode();
+        hash >>>= ( readOnly ) ? 7 : 13;
+        return hash;
+    }
+    
+    public String toString() {
+        return "Parameters[" + ( readOnly ? "r/o]" : "r/w]:" ) + parameters;
+    }
+
+    /**
+     * Checks is this <code>Parameters</code> object is writeable.
+     *
+     * @throws IllegalStateException if this <code>Parameters</code> object is read-only
+     */
+    protected final void checkWriteable()
+    throws IllegalStateException {
+        if( readOnly ) {
+            throw new IllegalStateException( "Configuration is read only and can not be modified" );
+        }
+    }
+}

Propchange: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/PipelineComponentParameters.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/PipelineComponentParameters.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Producer.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Producer.java?rev=421827&r1=421826&r2=421827&view=diff
==============================================================================
--- cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Producer.java (original)
+++ cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Producer.java Fri Jul 14 00:50:33 2006
@@ -19,25 +19,25 @@
 
 /**
  * This interfaces identifies classes that produce XML data, sending SAX
- * events to the configured <code>XMLConsumer</code>.
+ * events to the configured <code>ContentHandler</code>.
  * <p>
- * The XMLProducer is comprised of only one method to give the component the
- * next element of the pipeline.  Cocoon calls the <code>setConsumer()</code>
- * method with the reference to the next XMLConsumer in the pipeline.  The
- * approach allows the XMLProducer to call the different SAX related methods on
- * the XMLConsumer without knowing ahead of time what that consumer will be.
+ * The Producer is comprised of only one method to give the component the
+ * next element of the pipeline. Cocoon calls the <code>setContentHandler()</code>
+ * method with the reference to the next ContentHandler in the pipeline.  The
+ * approach allows the Producer to call the different SAX related methods on
+ * the ContentHandler without knowing ahead of time what that consumer will be.
  * The design is very simple and very powerful in that it allows Cocoon to
  * daisy chain several components in any order and then execute the pipeline.
  * </p>
  * <p>
  * Any producer can be paired with any consumer and we have a pipeline.  The
  * core design is very powerful and allows the end user to mix and match
- * sitemap components as they see fit.  Cocoon will always call
- * <code>setConsumer()</code> on every XMLProducer in a pipeline or it will
+ * pipeline components as they see fit.  Cocoon will always call
+ * <code>setContentHandler()</code> on every Producer in a pipeline or it will
  * throw an exception saying that the pipeline is invalid (i.e. there is no
- * serializer for the pipeline).  The only contract that the XMLProducer has to
- * worry about is that it must always make calls to the XMLConsumer passed in
- * through the <code>setConsumer()</code> method.
+ * serializer for the pipeline).  The only contract that the Producer has to
+ * worry about is that it must always make calls to the ContentHandler passed in
+ * through the <code>setContentHandler()</code> method.
  * </p>
  *
  * @version $Id$
@@ -46,9 +46,12 @@
 public interface Producer {
 
     /**
-     * Set the {@link Consumer} that will receive XML data.
+     * Set the {@link ContentHandler} that will receive XML data.
+     * The content handler might also implement the {@link LexicalHandler}
+     * interface. The producer must check this and in send lexical events
+     * as well.
      *
-     * @param consumer  The Consumer target for SAX events.
+     * @param handler  The Consumer target for SAX events.
      */
     void setContentHandler(ContentHandler handler);
 }

Added: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Serializer.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Serializer.java?rev=421827&view=auto
==============================================================================
--- cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Serializer.java (added)
+++ cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Serializer.java Fri Jul 14 00:50:33 2006
@@ -0,0 +1,33 @@
+/*
+ * 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.processing.pipeline;
+
+import org.xml.sax.ContentHandler;
+
+/**
+ * A serializer is the last point of a pipeline. It "serializes" XML
+ * arriving as SAX events into any binary format. <br> Serializers extend
+ * the {@link PipelineComponent} 
+ * interface to gain access to the <code>request</code> and <code>response</code>
+ * object and to get an optional configuration.
+ *
+ * @version $Id$
+ * @since 2.2
+ */
+public interface Serializer extends ContentHandler, PipelineComponent {
+
+    // just a marker interface
+}

Propchange: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Serializer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Serializer.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Transformer.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Transformer.java?rev=421827&view=auto
==============================================================================
--- cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Transformer.java (added)
+++ cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Transformer.java Fri Jul 14 00:50:33 2006
@@ -0,0 +1,31 @@
+/*
+ * 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.processing.pipeline;
+
+import org.xml.sax.ContentHandler;
+
+/**
+ * A transformer is the zero to several intermediate points in a pipeline.
+ * It "transforms" incoming XML arriving as SAX events from the pipeline
+ * and sends modified XML as SAX events down the pipeline.
+ *
+ * @version $Id$
+ * @since 2.2
+ */
+public interface Transformer extends Producer, ContentHandler, PipelineComponent {
+
+    // just a marker interface
+}

Propchange: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Transformer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/pipeline/Transformer.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/sitemap/impl/SitemapProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/sitemap/impl/SitemapProcessor.java?rev=421827&r1=421826&r2=421827&view=diff
==============================================================================
--- cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/sitemap/impl/SitemapProcessor.java (original)
+++ cocoon/whiteboard/processor/src/main/java/org/apache/cocoon/processing/sitemap/impl/SitemapProcessor.java Fri Jul 14 00:50:33 2006
@@ -15,7 +15,10 @@
  */
 package org.apache.cocoon.processing.sitemap.impl;
 
+import java.io.IOException;
+
 import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -25,6 +28,7 @@
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.ProcessingUtil;
 import org.apache.cocoon.components.treeprocessor.TreeProcessor;
+import org.apache.cocoon.processing.ProcessingException;
 import org.apache.cocoon.processing.Processor;
 import org.apache.cocoon.servlet.RequestProcessor;
 import org.apache.excalibur.source.Source;
@@ -34,6 +38,7 @@
 import org.springframework.beans.factory.BeanFactoryAware;
 import org.springframework.beans.factory.DisposableBean;
 import org.springframework.web.context.ServletContextAware;
+import org.xml.sax.SAXException;
 
 /**
  *
@@ -88,7 +93,8 @@
     /**
      *
      */
-    protected void createSitemapProcessor() throws Exception {
+    protected void createSitemapProcessor()
+    throws ProcessingException, IOException {
         if ( this.treeProcessor == null ) {
             synchronized ( this ) {
                 if ( this.treeProcessor == null ) {
@@ -114,6 +120,8 @@
                         this.requestProcessor.setProcessor(tp);
 
                         this.treeProcessor = tp;
+                    } catch (Exception e) {
+                        throw new ProcessingException(e);
                     } finally {
                         this.resolver.release(source);
                     }                    
@@ -151,9 +159,14 @@
     /**
      * @see org.apache.cocoon.processing.Processor#process(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
      */
-    public boolean process(HttpServletRequest request, HttpServletResponse response) throws Exception {
+    public boolean process(HttpServletRequest request, HttpServletResponse response)
+    throws ProcessingException, IOException, SAXException {
         this.createSitemapProcessor();
-        this.requestProcessor.service(request, response);
+        try {
+             this.requestProcessor.service(request, response);
+        } catch (ServletException se) {
+            throw new ProcessingException(se);
+        }
         return true;
     }
 }