You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/04/06 00:42:23 UTC

svn commit: r525992 - in /incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl: ComponentTypeDocumentProcessor.java CompositeDocumentProcessor.java ConstrainingTypeDocumentProcessor.java

Author: jsdelfino
Date: Thu Apr  5 15:42:22 2007
New Revision: 525992

URL: http://svn.apache.org/viewvc?view=rev&rev=525992
Log:
Added URLArtifactProcessors for .composite, .componentType, .constrainingType documents.

Added:
    incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ComponentTypeDocumentProcessor.java   (with props)
    incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/CompositeDocumentProcessor.java   (with props)
    incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ConstrainingTypeDocumentProcessor.java   (with props)

Added: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ComponentTypeDocumentProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ComponentTypeDocumentProcessor.java?view=auto&rev=525992
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ComponentTypeDocumentProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ComponentTypeDocumentProcessor.java Thu Apr  5 15:42:22 2007
@@ -0,0 +1,97 @@
+/*
+ * 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.tuscany.assembly.xml.impl;
+
+import java.io.IOException;
+import java.net.URL;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.assembly.AssemblyFactory;
+import org.apache.tuscany.assembly.ComponentType;
+import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.policy.PolicyFactory;
+import org.apache.tuscany.policy.impl.DefaultPolicyFactory;
+import org.apache.tuscany.services.spi.contribution.ArtifactResolver;
+import org.apache.tuscany.services.spi.contribution.ContributionException;
+import org.apache.tuscany.services.spi.contribution.ContributionReadException;
+import org.apache.tuscany.services.spi.contribution.StAXArtifactProcessorRegistry;
+import org.apache.tuscany.services.spi.contribution.URLArtifactProcessor;
+
+/**
+ * A componentType processor.
+ * 
+ * @version $Rev$ $Date$
+ */
+public class ComponentTypeDocumentProcessor extends BaseArtifactProcessor implements URLArtifactProcessor<ComponentType> {
+    private StAXArtifactProcessorRegistry registry;
+    private XMLInputFactory inputFactory;
+    
+    /**
+     * Constructs a new componentType processor.
+     * @param factory
+     * @param policyFactory
+     * @param registry
+     */
+    public ComponentTypeDocumentProcessor(AssemblyFactory factory, PolicyFactory policyFactory, StAXArtifactProcessorRegistry registry, XMLInputFactory inputFactory) {
+        super(factory, policyFactory);
+        this.registry = registry;
+        this.inputFactory = inputFactory;
+    }
+    
+    /**
+     * Constructs a new componentType processor.
+     * @param registry
+     */
+    public ComponentTypeDocumentProcessor(StAXArtifactProcessorRegistry registry) {
+        this(new DefaultAssemblyFactory(), new DefaultPolicyFactory(), registry, XMLInputFactory.newInstance());
+    }
+    
+    public ComponentType read(URL url) throws ContributionReadException {
+        try {
+            XMLStreamReader reader = inputFactory.createXMLStreamReader(url.openStream());
+            ComponentType componentType = (ComponentType)registry.read(reader);
+            return componentType;
+            
+        } catch (XMLStreamException e) {
+            throw new ContributionReadException(e);
+        } catch (IOException e) {
+            throw new ContributionReadException(e);
+        }
+    }
+    
+    public void resolve(ComponentType componentType, ArtifactResolver resolver) throws ContributionException {
+        registry.resolve(componentType, resolver);
+    }
+    
+    public void optimize(ComponentType componentType) throws ContributionException {
+        registry.optimize(componentType);
+    }
+    
+    public String getArtifactType() {
+        return ".componentType";
+    }
+    
+    public Class<ComponentType> getModelType() {
+        return ComponentType.class;
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ComponentTypeDocumentProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ComponentTypeDocumentProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/CompositeDocumentProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/CompositeDocumentProcessor.java?view=auto&rev=525992
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/CompositeDocumentProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/CompositeDocumentProcessor.java Thu Apr  5 15:42:22 2007
@@ -0,0 +1,97 @@
+/*
+ * 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.tuscany.assembly.xml.impl;
+
+import java.io.IOException;
+import java.net.URL;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.assembly.AssemblyFactory;
+import org.apache.tuscany.assembly.Composite;
+import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.policy.PolicyFactory;
+import org.apache.tuscany.policy.impl.DefaultPolicyFactory;
+import org.apache.tuscany.services.spi.contribution.ArtifactResolver;
+import org.apache.tuscany.services.spi.contribution.ContributionException;
+import org.apache.tuscany.services.spi.contribution.ContributionReadException;
+import org.apache.tuscany.services.spi.contribution.StAXArtifactProcessorRegistry;
+import org.apache.tuscany.services.spi.contribution.URLArtifactProcessor;
+
+/**
+ * A composite processor.
+ * 
+ * @version $Rev$ $Date$
+ */
+public class CompositeDocumentProcessor extends BaseArtifactProcessor implements URLArtifactProcessor<Composite> {
+    private StAXArtifactProcessorRegistry registry;
+    private XMLInputFactory inputFactory;
+
+    /**
+     * Construct a new composite processor
+     * @param assemblyFactory
+     * @param policyFactory
+     * @param registry
+     */
+    public CompositeDocumentProcessor(AssemblyFactory factory, PolicyFactory policyFactory, StAXArtifactProcessorRegistry registry, XMLInputFactory inputFactory) {
+        super(factory, policyFactory);
+        this.registry = registry;
+        this.inputFactory = inputFactory;
+    }
+
+    /**
+     * Construct a new composite processor.
+     * @param registry
+     */
+    public CompositeDocumentProcessor(StAXArtifactProcessorRegistry registry) {
+        this(new DefaultAssemblyFactory(), new DefaultPolicyFactory(), registry, XMLInputFactory.newInstance());
+    }
+
+    public Composite read(URL url) throws ContributionReadException {
+        try {
+            XMLStreamReader reader = inputFactory.createXMLStreamReader(url.openStream());
+            Composite composite = (Composite)registry.read(reader);
+            return composite;
+            
+        } catch (XMLStreamException e) {
+            throw new ContributionReadException(e);
+        } catch (IOException e) {
+            throw new ContributionReadException(e);
+        }
+    }
+    
+    public void resolve(Composite composite, ArtifactResolver resolver) throws ContributionException {
+        registry.resolve(composite, resolver);
+    }
+
+    public void optimize(Composite composite) throws ContributionException {
+        registry.optimize(composite);
+    }
+
+    public String getArtifactType() {
+        return ".composite";
+    }
+    
+    public Class<Composite> getModelType() {
+        return Composite.class;
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/CompositeDocumentProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/CompositeDocumentProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ConstrainingTypeDocumentProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ConstrainingTypeDocumentProcessor.java?view=auto&rev=525992
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ConstrainingTypeDocumentProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ConstrainingTypeDocumentProcessor.java Thu Apr  5 15:42:22 2007
@@ -0,0 +1,98 @@
+/*
+ * 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.tuscany.assembly.xml.impl;
+
+import java.io.IOException;
+import java.net.URL;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.assembly.AssemblyFactory;
+import org.apache.tuscany.assembly.ConstrainingType;
+import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.policy.PolicyFactory;
+import org.apache.tuscany.policy.impl.DefaultPolicyFactory;
+import org.apache.tuscany.services.spi.contribution.ArtifactResolver;
+import org.apache.tuscany.services.spi.contribution.ContributionException;
+import org.apache.tuscany.services.spi.contribution.ContributionReadException;
+import org.apache.tuscany.services.spi.contribution.StAXArtifactProcessorRegistry;
+import org.apache.tuscany.services.spi.contribution.URLArtifactProcessor;
+
+/**
+ * A contrainingType content handler.
+ * 
+ * @version $Rev$ $Date$
+ */
+public class ConstrainingTypeDocumentProcessor extends BaseArtifactProcessor implements URLArtifactProcessor<ConstrainingType> {
+    private StAXArtifactProcessorRegistry registry;
+    private XMLInputFactory inputFactory;
+
+    /**
+     * Construct a new constrainingType processor.
+     * @param factory
+     * @param policyFactory
+     * @param registry
+     */
+    public ConstrainingTypeDocumentProcessor(AssemblyFactory factory, PolicyFactory policyFactory, StAXArtifactProcessorRegistry registry, XMLInputFactory inputFactory) {
+        super(factory, policyFactory);
+        this.registry = registry;
+        this.inputFactory = inputFactory;
+    }
+
+    /**
+     * Construct a new constrainingType processor.
+     * @param registry
+     */
+    public ConstrainingTypeDocumentProcessor(StAXArtifactProcessorRegistry registry) {
+        this(new DefaultAssemblyFactory(), new DefaultPolicyFactory(), registry, XMLInputFactory.newInstance());
+        this.registry = registry;
+    }
+
+    public ConstrainingType read(URL url) throws ContributionReadException {
+        try {
+            XMLStreamReader reader = inputFactory.createXMLStreamReader(url.openStream());
+            ConstrainingType constrainingType = (ConstrainingType)registry.read(reader);
+            return constrainingType;
+            
+        } catch (XMLStreamException e) {
+            throw new ContributionReadException(e);
+        } catch (IOException e) {
+            throw new ContributionReadException(e);
+        }
+    }
+    
+    public void resolve(ConstrainingType constrainingType, ArtifactResolver resolver) throws ContributionException {
+        registry.resolve(constrainingType, resolver);
+    }
+    
+    public void optimize(ConstrainingType constrainingType) throws ContributionException {
+        registry.optimize(constrainingType);
+    }
+
+    public String getArtifactType() {
+        return ".constrainingType";
+    }
+    
+    public Class<ConstrainingType> getModelType() {
+        return ConstrainingType.class;
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ConstrainingTypeDocumentProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ConstrainingTypeDocumentProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org