You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by si...@apache.org on 2010/12/07 21:32:06 UTC

svn commit: r1043189 - /cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/

Author: simonetripodi
Date: Tue Dec  7 20:32:06 2010
New Revision: 1043189

URL: http://svn.apache.org/viewvc?rev=1043189&view=rev
Log:
first checkin of Pipeline DSL to easily setup and run pipelines

Added:
    cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/
    cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineBuilder.java   (with props)
    cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineComponentBuilder.java   (with props)
    cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineConfigurationBuilder.java   (with props)
    cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineSetupBuilder.java   (with props)
    cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineStarterBuilder.java   (with props)
    cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/PipelineBuilder.java   (with props)

Added: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineBuilder.java?rev=1043189&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineBuilder.java (added)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineBuilder.java Tue Dec  7 20:32:06 2010
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.pipeline.builder;
+
+import org.apache.cocoon.pipeline.component.PipelineComponent;
+
+/**
+ * Simple DSL to easily manipulate pipelines.
+ *
+ * @param <PC> the {@link PipelineComponent} type.
+ * @version $Id$
+ */
+public interface LinkedPipelineBuilder<PC extends PipelineComponent> {
+
+    LinkedPipelineStarterBuilder<PC> newAsyncCachePipeline();
+
+    LinkedPipelineStarterBuilder<PC> newCachingPipeline();
+
+    LinkedPipelineStarterBuilder<PC> newNonCachingPipeline();
+
+}

Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineComponentBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineComponentBuilder.java?rev=1043189&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineComponentBuilder.java (added)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineComponentBuilder.java Tue Dec  7 20:32:06 2010
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.pipeline.builder;
+
+import org.apache.cocoon.pipeline.component.PipelineComponent;
+
+/**
+ * 
+ *
+ * @param <PC> the {@link PipelineComponent} type.
+ * @version $Id$
+ */
+public interface LinkedPipelineComponentBuilder<PC extends PipelineComponent> {
+
+    LinkedPipelineComponentBuilder<PC> addComponent(PC pipelineComponent);
+
+    LinkedPipelineConfigurationBuilder<PC> setFinisher(PC finisher);
+
+}

Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineComponentBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineComponentBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineComponentBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineConfigurationBuilder.java?rev=1043189&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineConfigurationBuilder.java (added)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineConfigurationBuilder.java Tue Dec  7 20:32:06 2010
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.pipeline.builder;
+
+import java.util.Map;
+
+import org.apache.cocoon.pipeline.component.PipelineComponent;
+
+/**
+ * 
+ *
+ * @param <PC> the {@link PipelineComponent} type.
+ * @version $Id$
+ */
+public interface LinkedPipelineConfigurationBuilder<PC extends PipelineComponent> {
+
+    LinkedPipelineSetupBuilder<PC> withEmptyConfiguration();
+
+    LinkedPipelineSetupBuilder<PC> setConfiguration(Map<String, ? extends Object> parameters);
+
+}

Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineConfigurationBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineConfigurationBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineConfigurationBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineSetupBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineSetupBuilder.java?rev=1043189&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineSetupBuilder.java (added)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineSetupBuilder.java Tue Dec  7 20:32:06 2010
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.pipeline.builder;
+
+import java.io.OutputStream;
+
+import org.apache.cocoon.pipeline.Pipeline;
+import org.apache.cocoon.pipeline.component.PipelineComponent;
+
+/**
+ * 
+ *
+ * @param <PC> the {@link PipelineComponent} type.
+ * @version $Id$
+ */
+public interface LinkedPipelineSetupBuilder<PC extends PipelineComponent> {
+
+    Pipeline<PC> setup(OutputStream outputStream);
+
+}

Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineSetupBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineSetupBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineSetupBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineStarterBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineStarterBuilder.java?rev=1043189&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineStarterBuilder.java (added)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineStarterBuilder.java Tue Dec  7 20:32:06 2010
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.pipeline.builder;
+
+import org.apache.cocoon.pipeline.component.PipelineComponent;
+
+/**
+ * 
+ *
+ * @param <PC> the {@link PipelineComponent} type.
+ * @version $Id$
+ */
+public interface LinkedPipelineStarterBuilder<PC extends PipelineComponent> {
+
+    LinkedPipelineComponentBuilder<PC> setStarter(PC starter);
+
+}

Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineStarterBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineStarterBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/LinkedPipelineStarterBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/PipelineBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/PipelineBuilder.java?rev=1043189&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/PipelineBuilder.java (added)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/PipelineBuilder.java Tue Dec  7 20:32:06 2010
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.pipeline.builder;
+
+import java.io.OutputStream;
+import java.util.Collections;
+import java.util.Map;
+
+import org.apache.cocoon.pipeline.AsyncCachePipeline;
+import org.apache.cocoon.pipeline.CachingPipeline;
+import org.apache.cocoon.pipeline.NonCachingPipeline;
+import org.apache.cocoon.pipeline.Pipeline;
+import org.apache.cocoon.pipeline.component.Finisher;
+import org.apache.cocoon.pipeline.component.PipelineComponent;
+import org.apache.cocoon.pipeline.component.Starter;
+
+/**
+ * 
+ *
+ * @param <PC> the {@link PipelineComponent} type.
+ * @version $Id$
+ */
+public final class PipelineBuilder<PC extends PipelineComponent> implements LinkedPipelineBuilder<PC> {
+
+    /**
+     * {@inheritDoc}
+     */
+    public LinkedPipelineStarterBuilder<PC> newAsyncCachePipeline() {
+        return this.newPipeline(new AsyncCachePipeline<PC>());
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public LinkedPipelineStarterBuilder<PC> newCachingPipeline() {
+        return this.newPipeline(new CachingPipeline<PC>());
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public LinkedPipelineStarterBuilder<PC> newNonCachingPipeline() {
+        return this.newPipeline(new NonCachingPipeline<PC>());
+    }
+
+    private LinkedPipelineStarterBuilder<PC> newPipeline(final Pipeline<PC> pipeline) {
+        return new LinkedPipelineStarterBuilder<PC>() {
+
+            public LinkedPipelineComponentBuilder<PC> setStarter(final PC starter) {
+                if (starter == null) {
+                    throw new IllegalArgumentException("Parameter 'starter' must be not null");
+                }
+                if (!(starter instanceof Starter)) {
+                    throw new IllegalArgumentException("Parameter 'starter' must be org.apache.cocoon.pipeline.component.Starter instance");
+                }
+                pipeline.addComponent(starter);
+
+                return new LinkedPipelineComponentBuilder<PC>() {
+
+                    public LinkedPipelineComponentBuilder<PC> addComponent(final PC pipelineComponent) {
+                        if (pipelineComponent == null) {
+                            throw new IllegalArgumentException("Parameter 'pipelineComponent' must be not null");
+                        }
+                        pipeline.addComponent(pipelineComponent);
+                        return this;
+                    }
+
+                    public LinkedPipelineConfigurationBuilder<PC> setFinisher(final PC finisher) {
+                        if (finisher == null) {
+                            throw new IllegalArgumentException("Parameter 'finisher' must be not null");
+                        }
+                        if (!(finisher instanceof Finisher)) {
+                            throw new IllegalArgumentException("Parameter 'finisher' must be org.apache.cocoon.pipeline.component.Finisher instance");
+                        }
+                        pipeline.addComponent(finisher);
+
+                        return new LinkedPipelineConfigurationBuilder<PC>() {
+
+                            @SuppressWarnings("unchecked")
+                            public LinkedPipelineSetupBuilder<PC> withEmptyConfiguration() {
+                                return this.setConfiguration(Collections.EMPTY_MAP);
+                            }
+
+                            public LinkedPipelineSetupBuilder<PC> setConfiguration(final Map<String, ? extends Object> parameters) {
+                                if (parameters == null) {
+                                    throw new IllegalArgumentException("Parameter 'parameters' must be not null");
+                                }
+                                pipeline.setConfiguration(parameters);
+
+                                return new LinkedPipelineSetupBuilder<PC>() {
+
+                                    public Pipeline<PC> setup(final OutputStream outputStream) {
+                                        if (outputStream == null) {
+                                            throw new IllegalArgumentException("Parameter 'outputStream' must be not null");
+                                        }
+                                        pipeline.setup(outputStream);
+                                        return pipeline;
+                                    }
+
+                                };
+                            }
+
+                        };
+                    }
+
+                };
+            }
+
+        };
+    }
+
+}

Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/PipelineBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/PipelineBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/builder/PipelineBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain