cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1195941 - in /cocoon/cocoon3/trunk/cocoon-cli/src/main/java/org/apache/cocoon/cli: PipelineDescriptorModule.java PipelineDescriptorParser.java
Date Tue, 01 Nov 2011 11:57:57 GMT
Author: simonetripodi
Date: Tue Nov  1 11:57:56 2011
New Revision: 1195941

URL: http://svn.apache.org/viewvc?rev=1195941&view=rev
Log:
first checkin of PipelineDescriptorParser class - it is a wrapper of Digester
dropped the module class, embedded in the parser class

Added:
    cocoon/cocoon3/trunk/cocoon-cli/src/main/java/org/apache/cocoon/cli/PipelineDescriptorParser.java
  (with props)
Removed:
    cocoon/cocoon3/trunk/cocoon-cli/src/main/java/org/apache/cocoon/cli/PipelineDescriptorModule.java

Added: cocoon/cocoon3/trunk/cocoon-cli/src/main/java/org/apache/cocoon/cli/PipelineDescriptorParser.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-cli/src/main/java/org/apache/cocoon/cli/PipelineDescriptorParser.java?rev=1195941&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-cli/src/main/java/org/apache/cocoon/cli/PipelineDescriptorParser.java
(added)
+++ cocoon/cocoon3/trunk/cocoon-cli/src/main/java/org/apache/cocoon/cli/PipelineDescriptorParser.java
Tue Nov  1 11:57:56 2011
@@ -0,0 +1,84 @@
+/*
+ * 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.cli;
+
+import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
+import static javax.xml.validation.SchemaFactory.newInstance;
+import static org.apache.commons.digester3.binder.DigesterLoader.newLoader;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.xml.validation.Schema;
+
+import org.apache.cocoon.cli.CreateXMLGeneratorRule.CreateXMLGeneratorRuleProvider;
+import org.apache.cocoon.cli.PipelineCreateRule.PipelineCreateRuleProvider;
+import org.apache.cocoon.sax.component.XMLSerializer;
+import org.apache.commons.digester3.binder.AbstractRulesModule;
+import org.apache.commons.digester3.binder.DigesterLoader;
+import org.xml.sax.SAXException;
+
+final class PipelineDescriptorParser
+{
+
+    private final DigesterLoader digesterLoader;
+
+    public PipelineDescriptorParser()
+    {
+        Schema schema;
+        try
+        {
+            schema = newInstance( W3C_XML_SCHEMA_NS_URI ).newSchema( getClass().getResource(
"cocoon-cli-1.0.xsd" ) );
+        }
+        catch ( SAXException e )
+        {
+            // ignored, should not happen
+            schema = null;
+        }
+
+        digesterLoader = newLoader( new AbstractRulesModule()
+        {
+
+            @Override
+            protected void configure()
+            {
+                forPattern( "pipelines" )
+                    .createObject().ofType( PipelinesRegistry.class )
+                    .then()
+                    .setProperties()
+                        .addAlias( "default", "defaultId" );
+                forPattern( "pipelines/pipeline" ).addRuleCreatedBy( new PipelineCreateRuleProvider()
);
+                forPattern( "pipelines/pipeline/generator" ).addRuleCreatedBy( new CreateXMLGeneratorRuleProvider()
);
+                forPattern( "pipelines/pipeline/serializer" )
+                    .createObject().ofType( XMLSerializer.class )
+                    .then()
+                    .setProperties();
+            }
+
+        }).setSchema( schema );
+    }
+
+    public PipelinesRegistry parse( File pipelineDescriptorFile )
+        throws IOException, SAXException
+    {
+        PipelinesRegistry registry = digesterLoader.newDigester().parse( pipelineDescriptorFile
);
+        return registry;
+    }
+
+}

Propchange: cocoon/cocoon3/trunk/cocoon-cli/src/main/java/org/apache/cocoon/cli/PipelineDescriptorParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Propchange: cocoon/cocoon3/trunk/cocoon-cli/src/main/java/org/apache/cocoon/cli/PipelineDescriptorParser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message