Permalink
Browse files

Initial impport of Butterfly

git-svn-id: https://svn.apache.org/repos/asf/cocoon/branches/src@30863 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
0 parents commit 8e26b70fba14b7f8cc7573ecbd40177aee4fd193 Ugo Cei committed Jul 28, 2004
Showing with 5,374 additions and 0 deletions.
  1. +55 −0 java/org/apache/butterfly/components/pipeline/InvalidPipelineException.java
  2. +55 −0 java/org/apache/butterfly/components/pipeline/PipelineException.java
  3. +55 −0 java/org/apache/butterfly/components/pipeline/PipelineProcessingException.java
  4. +132 −0 java/org/apache/butterfly/components/pipeline/ProcessingPipeline.java
  5. +265 −0 java/org/apache/butterfly/components/pipeline/impl/NonCachingProcessingPipeline.java
  6. +191 −0 java/org/apache/butterfly/environment/Environment.java
  7. +64 −0 java/org/apache/butterfly/generation/FileGenerator.java
  8. +29 −0 java/org/apache/butterfly/generation/Generator.java
  9. +41 −0 java/org/apache/butterfly/reading/Reader.java
  10. +29 −0 java/org/apache/butterfly/serialization/Serializer.java
  11. +125 −0 java/org/apache/butterfly/serialization/XMLSerializer.java
  12. +43 −0 java/org/apache/butterfly/sitemap/SitemapOutputComponent.java
  13. +143 −0 java/org/apache/butterfly/source/Source.java
  14. +42 −0 java/org/apache/butterfly/source/SourceException.java
  15. +53 −0 java/org/apache/butterfly/source/SourceFactory.java
  16. +42 −0 java/org/apache/butterfly/source/SourceNotFoundException.java
  17. +120 −0 java/org/apache/butterfly/source/SourceResolver.java
  18. +473 −0 java/org/apache/butterfly/source/SourceUtil.java
  19. +75 −0 java/org/apache/butterfly/source/SourceValidity.java
  20. +33 −0 java/org/apache/butterfly/source/URIAbsolutizer.java
  21. +176 −0 java/org/apache/butterfly/source/impl/FileSource.java
  22. +50 −0 java/org/apache/butterfly/source/impl/FileSourceFactory.java
  23. +109 −0 java/org/apache/butterfly/source/impl/URLSource.java
  24. +39 −0 java/org/apache/butterfly/source/impl/URLSourceFactory.java
  25. +87 −0 java/org/apache/butterfly/source/impl/validity/FileTimeStampValidity.java
  26. +28 −0 java/org/apache/butterfly/transformation/Transformer.java
  27. +68 −0 java/org/apache/butterfly/transformation/TraxTransformer.java
  28. +230 −0 java/org/apache/butterfly/xml/AbstractXMLPipe.java
  29. +81 −0 java/org/apache/butterfly/xml/AbstractXMLProducer.java
  30. +58 −0 java/org/apache/butterfly/xml/EmbeddedXMLPipe.java
  31. +214 −0 java/org/apache/butterfly/xml/Parser.java
  32. +136 −0 java/org/apache/butterfly/xml/WhitespaceFilter.java
  33. +33 −0 java/org/apache/butterfly/xml/XMLConsumer.java
  34. +60 −0 java/org/apache/butterfly/xml/XMLException.java
  35. +26 −0 java/org/apache/butterfly/xml/XMLPipe.java
  36. +39 −0 java/org/apache/butterfly/xml/XMLProducer.java
  37. +141 −0 java/org/apache/butterfly/xml/dom/DOMBuilder.java
  38. +720 −0 java/org/apache/butterfly/xml/dom/DOMStreamer.java
  39. +60 −0 java/org/apache/butterfly/xml/xslt/TraxException.java
  40. +79 −0 java/org/apache/butterfly/xml/xslt/TraxTransformerFactory.java
  41. +77 −0 test/beans.xml
  42. +15 −0 test/log4j.properties
  43. +62 −0 test/org/apache/butterfly/components/pipeline/impl/GroovySitemapTestCase.java
  44. +13 −0 test/org/apache/butterfly/components/pipeline/impl/MyPipeline.groovy
  45. +398 −0 test/org/apache/butterfly/components/pipeline/impl/NonCachingProcessingPipelineTestCase.java
  46. +34 −0 test/org/apache/butterfly/components/pipeline/impl/Pipeline.groovy
  47. +56 −0 test/org/apache/butterfly/generation/FileGeneratorTestCase.java
  48. +58 −0 test/org/apache/butterfly/serialization/XMLSerializerTestCase.java
  49. +49 −0 test/org/apache/butterfly/source/SourceResolverTestCase.java
  50. +52 −0 test/org/apache/butterfly/test/SitemapComponentTestCase.java
  51. +61 −0 test/org/apache/butterfly/transformation/TraxTransformerTestCase.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2004, Ugo Cei.
