tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsdelf...@apache.org
Subject svn commit: r526495 - in /incubator/tuscany/java/sca/modules: assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ contribution/src/main/java/org/apache/tuscany/services/spi/contri...
Date Sat, 07 Apr 2007 22:24:13 GMT
Author: jsdelfino
Date: Sat Apr  7 15:24:07 2007
New Revision: 526495

URL: http://svn.apache.org/viewvc?view=rev&rev=526495
Log:
Implemented XML writers for component implementations, Java interfaces and WSDL portTypes.

Added:
    incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/WireTestCase.java   (with props)
    incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/implementation/java/xml/WriteTestCase.java   (with props)
    incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/resources/org/
    incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/
    incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/
    incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/implementation/
    incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/implementation/java/
    incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/implementation/java/xml/
    incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/implementation/java/xml/Calculator.composite   (with props)
    incubator/tuscany/java/sca/modules/interface-java-xml/src/test/java/org/apache/tuscany/interfacedef/java/xml/WriteTestCase.java   (with props)
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/xml/WriteTestCase.java   (with props)
Removed:
    incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/OptimizeTestCase.java
    incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/resources/Calculator.composite
    incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/resources/CalculatorComponent.constrainingType
    incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/resources/CalculatorImpl.componentType
Modified:
    incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ComponentTypeProcessor.java
    incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/CompositeProcessor.java
    incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ConstrainingTypeProcessor.java
    incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ReadAllTestCase.java
    incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ReadDocumentTestCase.java
    incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ReadTestCase.java
    incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ResolveTestCase.java
    incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/StAXPerfTest.java
    incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/WriteAllTestCase.java
    incubator/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/services/spi/contribution/DefaultStAXArtifactProcessorRegistry.java
    incubator/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/services/spi/contribution/DefaultURLArtifactProcessorRegistry.java
    incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/xml/JavaImplementationProcessor.java
    incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/implementation/java/xml/ReadTestCase.java
    incubator/tuscany/java/sca/modules/interface-java-xml/src/main/java/org/apache/tuscany/interfacedef/java/xml/JavaInterfaceProcessor.java
    incubator/tuscany/java/sca/modules/interface-java-xml/src/test/java/org/apache/tuscany/interfacedef/java/xml/ReadTestCase.java
    incubator/tuscany/java/sca/modules/interface-java-xml/src/test/resources/org/apache/tuscany/interfacedef/java/xml/Calculator.composite
    incubator/tuscany/java/sca/modules/interface-java-xml/src/test/resources/org/apache/tuscany/interfacedef/java/xml/CalculatorComponent.constrainingType
    incubator/tuscany/java/sca/modules/interface-java-xml/src/test/resources/org/apache/tuscany/interfacedef/java/xml/CalculatorImpl.componentType
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/xml/ReadTestCase.java
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/interfacedef/wsdl/xml/Calculator.composite
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/interfacedef/wsdl/xml/CalculatorComponent.constrainingType
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/interfacedef/wsdl/xml/CalculatorImpl.componentType

Modified: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ComponentTypeProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ComponentTypeProcessor.java?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ComponentTypeProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ComponentTypeProcessor.java Sat Apr  7 15:24:07 2007
@@ -212,6 +212,8 @@
     
             for (Service service : componentType.getServices()) {
                 writeStart(writer, SERVICE, new XAttr(NAME, service.getName()));
+                //TODO write callback interface 
+                extensionProcessor.write(service.getInterface(), writer);
                 if (service.getCallback() != null) {
                     writeStart(writer, CALLBACK);
                     writeEnd(writer);
@@ -225,6 +227,8 @@
                 writeStart(writer, REFERENCE,
                       new XAttr(NAME, reference.getName()),
                       new XAttr(TARGET, target));
+                //TODO write callback interface 
+                extensionProcessor.write(reference.getInterface(), writer);
                 if (reference.getCallback() != null) {
                     writeStart(writer, CALLBACK);
                     writeEnd(writer);

Modified: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/CompositeProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/CompositeProcessor.java?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/CompositeProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/CompositeProcessor.java Sat Apr  7 15:24:07 2007
@@ -343,6 +343,8 @@
                 ComponentService promotedService = compositeService.getPromotedService();
                 String promote = promotedService != null ? promotedService.getName() : null;
                 writeStart(writer, SERVICE, new XAttr(NAME, service.getName()), new XAttr(PROMOTE, promote));
+                //TODO write callback interface 
+                extensionProcessor.write(service.getInterface(), writer);
                 if (service.getCallback() != null) {
                     writeStart(writer, CALLBACK);
                     writeEnd(writer);
@@ -355,11 +357,13 @@
     
                 for (ComponentService service : component.getServices()) {
                     writeStart(writer, SERVICE, new XAttr(NAME, service.getName()));
-                    writeEnd(writer);
+                    //TODO write callback interface 
+                    extensionProcessor.write(service.getInterface(), writer);
                     if (service.getCallback() != null) {
                         writeStart(writer, CALLBACK);
                         writeEnd(writer);
                     }
+                    writeEnd(writer);
                 }
     
                 for (ComponentReference reference : component.getReferences()) {
@@ -368,6 +372,8 @@
                     writeStart(writer, REFERENCE,
                                new XAttr(NAME, reference.getName()),
                                new XAttr(TARGET,target));
+                    //TODO write callback interface 
+                    extensionProcessor.write(reference.getInterface(), writer);
                     if (reference.getCallback() != null) {
                         writeStart(writer, CALLBACK);
                         writeEnd(writer);
@@ -379,6 +385,16 @@
                     writeStart(writer, PROPERTY, new XAttr(NAME, property.getName()));
                     writeEnd(writer);
                 }
+
+                // Write the component implementation
+                Implementation implementation = component.getImplementation();
+                if (implementation instanceof Composite) {
+                    writeStart(writer, IMPLEMENTATION_COMPOSITE, 
+                       new XAttr(NAME, composite.getName()));
+                    writeEnd(writer);
+                } else {
+                    extensionProcessor.write(component.getImplementation(), writer);
+                }
     
                 writeEnd(writer);
             }
@@ -394,6 +410,8 @@
                 writeStart(writer, REFERENCE,
                            new XAttr(NAME, reference.getName()),
                            new XAttr(PROMOTE, promote));
+                //TODO write callback interface 
+                extensionProcessor.write(reference.getInterface(), writer);
                 if (reference.getCallback() != null) {
                     writeStart(writer, CALLBACK);
                     writeEnd(writer);

Modified: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ConstrainingTypeProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ConstrainingTypeProcessor.java?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ConstrainingTypeProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ConstrainingTypeProcessor.java Sat Apr  7 15:24:07 2007
@@ -181,12 +181,16 @@
     
             for (AbstractService service : constrainingType.getServices()) {
                 writeStart(writer, SERVICE, new XAttr(NAME, service.getName()));
+                //TODO write callback interface 
+                extensionProcessor.write(service.getInterface(), writer);
                 writeEnd(writer);
             }
     
             for (AbstractReference reference : constrainingType.getReferences()) {
                 writeStart(writer, REFERENCE,
                       new XAttr(NAME, reference.getName()));
+                //TODO write callback interface 
+                extensionProcessor.write(reference.getInterface(), writer);
                 writeEnd(writer);
             }
     

Modified: incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ReadAllTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ReadAllTestCase.java?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ReadAllTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ReadAllTestCase.java Sat Apr  7 15:24:07 2007
@@ -44,7 +44,7 @@
 import org.w3c.dom.Element;
 
 /**
- * Test the usability of the assembly model API when loading SCDL
+ * Test reading SCA XML assemblies.
  * 
  * @version $Rev$ $Date$
  */

Modified: incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ReadDocumentTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ReadDocumentTestCase.java?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ReadDocumentTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ReadDocumentTestCase.java Sat Apr  7 15:24:07 2007
@@ -36,7 +36,7 @@
 import org.apache.tuscany.services.spi.contribution.DefaultURLArtifactProcessorRegistry;
 
 /**
- * Test the resolving SCA XML assemblies.
+ * Test reading SCA XML assembly documents.
  * 
  * @version $Rev$ $Date$
  */

Modified: incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ReadTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ReadTestCase.java?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ReadTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ReadTestCase.java Sat Apr  7 15:24:07 2007
@@ -32,7 +32,7 @@
 import org.apache.tuscany.services.spi.contribution.DefaultStAXArtifactProcessorRegistry;
 
 /**
- * Test the usability of the assembly model API when loading SCDL
+ * Test reading SCA XML assemblies.
  * 
  * @version $Rev$ $Date$
  */

Modified: incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ResolveTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ResolveTestCase.java?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ResolveTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ResolveTestCase.java Sat Apr  7 15:24:07 2007
@@ -34,7 +34,7 @@
 import org.apache.tuscany.services.spi.contribution.DefaultStAXArtifactProcessorRegistry;
 
 /**
- * Test the resolving SCA XML assemblies.
+ * Test resolving SCA XML assemblies.
  * 
  * @version $Rev$ $Date$
  */

Modified: incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/StAXPerfTest.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/StAXPerfTest.java?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/StAXPerfTest.java (original)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/StAXPerfTest.java Sat Apr  7 15:24:07 2007
@@ -33,7 +33,7 @@
 import org.apache.tuscany.services.spi.contribution.DefaultStAXArtifactProcessorRegistry;
 
 /**
- * Test the usability of the assembly model API when loading SCDL
+ * Test the performance of StAX parsing.
  * 
  * @version $Rev$ $Date$
  */

Added: incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/WireTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/WireTestCase.java?view=auto&rev=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/WireTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/WireTestCase.java Sat Apr  7 15:24:07 2007
@@ -0,0 +1,104 @@
+/*
+ * 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;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.assembly.Composite;
+import org.apache.tuscany.assembly.ConstrainingType;
+import org.apache.tuscany.assembly.xml.impl.CompositeProcessor;
+import org.apache.tuscany.assembly.xml.impl.ConstrainingTypeProcessor;
+import org.apache.tuscany.services.spi.contribution.DefaultArtifactResolver;
+import org.apache.tuscany.services.spi.contribution.DefaultStAXArtifactProcessorRegistry;
+
+/**
+ * Test the wiring of SCA XML assemblies.
+ * 
+ * @version $Rev$ $Date$
+ */
+public class WireTestCase extends TestCase {
+
+    private XMLInputFactory inputFactory;
+    private DefaultStAXArtifactProcessorRegistry registry;
+
+    public void setUp() throws Exception {
+        inputFactory = XMLInputFactory.newInstance();
+        registry = new DefaultStAXArtifactProcessorRegistry();
+    }
+
+    public void tearDown() throws Exception {
+        inputFactory = null;
+        registry = null;
+    }
+
+    public void testResolveConstrainingType() throws Exception {
+        DefaultArtifactResolver resolver = new DefaultArtifactResolver();
+        
+        InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
+        ConstrainingTypeProcessor constrainingTypeReader = new ConstrainingTypeProcessor(registry);
+        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+        ConstrainingType constrainingType = constrainingTypeReader.read(reader);
+        is.close();
+        assertNotNull(constrainingType);
+        resolver.put(constrainingType, constrainingType);
+
+        is = getClass().getResourceAsStream("TestAllCalculator.composite");
+        CompositeProcessor compositeReader = new CompositeProcessor(registry);
+        reader = inputFactory.createXMLStreamReader(is);
+        Composite composite = compositeReader.read(reader);
+        is.close();
+        assertNotNull(composite);
+        
+        compositeReader.resolve(composite, resolver);
+        compositeReader.wire(composite);
+        
+        assertEquals(composite.getConstrainingType(), constrainingType);
+        assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
+    }
+
+    public void testResolveComposite() throws Exception {
+        DefaultArtifactResolver resolver = new DefaultArtifactResolver();
+        
+        InputStream is = getClass().getResourceAsStream("Calculator.composite");
+        CompositeProcessor compositeReader = new CompositeProcessor(registry);
+        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+        Composite nestedComposite = compositeReader.read(reader);
+        is.close();
+        assertNotNull(nestedComposite);
+        resolver.put(nestedComposite, nestedComposite);
+
+        is = getClass().getResourceAsStream("TestAllCalculator.composite");
+        compositeReader = new CompositeProcessor(registry);
+        reader = inputFactory.createXMLStreamReader(is);
+        Composite composite = compositeReader.read(reader);
+        is.close();
+        
+        compositeReader.resolve(composite, resolver);
+        compositeReader.wire(composite);
+        
+        assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
+    }
+
+}

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

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

Modified: incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/WriteAllTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/WriteAllTestCase.java?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/WriteAllTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/WriteAllTestCase.java Sat Apr  7 15:24:07 2007
@@ -33,7 +33,7 @@
 import org.apache.tuscany.services.spi.contribution.DefaultStAXArtifactProcessorRegistry;
 
 /**
- * Test the usability of the assembly model API when loading SCDL
+ * Test writing SCA XML assemblies.
  * 
  * @version $Rev$ $Date$
  */

Modified: incubator/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/services/spi/contribution/DefaultStAXArtifactProcessorRegistry.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/services/spi/contribution/DefaultStAXArtifactProcessorRegistry.java?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/services/spi/contribution/DefaultStAXArtifactProcessorRegistry.java (original)
+++ incubator/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/services/spi/contribution/DefaultStAXArtifactProcessorRegistry.java Sat Apr  7 15:24:07 2007
@@ -73,27 +73,33 @@
     public void write(Object model, XMLStreamWriter outputSource) throws ContributionWriteException {
         
         // Delegate to the processor associated with the model type
-        StAXArtifactProcessor<Object> processor = (StAXArtifactProcessor<Object>)this.getProcessor((Class<Object>)model.getClass());
-        if (processor != null) {
-            processor.write(model, outputSource);
+        if (model != null) {
+            StAXArtifactProcessor<Object> processor = (StAXArtifactProcessor<Object>)this.getProcessor((Class<Object>)model.getClass());
+            if (processor != null) {
+                processor.write(model, outputSource);
+            }
         }
     }
     
     public void resolve(Object model, ArtifactResolver resolver) throws ContributionResolveException {
 
         // Delegate to the processor associated with the model type
-        StAXArtifactProcessor<Object> processor = (StAXArtifactProcessor<Object>)this.getProcessor((Class<Object>)model.getClass());
-        if (processor != null) {
-            processor.resolve(model, resolver);
+        if (model != null) {
+            StAXArtifactProcessor<Object> processor = (StAXArtifactProcessor<Object>)this.getProcessor((Class<Object>)model.getClass());
+            if (processor != null) {
+                processor.resolve(model, resolver);
+            }
         }
     }
     
     public void wire(Object model) throws ContributionWireException {
 
         // Delegate to the processor associated with the model type
-        StAXArtifactProcessor<Object> processor = (StAXArtifactProcessor<Object>)this.getProcessor((Class<Object>)model.getClass());
-        if (processor != null) {
-            processor.wire(model);
+        if (model != null) {
+            StAXArtifactProcessor<Object> processor = (StAXArtifactProcessor<Object>)this.getProcessor((Class<Object>)model.getClass());
+            if (processor != null) {
+                processor.wire(model);
+            }
         }
     }
 

Modified: incubator/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/services/spi/contribution/DefaultURLArtifactProcessorRegistry.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/services/spi/contribution/DefaultURLArtifactProcessorRegistry.java?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/services/spi/contribution/DefaultURLArtifactProcessorRegistry.java (original)
+++ incubator/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/services/spi/contribution/DefaultURLArtifactProcessorRegistry.java Sat Apr  7 15:24:07 2007
@@ -53,9 +53,11 @@
     public void write(Object model, URL outputSource) throws ContributionWriteException {
         
         // Delegate to the processor associated with the particular model type
-        URLArtifactProcessor<Object> processor = (URLArtifactProcessor<Object>)this.getProcessor((Class<Object>)model.getClass());
-        if (processor != null) {
-            processor.write(model, outputSource);
+        if (model != null) {
+            URLArtifactProcessor<Object> processor = (URLArtifactProcessor<Object>)this.getProcessor((Class<Object>)model.getClass());
+            if (processor != null) {
+                processor.write(model, outputSource);
+            }
         }
     }
     
@@ -64,18 +66,22 @@
     public void resolve(Object model, ArtifactResolver resolver) throws ContributionResolveException {
 
         // Delegate to the processor associated with the model type
-        URLArtifactProcessor<Object> processor = (URLArtifactProcessor<Object>)this.getProcessor((Class<Object>)model.getClass());
-        if (processor != null) {
-            processor.resolve(model, resolver);
+        if (model != null) {
+            URLArtifactProcessor<Object> processor = (URLArtifactProcessor<Object>)this.getProcessor((Class<Object>)model.getClass());
+            if (processor != null) {
+                processor.resolve(model, resolver);
+            }
         }
     }
     
     public void wire(Object model) throws ContributionWireException {
 
         // Delegate to the processor associated with the model type
-        URLArtifactProcessor<Object> processor = (URLArtifactProcessor<Object>)this.getProcessor((Class<Object>)model.getClass());
-        if (processor != null) {
-            processor.wire(model);
+        if (model != null) {
+            URLArtifactProcessor<Object> processor = (URLArtifactProcessor<Object>)this.getProcessor((Class<Object>)model.getClass());
+            if (processor != null) {
+                processor.wire(model);
+            }
         }
     }
     

Modified: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/xml/JavaImplementationProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/xml/JavaImplementationProcessor.java?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/xml/JavaImplementationProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/xml/JavaImplementationProcessor.java Sat Apr  7 15:24:07 2007
@@ -27,6 +27,7 @@
 import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.assembly.xml.Constants;
 import org.apache.tuscany.implementation.java.JavaImplementation;
 import org.apache.tuscany.implementation.java.JavaImplementationFactory;
 import org.apache.tuscany.implementation.java.impl.DefaultJavaImplementationFactory;
@@ -71,8 +72,18 @@
         }
     }
     
-    public void write(JavaImplementation model, XMLStreamWriter outputSource) throws ContributionWriteException {
-        // TODO Auto-generated method stub
+    public void write(JavaImplementation javaImplementation, XMLStreamWriter writer) throws ContributionWriteException {
+        try {
+            // Write an <interface.java>
+            writer.writeStartElement(Constants.SCA10_NS, IMPLEMENTATION_JAVA);
+            if (javaImplementation.getName() != null) {
+                writer.writeAttribute(CLASS, javaImplementation.getName());
+            }
+            writer.writeEndElement();
+            
+        } catch (XMLStreamException e) {
+            throw new ContributionWriteException(e);
+        }
     }
     
     public void resolve(JavaImplementation model, ArtifactResolver resolver) throws ContributionResolveException {

Modified: incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/implementation/java/xml/ReadTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/implementation/java/xml/ReadTestCase.java?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/implementation/java/xml/ReadTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/implementation/java/xml/ReadTestCase.java Sat Apr  7 15:24:07 2007
@@ -26,18 +26,14 @@
 
 import junit.framework.TestCase;
 
-import org.apache.tuscany.assembly.ComponentType;
 import org.apache.tuscany.assembly.Composite;
-import org.apache.tuscany.assembly.ConstrainingType;
 import org.apache.tuscany.assembly.util.CompositeUtil;
 import org.apache.tuscany.assembly.util.PrintUtil;
-import org.apache.tuscany.assembly.xml.impl.ComponentTypeProcessor;
 import org.apache.tuscany.assembly.xml.impl.CompositeProcessor;
-import org.apache.tuscany.assembly.xml.impl.ConstrainingTypeProcessor;
 import org.apache.tuscany.services.spi.contribution.DefaultStAXArtifactProcessorRegistry;
 
 /**
- * Test the usability of the assembly model API when loading SCDL
+ * Test reading Java implementations.
  * 
  * @version $Rev$ $Date$
  */
@@ -59,29 +55,9 @@
         registry = null;
     }
 
-    public void testReadComponentType() throws Exception {
-        ComponentTypeProcessor componentTypeProcessor = new ComponentTypeProcessor(registry);
-        InputStream is = getClass().getClassLoader().getResourceAsStream("CalculatorImpl.componentType");
-        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
-        ComponentType componentType = componentTypeProcessor.read(reader);
-        assertNotNull(componentType);
-        
-        new PrintUtil(System.out).print(componentType);
-    }
-
-    public void testReadConstrainingType() throws Exception {
-        ConstrainingTypeProcessor constrainingTypeProcessor = new ConstrainingTypeProcessor(registry);
-        InputStream is = getClass().getClassLoader().getResourceAsStream("CalculatorComponent.constrainingType");
-        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
-        ConstrainingType constrainingType = constrainingTypeProcessor.read(reader);
-        assertNotNull(constrainingType);
-
-        new PrintUtil(System.out).print(constrainingType);
-    }
-    
     public void testReadComposite() throws Exception {
         CompositeProcessor compositeProcessor = new CompositeProcessor(registry);
-        InputStream is = getClass().getClassLoader().getResourceAsStream("Calculator.composite");
+        InputStream is = getClass().getResourceAsStream("Calculator.composite");
         XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
         Composite composite = compositeProcessor.read(reader);
         assertNotNull(composite);

Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/implementation/java/xml/WriteTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/implementation/java/xml/WriteTestCase.java?view=auto&rev=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/implementation/java/xml/WriteTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/implementation/java/xml/WriteTestCase.java Sat Apr  7 15:24:07 2007
@@ -0,0 +1,68 @@
+/*
+ * 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.implementation.java.xml;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.assembly.Composite;
+import org.apache.tuscany.assembly.xml.impl.ComponentTypeProcessor;
+import org.apache.tuscany.assembly.xml.impl.CompositeProcessor;
+import org.apache.tuscany.assembly.xml.impl.ConstrainingTypeProcessor;
+import org.apache.tuscany.services.spi.contribution.DefaultStAXArtifactProcessorRegistry;
+
+/**
+ * Test writing Java implementations.
+ * 
+ * @version $Rev$ $Date$
+ */
+public class WriteTestCase extends TestCase {
+
+    XMLInputFactory inputFactory;
+    DefaultStAXArtifactProcessorRegistry registry;
+    
+    public void setUp() throws Exception {
+        inputFactory = XMLInputFactory.newInstance();
+        registry = new DefaultStAXArtifactProcessorRegistry();
+
+        registry.addArtifactProcessor(new CompositeProcessor(registry));
+        registry.addArtifactProcessor(new ComponentTypeProcessor(registry));
+        registry.addArtifactProcessor(new ConstrainingTypeProcessor(registry));
+
+        JavaImplementationProcessor javaProcessor = new JavaImplementationProcessor();
+        registry.addArtifactProcessor(javaProcessor);
+    }
+
+    public void tearDown() throws Exception {
+        inputFactory = null;
+        registry = null;
+    }
+
+    public void testReadWriteComposite() throws Exception {
+        InputStream is = getClass().getResourceAsStream("Calculator.composite");
+        Composite composite = registry.read(is, Composite.class);
+        assertNotNull(composite);
+        registry.write(composite, System.out);
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/implementation/java/xml/WriteTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/implementation/java/xml/WriteTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/implementation/java/xml/Calculator.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/implementation/java/xml/Calculator.composite?view=auto&rev=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/implementation/java/xml/Calculator.composite (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/implementation/java/xml/Calculator.composite Sat Apr  7 15:24:07 2007
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.    
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+	xmlns:calc="http://sample.calculator"
+	targetNamespace="http://sample.calculator"
+	name="Calculator">
+
+    <service name="CalculatorService" promote="CalculatorServiceComponent">
+        <interface.java interface="calculator.CalculatorService"/>
+    </service>
+
+    <component name="CalculatorServiceComponent">
+		<implementation.java class="calculator.CalculatorServiceImpl"/>
+        <reference name="addService" target="AddServiceComponent"/>
+        <reference name="subtractService" target="SubtractServiceComponent"/>
+        <reference name="multiplyService" target="MultiplyServiceComponent"/>
+        <reference name="divideService" target="DivideServiceComponent"/>
+    </component>
+
+    <component name="AddServiceComponent">
+        <implementation.java class="calculator.AddServiceImpl"/>
+    </component>
+
+    <component name="SubtractServiceComponent">
+        <implementation.java class="calculator.SubtractServiceImpl"/>
+    </component>
+
+    <component name="MultiplyServiceComponent">
+        <implementation.java class="calculator.MultiplyServiceImpl"/>
+    </component>
+
+    <component name="DivideServiceComponent">
+        <implementation.java class="calculator.DivideServiceImpl"/>
+    </component>
+
+</composite>

Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/implementation/java/xml/Calculator.composite
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/implementation/java/xml/Calculator.composite
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/modules/interface-java-xml/src/main/java/org/apache/tuscany/interfacedef/java/xml/JavaInterfaceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-java-xml/src/main/java/org/apache/tuscany/interfacedef/java/xml/JavaInterfaceProcessor.java?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-java-xml/src/main/java/org/apache/tuscany/interfacedef/java/xml/JavaInterfaceProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/interface-java-xml/src/main/java/org/apache/tuscany/interfacedef/java/xml/JavaInterfaceProcessor.java Sat Apr  7 15:24:07 2007
@@ -26,6 +26,7 @@
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
+import org.apache.tuscany.assembly.xml.Constants;
 import org.apache.tuscany.interfacedef.java.JavaFactory;
 import org.apache.tuscany.interfacedef.java.JavaInterface;
 import org.apache.tuscany.interfacedef.java.impl.DefaultJavaFactory;
@@ -49,7 +50,6 @@
     }
 
     public JavaInterface read(XMLStreamReader reader) throws ContributionReadException {
-        
         try {
     
             // Read an <interface.java>
@@ -70,9 +70,18 @@
         }
     }
     
-    public void write(JavaInterface model, XMLStreamWriter outputSource) throws ContributionWriteException {
-        // TODO Auto-generated method stub
-        
+    public void write(JavaInterface javaInterface, XMLStreamWriter writer) throws ContributionWriteException {
+        try {
+            // Write an <interface.java>
+            writer.writeStartElement(Constants.SCA10_NS, INTERFACE_JAVA);
+            if (javaInterface.getName() != null) {
+                writer.writeAttribute(INTERFACE, javaInterface.getName());
+            }
+            writer.writeEndElement();
+            
+        } catch (XMLStreamException e) {
+            throw new ContributionWriteException(e);
+        }
     }
     
     public void resolve(JavaInterface model, ArtifactResolver resolver) throws ContributionResolveException {

Modified: incubator/tuscany/java/sca/modules/interface-java-xml/src/test/java/org/apache/tuscany/interfacedef/java/xml/ReadTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-java-xml/src/test/java/org/apache/tuscany/interfacedef/java/xml/ReadTestCase.java?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-java-xml/src/test/java/org/apache/tuscany/interfacedef/java/xml/ReadTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/interface-java-xml/src/test/java/org/apache/tuscany/interfacedef/java/xml/ReadTestCase.java Sat Apr  7 15:24:07 2007
@@ -38,7 +38,7 @@
 import org.apache.tuscany.services.spi.contribution.DefaultStAXArtifactProcessorRegistry;
 
 /**
- * Test the usability of the assembly model API when loading SCDL
+ * Test reading Java interfaces.
  * 
  * @version $Rev$ $Date$
  */

Added: incubator/tuscany/java/sca/modules/interface-java-xml/src/test/java/org/apache/tuscany/interfacedef/java/xml/WriteTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-java-xml/src/test/java/org/apache/tuscany/interfacedef/java/xml/WriteTestCase.java?view=auto&rev=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-java-xml/src/test/java/org/apache/tuscany/interfacedef/java/xml/WriteTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/interface-java-xml/src/test/java/org/apache/tuscany/interfacedef/java/xml/WriteTestCase.java Sat Apr  7 15:24:07 2007
@@ -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.tuscany.interfacedef.java.xml;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.assembly.ComponentType;
+import org.apache.tuscany.assembly.Composite;
+import org.apache.tuscany.assembly.ConstrainingType;
+import org.apache.tuscany.assembly.xml.impl.ComponentTypeProcessor;
+import org.apache.tuscany.assembly.xml.impl.CompositeProcessor;
+import org.apache.tuscany.assembly.xml.impl.ConstrainingTypeProcessor;
+import org.apache.tuscany.services.spi.contribution.DefaultStAXArtifactProcessorRegistry;
+
+/**
+ * Test writing Java interfaces.
+ * 
+ * @version $Rev$ $Date$
+ */
+public class WriteTestCase extends TestCase {
+
+    XMLInputFactory inputFactory;
+    DefaultStAXArtifactProcessorRegistry registry;
+
+    public void setUp() throws Exception {
+        inputFactory = XMLInputFactory.newInstance();
+        registry = new DefaultStAXArtifactProcessorRegistry();
+
+        registry.addArtifactProcessor(new CompositeProcessor(registry));
+        registry.addArtifactProcessor(new ComponentTypeProcessor(registry));
+        registry.addArtifactProcessor(new ConstrainingTypeProcessor(registry));
+
+        JavaInterfaceProcessor javaProcessor = new JavaInterfaceProcessor();
+        registry.addArtifactProcessor(javaProcessor);
+    }
+
+    public void tearDown() throws Exception {
+        inputFactory = null;
+        registry = null;
+    }
+
+    public void testReadWriteComponentType() throws Exception {
+        InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
+        ComponentType componentType = registry.read(is, ComponentType.class);
+        assertNotNull(componentType);
+        registry.write(componentType, System.out);
+    }
+
+    public void testReadWriteConstrainingType() throws Exception {
+        InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
+        ConstrainingType constrainingType = registry.read(is, ConstrainingType.class);
+        assertNotNull(constrainingType);
+        registry.write(constrainingType, System.out);
+    }
+
+    public void testReadWriteComposite() throws Exception {
+        InputStream is = getClass().getResourceAsStream("Calculator.composite");
+        Composite composite = registry.read(is, Composite.class);
+        assertNotNull(composite);
+        registry.write(composite, System.out);
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/interface-java-xml/src/test/java/org/apache/tuscany/interfacedef/java/xml/WriteTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/interface-java-xml/src/test/java/org/apache/tuscany/interfacedef/java/xml/WriteTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/modules/interface-java-xml/src/test/resources/org/apache/tuscany/interfacedef/java/xml/Calculator.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-java-xml/src/test/resources/org/apache/tuscany/interfacedef/java/xml/Calculator.composite?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-java-xml/src/test/resources/org/apache/tuscany/interfacedef/java/xml/Calculator.composite (original)
+++ incubator/tuscany/java/sca/modules/interface-java-xml/src/test/resources/org/apache/tuscany/interfacedef/java/xml/Calculator.composite Sat Apr  7 15:24:07 2007
@@ -20,7 +20,7 @@
 <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
 	xmlns:calc="http://sample.calculator"
 	targetNamespace="http://calc"
-	name="calc:Calculator">
+	name="Calculator">
 
     <service name="CalculatorService" promote="CalculatorServiceComponent">
         <interface.java interface="calculator.CalculatorService"/>

Modified: incubator/tuscany/java/sca/modules/interface-java-xml/src/test/resources/org/apache/tuscany/interfacedef/java/xml/CalculatorComponent.constrainingType
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-java-xml/src/test/resources/org/apache/tuscany/interfacedef/java/xml/CalculatorComponent.constrainingType?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-java-xml/src/test/resources/org/apache/tuscany/interfacedef/java/xml/CalculatorComponent.constrainingType (original)
+++ incubator/tuscany/java/sca/modules/interface-java-xml/src/test/resources/org/apache/tuscany/interfacedef/java/xml/CalculatorComponent.constrainingType Sat Apr  7 15:24:07 2007
@@ -23,11 +23,11 @@
 	name="CalculatorComponent">
 
   <service name="CalculatorService">
-        <interface.java class="calculator.CalculatorService" />
+        <interface.java interface="calculator.CalculatorService" />
   </service>
 
   <reference name="divideService">
-        <interface.java class="calculator.DivideService" />
+        <interface.java interface="calculator.DivideService" />
   </reference>  
 
 </constrainingType>              

Modified: incubator/tuscany/java/sca/modules/interface-java-xml/src/test/resources/org/apache/tuscany/interfacedef/java/xml/CalculatorImpl.componentType
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-java-xml/src/test/resources/org/apache/tuscany/interfacedef/java/xml/CalculatorImpl.componentType?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-java-xml/src/test/resources/org/apache/tuscany/interfacedef/java/xml/CalculatorImpl.componentType (original)
+++ incubator/tuscany/java/sca/modules/interface-java-xml/src/test/resources/org/apache/tuscany/interfacedef/java/xml/CalculatorImpl.componentType Sat Apr  7 15:24:07 2007
@@ -20,11 +20,11 @@
 <componentType xmlns="http://www.osoa.org/xmlns/sca/1.0">
 
   <service name="CalculatorService">
-        <interface.java class="calculator.CalculatorService" />
+        <interface.java interface="calculator.CalculatorService" />
   </service>
 
   <reference name="divideService">
-        <interface.java class="calculator.DivideService" />
+        <interface.java interface="calculator.DivideService" />
   </reference>  
 
 </componentType>              

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java Sat Apr  7 15:24:07 2007
@@ -26,6 +26,7 @@
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
+import org.apache.tuscany.assembly.xml.Constants;
 import org.apache.tuscany.interfacedef.wsdl.WSDLFactory;
 import org.apache.tuscany.interfacedef.wsdl.WSDLInterface;
 import org.apache.tuscany.interfacedef.wsdl.impl.DefaultWSDLFactory;
@@ -49,15 +50,26 @@
     }
 
     public WSDLInterface read(XMLStreamReader reader) throws ContributionReadException {
-        
         try {
     
-            // Read an <interface.java>
+            // Read an <interface.wsdl>
             WSDLInterface wsdlInterface = wsdlFactory.createWSDLInterface();
             wsdlInterface.setUnresolved(true);
-            // TODO handle qname
-            wsdlInterface.setName(new QName("", reader.getAttributeValue(null, INTERFACE)));
-    
+
+            // Read a qname in the form:
+            // namespace#wsdl.interface(name)
+            String uri = reader.getAttributeValue(null, INTERFACE);
+            if (uri != null) {
+                int index = uri.indexOf('#');
+                if (index == -1) {
+                    throw new ContributionReadException("Invalid WSDL interface attribute: " + uri);
+                }
+                String namespace = uri.substring(0, index);
+                String name = uri.substring(index + 1);
+                name = name.substring("wsdl.interface(".length(), name.length() - 1);
+                wsdlInterface.setName(new QName(namespace, name));
+            }
+                
             // Skip to end element
             while (reader.hasNext()) {
                 if (reader.next() == END_ELEMENT && INTERFACE_WSDL_QNAME.equals(reader.getName())) {
@@ -71,8 +83,21 @@
         }
     }
     
-    public void write(WSDLInterface model, XMLStreamWriter outputSource) throws ContributionWriteException {
-        // TODO Auto-generated method stub
+    public void write(WSDLInterface wsdlInterface, XMLStreamWriter writer) throws ContributionWriteException {
+        try {
+            // Write an <interface.wsdl>
+            writer.writeStartElement(Constants.SCA10_NS, INTERFACE_WSDL);
+            if (wsdlInterface.getName() != null) {
+                //FIXME Write portType QName
+                QName qname = wsdlInterface.getName();
+                String uri = qname.getNamespaceURI() + "#wsdl.interface(" + qname.getLocalPart() + ")";
+                writer.writeAttribute(INTERFACE, uri);
+            }
+            writer.writeEndElement();
+            
+        } catch (XMLStreamException e) {
+            throw new ContributionWriteException(e);
+        }
     }
     
     public void resolve(WSDLInterface model, ArtifactResolver resolver) throws ContributionResolveException {

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/xml/ReadTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/xml/ReadTestCase.java?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/xml/ReadTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/xml/ReadTestCase.java Sat Apr  7 15:24:07 2007
@@ -38,7 +38,7 @@
 import org.apache.tuscany.services.spi.contribution.DefaultStAXArtifactProcessorRegistry;
 
 /**
- * Test the usability of the assembly model API when loading SCDL
+ * Test reading WSDL interfaces.
  * 
  * @version $Rev$ $Date$
  */

Added: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/xml/WriteTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/xml/WriteTestCase.java?view=auto&rev=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/xml/WriteTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/xml/WriteTestCase.java Sat Apr  7 15:24:07 2007
@@ -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.tuscany.interfacedef.wsdl.xml;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.assembly.ComponentType;
+import org.apache.tuscany.assembly.Composite;
+import org.apache.tuscany.assembly.ConstrainingType;
+import org.apache.tuscany.assembly.xml.impl.ComponentTypeProcessor;
+import org.apache.tuscany.assembly.xml.impl.CompositeProcessor;
+import org.apache.tuscany.assembly.xml.impl.ConstrainingTypeProcessor;
+import org.apache.tuscany.services.spi.contribution.DefaultStAXArtifactProcessorRegistry;
+
+/**
+ * Test reading/write WSDL interfaces.
+ * 
+ * @version $Rev$ $Date$
+ */
+public class WriteTestCase extends TestCase {
+
+    XMLInputFactory inputFactory;
+    DefaultStAXArtifactProcessorRegistry registry;
+
+    public void setUp() throws Exception {
+        inputFactory = XMLInputFactory.newInstance();
+        registry = new DefaultStAXArtifactProcessorRegistry();
+
+        registry.addArtifactProcessor(new CompositeProcessor(registry));
+        registry.addArtifactProcessor(new ComponentTypeProcessor(registry));
+        registry.addArtifactProcessor(new ConstrainingTypeProcessor(registry));
+
+        WSDLInterfaceProcessor wsdlProcessor = new WSDLInterfaceProcessor();
+        registry.addArtifactProcessor(wsdlProcessor);
+    }
+
+    public void tearDown() throws Exception {
+        inputFactory = null;
+        registry = null;
+    }
+
+    public void testReadWriteComponentType() throws Exception {
+        InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
+        ComponentType componentType = registry.read(is, ComponentType.class);
+        assertNotNull(componentType);
+        registry.write(componentType, System.out);
+    }
+
+    public void testReadWriteConstrainingType() throws Exception {
+        InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
+        ConstrainingType constrainingType = registry.read(is, ConstrainingType.class);
+        assertNotNull(constrainingType);
+        registry.write(constrainingType, System.out);
+    }
+
+    public void testReadWriteComposite() throws Exception {
+        InputStream is = getClass().getResourceAsStream("Calculator.composite");
+        Composite composite = registry.read(is, Composite.class);
+        assertNotNull(composite);
+        registry.write(composite, System.out);
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/xml/WriteTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/xml/WriteTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/interfacedef/wsdl/xml/Calculator.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/interfacedef/wsdl/xml/Calculator.composite?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/interfacedef/wsdl/xml/Calculator.composite (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/interfacedef/wsdl/xml/Calculator.composite Sat Apr  7 15:24:07 2007
@@ -20,7 +20,7 @@
 <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
 	xmlns:calc="http://sample.calculator"
 	targetNamespace="http://calc"
-	name="calc:Calculator">
+	name="Calculator">
 
     <service name="CalculatorService" promote="CalculatorServiceComponent">
         <interface.wsdl interface="http://sample/calculator#wsdl.interface(Calculator)"/>

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/interfacedef/wsdl/xml/CalculatorComponent.constrainingType
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/interfacedef/wsdl/xml/CalculatorComponent.constrainingType?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/interfacedef/wsdl/xml/CalculatorComponent.constrainingType (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/interfacedef/wsdl/xml/CalculatorComponent.constrainingType Sat Apr  7 15:24:07 2007
@@ -27,7 +27,7 @@
   </service>
 
   <reference name="divideService">
-        <interface.java class="calculator.DivideService" />
+        <interface.wsdl interface="http://sample/calculator#wsdl.interface(Divide)"/>
   </reference>  
 
 </constrainingType>              

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/interfacedef/wsdl/xml/CalculatorImpl.componentType
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/interfacedef/wsdl/xml/CalculatorImpl.componentType?view=diff&rev=526495&r1=526494&r2=526495
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/interfacedef/wsdl/xml/CalculatorImpl.componentType (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/interfacedef/wsdl/xml/CalculatorImpl.componentType Sat Apr  7 15:24:07 2007
@@ -24,7 +24,7 @@
   </service>
 
   <reference name="divideService">
-        <interface.java class="calculator.DivideService" />
+        <interface.wsdl interface="http://sample/calculator#wsdl.interface(Divide)"/>
   </reference>  
 
 </componentType>              



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


Mime
View raw message