+ *
+ * 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.butterfly.components.pipeline;
+
+
+/**
+ * This exception is thrown whenever you try to assemble an invalid pipeline.
+ *
+ * @version CVS $Id: InvalidPipelineException.java,v 1.1 2004/07/24 20:21:33 ugo Exp $
+ */
+public class InvalidPipelineException extends PipelineException {
+
+ /**
+ *
+ */
+ public InvalidPipelineException() {
+ super();
+ }
+
+ /**
+ * @param arg0
+ */
+ public InvalidPipelineException(String arg0) {
+ super(arg0);
+ }
+
+ /**
+ * @param arg0
+ * @param arg1
+ */
+ public InvalidPipelineException(String arg0, Throwable arg1) {
+ super(arg0, arg1);
+ }
+
+ /**
+ * @param arg0
+ */
+ public InvalidPipelineException(Throwable arg0) {
+ super(arg0);
+ }
+
+}
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2004, Ugo Cei.
+ *
+ * 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.butterfly.components.pipeline;
+
+
+/**
+ * Base class for all exceptions thrown during pipeline processing.
+ *
+ * @version CVS $Id: PipelineException.java,v 1.1 2004/07/24 20:21:33 ugo Exp $
+ */
+public abstract class PipelineException extends RuntimeException {
+
+ /**
+ *
+ */
+ public PipelineException() {
+ super();
+ }
+
+ /**
+ * @param arg0
+ */
+ public PipelineException(String arg0) {
+ super(arg0);
+ }
+
+ /**
+ * @param arg0
+ * @param arg1
+ */
+ public PipelineException(String arg0, Throwable arg1) {
+ super(arg0, arg1);
+ }
+
+ /**
+ * @param arg0
+ */
+ public PipelineException(Throwable arg0) {
+ super(arg0);
+ }
+
+}
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2004, Ugo Cei.
+ *
+ * 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.butterfly.components.pipeline;
+
+
+/**
+ * This exception can be thrown when executing a pipeline.
+ *
+ * @version CVS $Id: PipelineProcessingException.java,v 1.1 2004/07/25 21:55:20 ugo Exp $
+ */
+public class PipelineProcessingException extends PipelineException {
+
+ /**
+ *
+ */
+ public PipelineProcessingException() {
+ super();
+ }
+
+ /**
+ * @param arg0
+ */
+ public PipelineProcessingException(String arg0) {
+ super(arg0);
+ }
+
+ /**
+ * @param arg0
+ * @param arg1
+ */
+ public PipelineProcessingException(String arg0, Throwable arg1) {
+ super(arg0, arg1);
+ }
+
+ /**
+ * @param arg0
+ */
+ public PipelineProcessingException(Throwable arg0) {
+ super(arg0);
+ }
+
+}
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2004, Ugo Cei.
+ *
+ * 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.butterfly.components.pipeline;
+
+import org.apache.butterfly.environment.Environment;
+import org.apache.butterfly.generation.Generator;
+import org.apache.butterfly.reading.Reader;
+import org.apache.butterfly.serialization.Serializer;
+import org.apache.butterfly.source.SourceValidity;
+import org.apache.butterfly.transformation.Transformer;
+import org.apache.butterfly.xml.XMLConsumer;
+
+
+/**
+ * A <code>ProcessingPipeline<code> produces the response for a given request.
+ * It is assembled according to the commands in the sitemap and can either
+ * <ul>
+ * <li>collect a <code>Reader</code> and let it produce a character stream</li>
+ * <li>or connect a <code>Generator</code> with zero or more
+ * <code>Transformer</code>s and a <code>Serializer</code> and let them
+ * produce the byte stream. This pipeline uses SAX events for
+ * communication.
+ * </li>
+ * </ul>
+ *
+ * @version CVS $Id: ProcessingPipeline.java,v 1.2 2004/07/24 20:21:33 ugo Exp $
+ */
+public interface ProcessingPipeline {
+
+ /**
+ * Setup this component
+ */
+ // void setup(Parameters params);
+
+ /**
+ * Set the generator that will be used as the initial step in the pipeline.
+ * The generator role is given : the actual <code>Generator</code> is fetched
+ * from the latest <code>ComponentManager</code> given by <code>compose()</code>
+ * or <code>recompose()</code>.
+ *
+ * @param role the generator role in the component manager.
+ * @param source the source where to produce XML from, or <code>null</code> if no
+ * source is given.
+ * @param param the parameters for the generator.
+ * @throws ProcessingException if the generator couldn't be obtained.
+ */
+ void setGenerator(Generator generator);
+
+ /**
+ * Get the generator - used for content aggregation
+ */
+ Generator getGenerator();
+
+ /**
+ * Informs pipeline we have come across a branch point
+ */
+ void informBranchPoint();
+
+ /**
+ * Add a transformer at the end of the pipeline.
+ * The transformer role is given : the actual <code>Transformer</code> is fetched
+ * from the latest <code>ComponentManager</code> given by <code>compose()</code>
+ * or <code>recompose()</code>.
+ *
+ * @param role the transformer role in the component manager.
+ * @param source the source used to setup the transformer (e.g. XSL file), or
+ * <code>null</code> if no source is given.
+ * @param param the parameters for the transfomer.
+ * @throws ProcessingException if the generator couldn't be obtained.
+ */
+ void addTransformer(Transformer transformer);
+
+ /**
+ * Set the serializer for this pipeline
+ * @param mimeType Can be null
+ */
+ void setSerializer(Serializer serializer);
+
+ /**
+ * Set the reader for this pipeline
+ * @param mimeType Can be null
+ */
+ void setReader(Reader reader);
+
+ /**
+ * Process the given <code>Environment</code>, producing the output.
+ */
+ boolean process(Environment environment);
+
+ /**
+ * Prepare an internal processing
+ * @param environment The current environment.
+ * @throws ProcessingException
+ */
+ void prepareInternal(Environment environment);
+
+ /**
+ * Process the given <code>Environment</code>, but do not use the
+ * serializer. Instead the sax events are streamed to the XMLConsumer.
+ * Make sure to call {@link #prepareInternal(Environment)} beforehand.
+ */
+ boolean process(Environment environment, XMLConsumer consumer);
+
+ /**
+ * Return valid validity objects for the event pipeline
+ * If the "event pipeline" (= the complete pipeline without the
+ * serializer) is cacheable and valid, return all validity objects.
+ * Otherwise return <code>null</code>
+ */
+ SourceValidity getValidityForEventPipeline();
+
+ /**
+ * Return the key for the event pipeline
+ * If the "event pipeline" (= the complete pipeline without the
+ * serializer) is cacheable and valid, return a key.
+ * Otherwise return <code>null</code>
+ */
+ String getKeyForEventPipeline();
+}
Oops, something went wrong.

0 comments on commit 8e26b70

Please sign in to comment.