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/03/21 23:12:10 UTC

svn commit: r521022 [1/2] - in /incubator/tuscany/sandbox/sebastien/java/sca: assembly-builder/src/main/java/org/apache/tuscany/assembly/builder/ assembly-builder/src/main/java/org/apache/tuscany/assembly/builder/impl/ assembly-builder/src/test/java/or...

Author: jsdelfino
Date: Wed Mar 21 15:12:08 2007
New Revision: 521022

URL: http://svn.apache.org/viewvc?view=rev&rev=521022
Log:
Some refactoring of the scdl module. Adding binding methods to builders. Starting to use SCDL constants in the readers.

Added:
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/ComponentTypeHandler.java   (with props)
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/CompositeHandler.java   (with props)
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/ConstrainingTypeHandler.java   (with props)
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/util/
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/util/BaseHandler.java   (with props)
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/util/NamespaceStack.java   (with props)
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/ComponentTypeWriter.java   (with props)
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/CompositeWriter.java   (with props)
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/ConstrainingTypeWriter.java   (with props)
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/util/
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/util/Attr.java   (with props)
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/util/BaseWriter.java   (with props)
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/reader/
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/reader/ReadTestCase.java   (with props)
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/writer/
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/writer/WriteTestCase.java   (with props)
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/xml/
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/xml/BuildCompositeXMLTestCase.java   (with props)
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/xml/util/
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/xml/util/Attr.java   (with props)
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/xml/util/Base.java   (with props)
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/xml/util/Element.java   (with props)
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/xml/util/ElementWriter.java   (with props)
    incubator/tuscany/sandbox/sebastien/java/sca/assembly/src/main/java/org/apache/tuscany/assembly/util/
    incubator/tuscany/sandbox/sebastien/java/sca/assembly/src/main/java/org/apache/tuscany/assembly/util/PrintUtil.java   (with props)
Removed:
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/assembly/reader/
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/assembly/writer/
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/assembly/xml/
Modified:
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/main/java/org/apache/tuscany/assembly/builder/ComponentReferenceBuilder.java
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/main/java/org/apache/tuscany/assembly/builder/ComponentServiceBuilder.java
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/main/java/org/apache/tuscany/assembly/builder/impl/ComponentReferenceBuilderImpl.java
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/main/java/org/apache/tuscany/assembly/builder/impl/ComponentServiceBuilderImpl.java
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/test/java/org/apache/tuscany/assembly/builder/BigBankBuilder.java
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/Constants.java
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/assembly/builder/BigBankBuilder.java
    incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/assembly/builder/BigBankBuilderTestCase.java

Modified: incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/main/java/org/apache/tuscany/assembly/builder/ComponentReferenceBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/main/java/org/apache/tuscany/assembly/builder/ComponentReferenceBuilder.java?view=diff&rev=521022&r1=521021&r2=521022
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/main/java/org/apache/tuscany/assembly/builder/ComponentReferenceBuilder.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/main/java/org/apache/tuscany/assembly/builder/ComponentReferenceBuilder.java Wed Mar 21 15:12:08 2007
@@ -23,10 +23,14 @@
 	
 	ComponentReferenceBuilder wiredTo(String target);
 	
-	ComponentReferenceBuilder definedBy(Class interfaceClass);
+	ComponentReferenceBuilder wiredTo(ComponentServiceBuilder target);
+	
+	ComponentReferenceBuilder typedBy(Class interfaceClass);
 	
 	ComponentReferenceBuilder promotedAs(String promoted);
 
 	ComponentReferenceBuilder promoted();
+	
+	ComponentReferenceBuilder boundTo(String uri);
 
 }

Modified: incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/main/java/org/apache/tuscany/assembly/builder/ComponentServiceBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/main/java/org/apache/tuscany/assembly/builder/ComponentServiceBuilder.java?view=diff&rev=521022&r1=521021&r2=521022
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/main/java/org/apache/tuscany/assembly/builder/ComponentServiceBuilder.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/main/java/org/apache/tuscany/assembly/builder/ComponentServiceBuilder.java Wed Mar 21 15:12:08 2007
@@ -21,10 +21,12 @@
 
 public interface ComponentServiceBuilder {
 	
-	ComponentServiceBuilder definedBy(Class interfaceClass);
+	ComponentServiceBuilder typedBy(Class interfaceClass);
 	
 	ComponentServiceBuilder promotedAs(String promoted);
 	
 	ComponentServiceBuilder promoted();
+	
+	ComponentServiceBuilder boundTo(String uri);
 	
 }

Modified: incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/main/java/org/apache/tuscany/assembly/builder/impl/ComponentReferenceBuilderImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/main/java/org/apache/tuscany/assembly/builder/impl/ComponentReferenceBuilderImpl.java?view=diff&rev=521022&r1=521021&r2=521022
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/main/java/org/apache/tuscany/assembly/builder/impl/ComponentReferenceBuilderImpl.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/main/java/org/apache/tuscany/assembly/builder/impl/ComponentReferenceBuilderImpl.java Wed Mar 21 15:12:08 2007
@@ -20,6 +20,7 @@
 package org.apache.tuscany.assembly.builder.impl;
 
 import org.apache.tuscany.assembly.builder.ComponentReferenceBuilder;
+import org.apache.tuscany.assembly.builder.ComponentServiceBuilder;
 import org.apache.tuscany.assembly.model.ComponentService;
 import org.apache.tuscany.assembly.model.CompositeReference;
 import org.apache.tuscany.assembly.model.impl.ComponentReferenceImpl;
@@ -38,7 +39,12 @@
 		return this;
 	}
 	
-	public ComponentReferenceBuilderImpl definedBy(Class interfaceClass) {
+	public ComponentReferenceBuilder wiredTo(ComponentServiceBuilder target) {
+		getTargets().add((ComponentServiceImpl)target);
+		return this;
+	}
+	
+	public ComponentReferenceBuilderImpl typedBy(Class interfaceClass) {
 		//FIXME support for Java interfaces 
 		return this;
 	}
@@ -55,7 +61,12 @@
 		return this;
 	}
 
-	public CompositeReference getCompositeReference() {
+	public ComponentReferenceBuilder boundTo(String uri) {
+		//TODO support bindings
+		return this;
+	}
+
+	CompositeReference getCompositeReference() {
 		return compositeReference;
 	}
 }

Modified: incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/main/java/org/apache/tuscany/assembly/builder/impl/ComponentServiceBuilderImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/main/java/org/apache/tuscany/assembly/builder/impl/ComponentServiceBuilderImpl.java?view=diff&rev=521022&r1=521021&r2=521022
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/main/java/org/apache/tuscany/assembly/builder/impl/ComponentServiceBuilderImpl.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/main/java/org/apache/tuscany/assembly/builder/impl/ComponentServiceBuilderImpl.java Wed Mar 21 15:12:08 2007
@@ -28,7 +28,7 @@
 	
 	private CompositeService compositeService;
 	
-	public ComponentServiceBuilderImpl definedBy(Class interfaceClass) {
+	public ComponentServiceBuilderImpl typedBy(Class interfaceClass) {
 		//FIXME support for Java interfaces 
 		return this;
 	}
@@ -45,7 +45,12 @@
 		return this;
 	}
 	
-	public CompositeService getCompositeService() {
+	public ComponentServiceBuilder boundTo(String uri) {
+		// TODO support bindings
+		return this;
+	}
+	
+	CompositeService getCompositeService() {
 		return compositeService;
 	}
 	

Modified: incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/test/java/org/apache/tuscany/assembly/builder/BigBankBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/test/java/org/apache/tuscany/assembly/builder/BigBankBuilder.java?view=diff&rev=521022&r1=521021&r2=521022
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/test/java/org/apache/tuscany/assembly/builder/BigBankBuilder.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca/assembly-builder/src/test/java/org/apache/tuscany/assembly/builder/BigBankBuilder.java Wed Mar 21 15:12:08 2007
@@ -30,11 +30,11 @@
 			component("AccountServiceComponent").
 			implementedBy(AccountServiceImpl.class).
 			uses(
-				reference("accountDataService").definedBy(AccountDataService.class).wiredTo("AccountDataServiceComponent/AccountDataService"),
+				reference("accountDataService").typedBy(AccountDataService.class).wiredTo("AccountDataServiceComponent/AccountDataService"),
 				reference("stockQuoteService").promotedAs("StockQuoteService")
 			).
 			provides(
-				service("AccountDataService").definedBy(AccountService.class).promoted()
+				service("AccountDataService").typedBy(AccountService.class).promoted()
 			).
 			declares(
 				property("currency").ofType("string").configuredTo("USD")
@@ -43,7 +43,7 @@
 			component("AccountDataServiceComponent").
 			implementedBy(AccountDataServiceImpl.class).
 			provides(
-				service("AccountDataService").definedBy(AccountDataService.class)
+				service("AccountDataService").typedBy(AccountDataService.class)
 			)
 		);
 		

Modified: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/Constants.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/Constants.java?view=diff&rev=521022&r1=521021&r2=521022
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/Constants.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/Constants.java Wed Mar 21 15:12:08 2007
@@ -22,7 +22,37 @@
 public interface Constants {
 	
 	public final static String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0";
+	public final static String COMPONENT_TYPE = "componentType";
+	public final static String SERVICE = "service";
+	public final static String REFERENCE = "reference";
+	public final static String PROPERTY = "property";
+	public final static String CONSTRAINING_TYPE = "constrainingType";
 	public final static String COMPOSITE = "composite";
+	public final static String INCLUDE = "include";
 	public final static String COMPONENT = "component";
+	public final static String WIRE = "wire";
+	public final static String NAME = "name";
+	public final static String TARGET_NAMESPACE = "targetNamespace";
+	public final static String LOCAL = "local";
+	public final static String AUTOWIRE = "autowire";
+	public final static String REQUIRES = "requires";
+	public final static String POLICY_SETS = "policySets";
+	public final static String OPERATION = "operation";
+	public final static String CALLBACK = "callback";
+	public final static String PROMOTE = "promote";
+	public final static String TARGET = "target";
+	public final static String WIRED_BY_IMPL = "wiredByImpl";
+	public final static String MULTIPLICITY = "multiplicity";
+	public final static String TYPE = "type";
+	public final static String ELEMENT = "element";
+	public final static String MANY = "many";
+	public final static String MUST_SUPPLY = "mustSupply";
+	public final static String SOURCE = "source";
+	public final static String FILE = "file";
+	public final static String URI = "uri";
+	public final static String ZERO_ONE = "0..1";
+	public final static String ZERO_N = "0..n";
+	public final static String ONE_ONE = "1..1";
+	public final static String ONE_N = "1..n";
 
 }

Added: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/ComponentTypeHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/ComponentTypeHandler.java?view=auto&rev=521022
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/ComponentTypeHandler.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/ComponentTypeHandler.java Wed Mar 21 15:12:08 2007
@@ -0,0 +1,108 @@
+/*
+ * 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.scdl.reader;
+
+import org.apache.tuscany.assembly.model.AssemblyFactory;
+import org.apache.tuscany.assembly.model.Callback;
+import org.apache.tuscany.assembly.model.ComponentService;
+import org.apache.tuscany.assembly.model.ComponentType;
+import org.apache.tuscany.assembly.model.Property;
+import org.apache.tuscany.assembly.model.Reference;
+import org.apache.tuscany.assembly.model.Service;
+import org.apache.tuscany.scdl.Constants;
+import org.apache.tuscany.scdl.reader.util.BaseHandler;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+/**
+ * A test handler to test the usability of the assembly model API when loading SCDL
+ * 
+ * @version $Rev$ $Date$
+ */
+public class ComponentTypeHandler extends BaseHandler implements ContentHandler {
+
+    private ComponentType componentType;
+    private Service service;
+    private Reference reference;
+    private Property property;
+    private Callback callback;
+
+    public ComponentTypeHandler(AssemblyFactory factory, XMLReader reader) {
+        super(factory, reader);
+    }
+
+    public void startElement(String uri, String name, String qname, Attributes attr) throws SAXException {
+        if (Constants.SCA10_NS.equals(uri)) {
+
+            if (Constants.COMPONENT_TYPE.equals(name)) {
+                componentType = factory.createComponentType();
+                componentType.setConstrainingType(getConstrainingType(attr));
+
+            } else if (Constants.SERVICE.equals(name)) {
+                service = factory.createService();
+                componentType.getServices().add(service);
+                service.setName(getString(attr, Constants.NAME));
+
+            } else if (Constants.REFERENCE.equals(name)) {
+                reference = factory.createReference();
+                componentType.getReferences().add(reference);
+                reference.setName(getString(attr, Constants.NAME));
+
+                //TODO support multivalued attribute
+            	ComponentService target = factory.createComponentService();
+            	target.setUndefined(true);
+            	target.setName(getString(attr, Constants.TARGET));
+            	reference.getTargets().add(target);
+            	
+            } else if (Constants.PROPERTY.equals(name)) {
+                property = factory.createProperty();
+                readProperty(property, attr);
+
+            } else if (Constants.CALLBACK.equals(name)) {
+	            callback = factory.createCallback();
+	            if (reference != null) {
+	            	reference.setCallback(callback);
+	            } else if (service != null) {
+	            	service.setCallback(callback);
+	            }
+	        }
+        }
+    }
+
+    public void endElement(String uri, String name, String qName) throws SAXException {
+        if (Constants.SCA10_NS.equals(uri)) {
+            if (Constants.SERVICE.equals(name)) {
+                service = null;
+            } else if (Constants.REFERENCE.equals(name)) {
+                reference = null;
+            } else if (Constants.PROPERTY.equals(name)) {
+                property = null;
+            } else if (Constants.CALLBACK.equals(name))
+            	callback = null;
+        }
+    }
+
+	public ComponentType getComponentType() {
+		return componentType;
+	}
+
+}

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/ComponentTypeHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/ComponentTypeHandler.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/CompositeHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/CompositeHandler.java?view=auto&rev=521022
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/CompositeHandler.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/CompositeHandler.java Wed Mar 21 15:12:08 2007
@@ -0,0 +1,181 @@
+/*
+ * 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.scdl.reader;
+
+import org.apache.tuscany.assembly.model.AssemblyFactory;
+import org.apache.tuscany.assembly.model.Callback;
+import org.apache.tuscany.assembly.model.Component;
+import org.apache.tuscany.assembly.model.ComponentProperty;
+import org.apache.tuscany.assembly.model.ComponentReference;
+import org.apache.tuscany.assembly.model.ComponentService;
+import org.apache.tuscany.assembly.model.Composite;
+import org.apache.tuscany.assembly.model.CompositeReference;
+import org.apache.tuscany.assembly.model.CompositeService;
+import org.apache.tuscany.assembly.model.Property;
+import org.apache.tuscany.assembly.model.Wire;
+import org.apache.tuscany.scdl.Constants;
+import org.apache.tuscany.scdl.reader.util.BaseHandler;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+/**
+ * A test handler to test the usability of the assembly model API when loading SCDL
+ * 
+ * @version $Rev$ $Date$
+ */
+public class CompositeHandler extends BaseHandler implements ContentHandler {
+
+    private Composite composite;
+    private Component component;
+    private Property property;
+    private ComponentService componentService;
+    private ComponentReference componentReference;
+    private ComponentProperty componentProperty;
+    private CompositeService compositeService;
+    private CompositeReference compositeReference;
+    private Wire wire;
+    private Callback callback;
+
+    public CompositeHandler(AssemblyFactory factory, XMLReader reader) {
+        super(factory, reader);
+    }
+
+    public void startElement(String uri, String name, String qname, Attributes attr) throws SAXException {
+        if (Constants.SCA10_NS.equals(uri)) {
+
+            if (Constants.COMPOSITE.equals(name)) {
+                composite = factory.createComposite();
+                composite.setName(getQName(attr, Constants.NAME));
+                composite.setAutowire(getBoolean(attr, Constants.AUTOWIRE));
+                composite.setLocal(getBoolean(attr, Constants.LOCAL));
+                composite.setConstrainingType(getConstrainingType(attr));
+
+            } else if (Constants.SERVICE.equals(name)) {
+                if (component != null) {
+                    componentService = factory.createComponentService();
+                    component.getServices().add(componentService);
+                    componentService.setName(getString(attr, Constants.NAME));
+                } else {
+                    compositeService = factory.createCompositeService();
+                    composite.getServices().add(compositeService);
+                    compositeService.setName(getString(attr, Constants.NAME));
+
+                    ComponentService promoted = factory.createComponentService();
+                	promoted.setUndefined(true);
+                	promoted.setName(getString(attr, Constants.PROMOTE));
+                	compositeService.setPromotedService(promoted);
+                }
+
+            } else if (Constants.REFERENCE.equals(name)) {
+                if (component != null) {
+                    componentReference = factory.createComponentReference();
+                    component.getReferences().add(componentReference);
+                    componentReference.setName(getString(attr, Constants.NAME));
+
+                    //TODO support multivalued attribute
+                	ComponentService target = factory.createComponentService();
+                	target.setUndefined(true);
+                	target.setName(getString(attr, Constants.TARGET));
+                	componentReference.getTargets().add(target);
+                    
+                } else {
+                    compositeReference = factory.createCompositeReference();
+                    composite.getReferences().add(compositeReference);
+                    compositeReference.setName(getString(attr, Constants.NAME));
+
+                    //TODO support multivalued attribute
+                    ComponentReference promoted = factory.createComponentReference();
+                	promoted.setUndefined(true);
+                	promoted.setName(getString(attr, Constants.PROMOTE));
+                	compositeReference.getPromotedReferences().add(promoted);
+                }
+
+            } else if (Constants.PROPERTY.equals(name)) {
+                if (component != null) {
+                    componentProperty = factory.createComponentProperty();
+                    component.getProperties().add(componentProperty);
+                    readProperty(componentProperty, attr);
+                } else {
+                    property = factory.createProperty();
+                    composite.getProperties().add(property);
+                    readProperty(property, attr);
+                }
+
+            } else if (Constants.COMPONENT.equals(name)) {
+                component = factory.createComponent();
+                composite.getComponents().add(component);
+                component.setName(getString(attr, Constants.NAME));
+                component.setConstrainingType(getConstrainingType(attr));
+                
+            } else if (Constants.WIRE.equals(name)) {
+            	wire = factory.createWire();
+                composite.getWires().add(wire);
+            	
+            	ComponentReference source = factory.createComponentReference();
+            	source.setUndefined(true);
+            	source.setName(getString(attr, Constants.SOURCE));
+            	wire.setSource(source);
+            	
+            	ComponentService target = factory.createComponentService();
+            	target.setUndefined(true);
+            	target.setName(getString(attr, Constants.TARGET));
+            	wire.setTarget(target);
+            	
+	        } else if (Constants.CALLBACK.equals(name)) {
+                callback = factory.createCallback();
+	            if (componentReference != null) {
+	            	componentReference.setCallback(callback);
+	            } else if (compositeReference != null) {
+	            	compositeReference.setCallback(callback);
+	            } else if (componentService != null) {
+	            	componentService.setCallback(callback);
+	            } else if (compositeService != null) {
+	            	compositeService.setCallback(callback);
+	            }
+	        }
+        }
+    }
+
+    public void endElement(String uri, String name, String qname) throws SAXException {
+        if (Constants.SERVICE.equals(name)) {
+            componentService = null;
+            compositeService = null;
+        } else if (Constants.REFERENCE.equals(name)) {
+            componentReference = null;
+            compositeReference = null;
+        } else if (Constants.PROPERTY.equals(name)) {
+            componentProperty = null;
+            property = null;
+        } else if (Constants.COMPONENT.equals(name)) {
+            component = null;
+        } else if (Constants.WIRE.equals(name)) {
+            wire= null;
+        } else if (Constants.CALLBACK.equals(name)) {
+        	callback = null;
+        }
+    }
+
+	public Composite getComposite() {
+		return composite;
+	}
+
+}

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/CompositeHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/CompositeHandler.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/ConstrainingTypeHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/ConstrainingTypeHandler.java?view=auto&rev=521022
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/ConstrainingTypeHandler.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/ConstrainingTypeHandler.java Wed Mar 21 15:12:08 2007
@@ -0,0 +1,93 @@
+/*
+ * 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.scdl.reader;
+
+import org.apache.tuscany.assembly.model.AbstractProperty;
+import org.apache.tuscany.assembly.model.AbstractReference;
+import org.apache.tuscany.assembly.model.AbstractService;
+import org.apache.tuscany.assembly.model.AssemblyFactory;
+import org.apache.tuscany.assembly.model.ConstrainingType;
+import org.apache.tuscany.scdl.Constants;
+import org.apache.tuscany.scdl.reader.util.BaseHandler;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+/**
+ * A test handler to test the usability of the assembly model API when loading SCDL
+ * 
+ * @version $Rev$ $Date$
+ */
+public class ConstrainingTypeHandler extends BaseHandler implements ContentHandler {
+
+    private ConstrainingType constrainingType;
+    private AbstractService abstractService;
+    private AbstractReference abstractReference;
+    private AbstractProperty abstractProperty;
+
+    public ConstrainingTypeHandler(AssemblyFactory factory, XMLReader reader) {
+        super(factory, reader);
+    }
+
+    public void startElement(String uri, String name, String qname, Attributes attr) throws SAXException {
+        if (Constants.SCA10_NS.equals(uri)) {
+
+            if (Constants.CONSTRAINING_TYPE.equals(name)) {
+                constrainingType = factory.createConstrainingType();
+                constrainingType.setName(getQName(attr, Constants.NAME));
+
+            } else if (Constants.SERVICE.equals(name)) {
+                abstractService = factory.createAbstractService();
+                constrainingType.getServices().add(abstractService);
+                abstractService.setName(getString(attr, Constants.NAME));
+
+            } else if (Constants.REFERENCE.equals(name)) {
+                abstractReference = factory.createAbstractReference();
+                constrainingType.getReferences().add(abstractReference);
+                abstractReference.setName(getString(attr, Constants.NAME));
+
+            } else if (Constants.PROPERTY.equals(name)) {
+                abstractProperty = factory.createAbstractProperty();
+                constrainingType.getProperties().add(abstractProperty);
+                readAbstractProperty(abstractProperty, attr);
+            }
+        }
+    }
+
+    public void endElement(String uri, String name, String qName) throws SAXException {
+        if (Constants.SCA10_NS.equals(uri)) {
+            if (Constants.SERVICE.equals(name)) {
+                abstractService = null;
+
+            } else if (Constants.REFERENCE.equals(name)) {
+                abstractReference = null;
+
+            } else if (Constants.PROPERTY.equals(name)) {
+                abstractProperty = null;
+            }
+        }
+    }
+
+	public ConstrainingType getConstrainingType() {
+		return constrainingType;
+	}
+
+}

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/ConstrainingTypeHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/ConstrainingTypeHandler.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/util/BaseHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/util/BaseHandler.java?view=auto&rev=521022
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/util/BaseHandler.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/util/BaseHandler.java Wed Mar 21 15:12:08 2007
@@ -0,0 +1,112 @@
+/*
+ * 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.scdl.reader.util;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.assembly.model.AbstractProperty;
+import org.apache.tuscany.assembly.model.AssemblyFactory;
+import org.apache.tuscany.assembly.model.ConstrainingType;
+import org.apache.tuscany.assembly.model.Property;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * A test handler to test the usability of the assembly model API when loading SCDL
+ * 
+ * @version $Rev$ $Date$
+ */
+public abstract class BaseHandler extends DefaultHandler implements ContentHandler {
+
+    protected final static String sca10 = "http://www.osoa.org/xmlns/sca/1.0";
+
+    protected NamespaceStack nsStack = new NamespaceStack();
+    protected AssemblyFactory factory;
+    protected XMLReader reader;
+
+    public BaseHandler(AssemblyFactory factory, XMLReader reader) {
+        this.factory = factory;
+        this.reader = reader;
+    }
+
+    protected String getString(Attributes attr, String name) {
+        return attr.getValue(name);
+    }
+
+    protected QName getQName(Attributes attr, String name) {
+        String qName = attr.getValue(name);
+        int index = qName.indexOf(':');
+        String prefix = index == -1 ? "" : qName.substring(0, index);
+        String localName = index == -1 ? qName : qName.substring(index);
+        String ns = nsStack.getNamespaceURI(prefix);
+        if (ns == null) {
+            ns = "";
+        }
+        return new QName(ns, localName, prefix);
+    }
+
+    protected boolean getBoolean(Attributes attr, String name) {
+        return Boolean.valueOf(attr.getValue(name));
+    }
+
+    protected ConstrainingType getConstrainingType(Attributes attr) {
+        String constrainingTypeName = attr.getValue(sca10, "constrainingType");
+        if (constrainingTypeName != null) {
+            ConstrainingType constrainingType = factory.createConstrainingType();
+            constrainingType.setName(new QName(constrainingTypeName));
+            constrainingType.setUndefined(true);
+            return constrainingType;
+        } else {
+            return null;
+        }
+    }
+
+    protected void readAbstractProperty(AbstractProperty prop, Attributes attr) {
+        prop.setName(getString(attr, "name"));
+        prop.setMany(getBoolean(attr, "many"));
+        prop.setMustSupply(getBoolean(attr, "mustSupply"));
+        String xsdElement = getString(attr, "element");
+        if (xsdElement != null) {
+            prop.setXSDElement(new QName(xsdElement));
+        }
+        String xsdType = getString(attr, "type");
+        if (xsdType != null) {
+            prop.setXSDType(new QName(xsdType));
+        }
+        // TODO handle default value
+    }
+
+    protected void readProperty(Property prop, Attributes attr) {
+        readAbstractProperty(prop, attr);
+        // TODO handle property value
+    }
+
+    public void endPrefixMapping(String prefix) throws SAXException {
+        nsStack.endPrefixMapping(prefix);
+    }
+
+    public void startPrefixMapping(String prefix, String uri) throws SAXException {
+        nsStack.startPrefixMapping(prefix, uri);
+    }
+
+}

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/util/BaseHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/util/BaseHandler.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/util/NamespaceStack.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/util/NamespaceStack.java?view=auto&rev=521022
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/util/NamespaceStack.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/util/NamespaceStack.java Wed Mar 21 15:12:08 2007
@@ -0,0 +1,225 @@
+/*
+ * 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.scdl.reader.util;
+
+import java.util.ArrayList;
+import java.util.EmptyStackException;
+
+public class NamespaceStack {
+    private FastStack<String> prefixStack = new FastStack<String>();
+
+    // Keep two arraylists for the prefixes and namespaces. They should be in
+    // sync
+    // since the index of the entry will be used to relate them
+    // use the minimum initial capacity to let things handle memory better
+
+    private FastStack<String> uriStack = new FastStack<String>();
+
+    public String getNamespaceURI(String prefix) {
+        int index = prefixStack.search(prefix);
+        return index == -1 ? null : (String)uriStack.get(index);
+    }
+
+    public String getPrefix(String uri) {
+        int index = uriStack.search(uri);
+        if (index != -1) {
+            return (String)prefixStack.get(index);
+        }
+        return null;
+    }
+
+    /**
+     * Pop a namespace
+     */
+    public void endPrefixMapping(String prefix) {
+        int index = prefixStack.search(prefix);
+        if (index != -1) {
+            prefixStack.remove(index);
+            uriStack.remove(index);
+        }
+    }
+
+    /**
+     * Register a namespace in this context
+     * 
+     * @param prefix
+     * @param uri
+     */
+    public void startPrefixMapping(String prefix, String uri) {
+        prefixStack.push(prefix);
+        uriStack.push(uri);
+
+    }
+
+    /**
+     * An implementation of the {@link java.util.Stack} API that is based on an <code>ArrayList</code> instead of a
+     * <code>Vector</code>, so it is not synchronized to protect against multi-threaded access. The implementation is
+     * therefore operates faster in environments where you do not need to worry about multiple thread contention.
+     * <p>
+     * The removal order of an <code>ArrayStack</code> is based on insertion order: The most recently added element is
+     * removed first. The iteration order is <i>not</i> the same as the removal order. The iterator returns elements
+     * from the bottom up, whereas the {@link #remove()} method removes them from the top down.
+     * <p>
+     * Unlike <code>Stack</code>, <code>ArrayStack</code> accepts null entries.
+     */
+    private static class FastStack<T> extends ArrayList<T> {
+
+        /** Ensure serialization compatibility */
+        private static final long serialVersionUID = 2130079159931574599L;
+
+        /**
+         * Constructs a new empty <code>ArrayStack</code>. The initial size is controlled by <code>ArrayList</code>
+         * and is currently 10.
+         */
+        public FastStack() {
+            super();
+        }
+
+        /**
+         * Constructs a new empty <code>ArrayStack</code> with an initial size.
+         * 
+         * @param initialSize the initial size to use
+         * @throws IllegalArgumentException if the specified initial size is negative
+         */
+        public FastStack(int initialSize) {
+            super(initialSize);
+        }
+
+        /**
+         * Return <code>true</code> if this stack is currently empty.
+         * <p>
+         * This method exists for compatibility with <code>java.util.Stack</code>. New users of this class should use
+         * <code>isEmpty</code> instead.
+         * 
+         * @return true if the stack is currently empty
+         */
+        public boolean empty() {
+            return isEmpty();
+        }
+
+        /**
+         * Returns the top item off of this stack without removing it.
+         * 
+         * @return the top item on the stack
+         * @throws EmptyStackException if the stack is empty
+         */
+        public T peek() throws EmptyStackException {
+            int n = size();
+            if (n <= 0) {
+                throw new EmptyStackException();
+            } else {
+                return get(n - 1);
+            }
+        }
+
+        /**
+         * Returns the n'th item down (zero-relative) from the top of this stack without removing it.
+         * 
+         * @param n the number of items down to go
+         * @return the n'th item on the stack, zero relative
+         * @throws EmptyStackException if there are not enough items on the stack to satisfy this request
+         */
+        public T peek(int n) throws EmptyStackException {
+            int m = (size() - n) - 1;
+            if (m < 0) {
+                throw new EmptyStackException();
+            } else {
+                return get(m);
+            }
+        }
+
+        /**
+         * Pops the top item off of this stack and return it.
+         * 
+         * @return the top item on the stack
+         * @throws EmptyStackException if the stack is empty
+         */
+        public T pop() throws EmptyStackException {
+            int n = size();
+            if (n <= 0) {
+                throw new EmptyStackException();
+            } else {
+                return remove(n - 1);
+            }
+        }
+
+        /**
+         * Pushes a new item onto the top of this stack. The pushed item is also returned. This is equivalent to calling
+         * <code>add</code>.
+         * 
+         * @param item the item to be added
+         * @return the item just pushed
+         */
+        public Object push(T item) {
+            add(item);
+            return item;
+        }
+
+        /**
+         * Returns the one-based position of the distance from the top that the specified object exists on this stack,
+         * where the top-most element is considered to be at distance <code>1</code>. If the object is not present on
+         * the stack, return <code>-1</code> instead. The <code>equals()</code> method is used to compare to the
+         * items in this stack.
+         * 
+         * @param object the object to be searched for
+         * @return index of the stack for the object, or -1 if not found
+         */
+        public int search(T object) {
+            int i = size() - 1; // Current index
+            while (i >= 0) {
+                T current = get(i);
+                if ((object == null && current == null) || (object != null && object.equals(current))) {
+                    return i;
+                }
+                i--;
+            }
+            return -1;
+        }
+
+        /**
+         * Returns the element on the top of the stack.
+         * 
+         * @return the element on the top of the stack
+         * @throws EmptyStackException if the stack is empty
+         */
+        public T get() {
+            int size = size();
+            if (size == 0) {
+                throw new EmptyStackException();
+            }
+            return get(size - 1);
+        }
+
+        /**
+         * Removes the element on the top of the stack.
+         * 
+         * @return the removed element
+         * @throws EmptyStackException if the stack is empty
+         */
+        public T remove() {
+            int size = size();
+            if (size == 0) {
+                throw new EmptyStackException();
+            }
+            return remove(size - 1);
+        }
+
+    }
+
+}

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/util/NamespaceStack.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/reader/util/NamespaceStack.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/ComponentTypeWriter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/ComponentTypeWriter.java?view=auto&rev=521022
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/ComponentTypeWriter.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/ComponentTypeWriter.java Wed Mar 21 15:12:08 2007
@@ -0,0 +1,77 @@
+/*
+ * 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.scdl.writer;
+
+import org.apache.tuscany.assembly.model.ComponentType;
+import org.apache.tuscany.assembly.model.Property;
+import org.apache.tuscany.assembly.model.Reference;
+import org.apache.tuscany.assembly.model.Service;
+import org.apache.tuscany.scdl.writer.util.Attr;
+import org.apache.tuscany.scdl.writer.util.BaseWriter;
+import org.xml.sax.SAXException;
+
+/**
+ * A test handler to test the usability of the assembly model API when writing SCDL
+ * 
+ * @version $Rev$ $Date$
+ */
+public class ComponentTypeWriter extends BaseWriter {
+
+    private ComponentType componentType;
+
+    public ComponentTypeWriter(ComponentType componentType) {
+        this.componentType = componentType;
+    }
+    
+    protected void write() throws SAXException {
+    	
+    	start("componentType", new Attr("constrainingType", getConstrainingType(componentType)));
+    	
+    	for (Service service: componentType.getServices()) {
+    		start("service", new Attr("name", service.getName()));
+    		if (service.getCallback() != null) {
+    			start("callback");
+    			end("callback");
+    		}
+    		end("service");
+    	}
+    	
+    	for (Reference reference: componentType.getReferences()) {
+    		//TODO handle multivalued target attribute
+    		String target = reference.getTargets().isEmpty()? null: reference.getTargets().get(0).getName();
+    		start("reference", 
+    			new Attr("name", reference.getName()),
+    			new Attr("target", target));
+    		if (reference.getCallback() != null) {
+    			start("callback");
+    			end("callback");
+    		}
+    		end("reference");
+    	}
+    	
+    	for (Property property: componentType.getProperties()) {
+    		start("property", new Attr("name", property.getName()));
+    		end("property");
+    	}
+    	
+    	end("componentType");
+    }
+    
+}

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/ComponentTypeWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/ComponentTypeWriter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/CompositeWriter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/CompositeWriter.java?view=auto&rev=521022
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/CompositeWriter.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/CompositeWriter.java Wed Mar 21 15:12:08 2007
@@ -0,0 +1,128 @@
+/*
+ * 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.scdl.writer;
+
+import org.apache.tuscany.assembly.model.Component;
+import org.apache.tuscany.assembly.model.ComponentProperty;
+import org.apache.tuscany.assembly.model.ComponentReference;
+import org.apache.tuscany.assembly.model.ComponentService;
+import org.apache.tuscany.assembly.model.Composite;
+import org.apache.tuscany.assembly.model.CompositeReference;
+import org.apache.tuscany.assembly.model.CompositeService;
+import org.apache.tuscany.assembly.model.Property;
+import org.apache.tuscany.assembly.model.Reference;
+import org.apache.tuscany.assembly.model.Service;
+import org.apache.tuscany.scdl.writer.util.Attr;
+import org.apache.tuscany.scdl.writer.util.BaseWriter;
+import org.xml.sax.SAXException;
+
+/**
+ * A test handler to test the usability of the assembly model API when writing SCDL
+ * 
+ * @version $Rev$ $Date$
+ */
+public class CompositeWriter extends BaseWriter {
+
+    private Composite composite;
+
+    public CompositeWriter(Composite composite) {
+        this.composite = composite;
+    }
+    
+    protected void write() throws SAXException {
+    	
+    	start("composite", new Attr("constrainingType", getConstrainingType(composite)));
+    	
+    	for (Service service: composite.getServices()) {
+    		CompositeService compositeService = (CompositeService)service;
+    		ComponentService promotedService = compositeService.getPromotedService();
+    		String promote = promotedService != null? promotedService.getName():null;
+    		start("service",
+    			new Attr("name", service.getName()),
+    			new Attr("promote", promote));
+    		if (service.getCallback() != null) {
+    			start("callback");
+    			end("callback");
+    		}
+    		end("service");
+    	}
+    	
+    	for (Component component: composite.getComponents()) {
+    		start("component",
+    			new Attr("name", component.getName()));
+
+    		for (ComponentService service: component.getServices()) {
+        		start("service",
+        			new Attr("name", service.getName()));
+        		end("service");
+        		if (service.getCallback() != null) {
+        			start("callback");
+        			end("callback");
+        		}
+        	}
+    		
+        	for (ComponentReference reference: component.getReferences()) {
+        		//TODO handle multivalued target attribute
+        		String target = reference.getTargets().isEmpty()? null: reference.getTargets().get(0).getName();
+        		start("reference", 
+        			new Attr("name", reference.getName()),
+        			new Attr("target", target));
+        		if (reference.getCallback() != null) {
+        			start("callback");
+        			end("callback");
+        		}
+        		end("reference");
+        	}
+        	
+        	for (ComponentProperty property: component.getProperties()) {
+        		start("property", new Attr("name", property.getName()));
+        		end("property");
+        	}
+        	
+    		end("component");
+    	}
+    	
+    	for (Reference reference: composite.getReferences()) {
+    		//TODO handle multivalued promote attribute
+    		CompositeReference compositeReference = (CompositeReference)reference;
+    		String promote;
+    		if (!compositeReference.getPromotedReferences().isEmpty())
+        		promote = compositeReference.getPromotedReferences().get(0).getName();
+    		else
+    			promote = null;
+    		start("reference", 
+    			new Attr("name", reference.getName()),
+    			new Attr("promote", promote));
+    		if (reference.getCallback() != null) {
+    			start("callback");
+    			end("callback");
+    		}
+    		end("reference");
+    	}
+    	
+    	for (Property property: composite.getProperties()) {
+    		start("property", new Attr("name", property.getName()));
+    		end("property");
+    	}
+    	
+    	end("composite");
+    }
+    
+}

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/CompositeWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/CompositeWriter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/ConstrainingTypeWriter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/ConstrainingTypeWriter.java?view=auto&rev=521022
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/ConstrainingTypeWriter.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/ConstrainingTypeWriter.java Wed Mar 21 15:12:08 2007
@@ -0,0 +1,66 @@
+/*
+ * 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.scdl.writer;
+
+import org.apache.tuscany.assembly.model.AbstractProperty;
+import org.apache.tuscany.assembly.model.AbstractReference;
+import org.apache.tuscany.assembly.model.AbstractService;
+import org.apache.tuscany.assembly.model.ConstrainingType;
+import org.apache.tuscany.scdl.writer.util.Attr;
+import org.apache.tuscany.scdl.writer.util.BaseWriter;
+import org.xml.sax.SAXException;
+
+/**
+ * A test handler to test the usability of the assembly model API when writing SCDL
+ * 
+ * @version $Rev$ $Date$
+ */
+public class ConstrainingTypeWriter extends BaseWriter {
+
+    private ConstrainingType constrainingType;
+
+    public ConstrainingTypeWriter(ConstrainingType constrainingType) {
+        this.constrainingType = constrainingType;
+    }
+    
+    protected void write() throws SAXException {
+    	
+    	start("constrainingType");
+    	
+    	for (AbstractService service: constrainingType.getServices()) {
+    		start("service", new Attr("name", service.getName()));
+    		end("service");
+    	}
+    	
+    	for (AbstractReference reference: constrainingType.getReferences()) {
+    		//TODO handle multivalued target attribute
+    		start("reference", new Attr("name", reference.getName()));
+    		end("reference");
+    	}
+    	
+    	for (AbstractProperty property: constrainingType.getProperties()) {
+    		start("property", new Attr("name", property.getName()));
+    		end("property");
+    	}
+    	
+    	end("constrainingType");
+    }
+    
+}

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/ConstrainingTypeWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/ConstrainingTypeWriter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/util/Attr.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/util/Attr.java?view=auto&rev=521022
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/util/Attr.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/util/Attr.java Wed Mar 21 15:12:08 2007
@@ -0,0 +1,71 @@
+/*
+ * 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.scdl.writer.util;
+
+import javax.xml.namespace.QName;
+
+import org.xml.sax.helpers.AttributesImpl;
+
+public class Attr {
+	
+	String uri;
+	String name;
+	Object value;
+	
+	public Attr(String uri, String name, String value) {
+		this.uri = uri;
+		this.name = name;
+		this.value = value;
+	}
+
+	public Attr(String name, String value) {
+		this.name = name;
+		this.value = value;
+	}
+
+	public Attr(String uri, String name, boolean value) {
+		this.uri = uri;
+		this.name = name;
+		this.value = value;
+	}
+
+	public Attr(String name, boolean value) {
+		this.name = name;
+		this.value = value;
+	}
+	
+	public Attr(String uri, String name, QName value) {
+		this.uri = uri;
+		this.name = name;
+		this.value = value;
+	}
+
+	public Attr(String name, QName value) {
+		this.name = name;
+		this.value = value;
+	}
+	
+	void write(AttributesImpl attrs) {
+		if (value != null) {
+			attrs.addAttribute(uri, name, name, "CDATA", String.valueOf(value));
+		}
+	}
+	
+}

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/util/Attr.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/util/Attr.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/util/BaseWriter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/util/BaseWriter.java?view=auto&rev=521022
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/util/BaseWriter.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/util/BaseWriter.java Wed Mar 21 15:12:08 2007
@@ -0,0 +1,113 @@
+/*
+ * 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.scdl.writer.util;
+
+import java.io.IOException;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.assembly.model.AbstractProperty;
+import org.apache.tuscany.assembly.model.ComponentType;
+import org.apache.tuscany.assembly.model.ConstrainingType;
+import org.apache.tuscany.assembly.model.Property;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+import org.xml.sax.helpers.XMLFilterImpl;
+
+/**
+ * A test writer to test the usability of the assembly model API when writing SCDL
+ * 
+ * @version $Rev$ $Date$
+ */
+public abstract class BaseWriter extends XMLFilterImpl {
+
+    protected final static String sca10 = "http://www.osoa.org/xmlns/sca/1.0";
+    protected ContentHandler out;
+
+    /**
+     * This is where you write the logic to produce SCDL.
+     * @throws SAXException
+     */
+    abstract protected void write() throws SAXException;
+    
+    public void parse(InputSource input) throws SAXException, IOException {
+    	out.startDocument();
+    	write();
+    	out.endDocument();
+    }
+    
+    public void setContentHandler(ContentHandler handler) {
+    	super.setContentHandler(handler);
+    	out = handler;
+    }
+    
+    protected void start(String uri, String name, Attr... attrs) throws SAXException {
+    	out.startElement(uri, null, name, attributes(attrs));
+    }
+
+    protected void start(String name, Attr... attrs) throws SAXException {
+    	out.startElement(sca10, null, name, attributes(attrs));
+    }
+    
+    protected void end(String uri, String name) throws SAXException {
+    	out.endElement(uri, null, name);
+    }
+
+    protected void end(String name) throws SAXException {
+    	out.endElement(sca10, null, name);
+    }
+
+    protected Attributes attributes(Attr... attrs) {
+    	AttributesImpl attributes = new AttributesImpl();
+    	for (Attr attr: attrs) {
+    		if (attr != null)
+    			attr.write(attributes);
+    	}
+    	return attributes;
+    }
+
+    protected QName getConstrainingType(ComponentType componentType) {
+    	ConstrainingType constrainingType = componentType.getConstrainingType();
+    	if (constrainingType!=null)
+    		return constrainingType.getName();
+    	else
+    		return null;
+    }
+
+    protected Attributes abstractPropertyAttributes(AbstractProperty prop) {
+    	Attributes attributes = attributes(
+	        new Attr("name", prop.getName()),
+	        new Attr("many", prop.isMany()),
+	        new Attr("mustSupply", prop.isMustSupply()),
+	        new Attr("element", prop.getXSDElement()),
+	        new Attr("type", prop.getXSDType())
+    	);
+        // TODO handle default value
+    	return attributes;
+    }
+
+    protected Attributes propertyAttributes(Property prop) {
+        // TODO handle property value
+        return abstractPropertyAttributes(prop);
+    }
+}

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/util/BaseWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/main/java/org/apache/tuscany/scdl/writer/util/BaseWriter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/assembly/builder/BigBankBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/assembly/builder/BigBankBuilder.java?view=diff&rev=521022&r1=521021&r2=521022
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/assembly/builder/BigBankBuilder.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/assembly/builder/BigBankBuilder.java Wed Mar 21 15:12:08 2007
@@ -30,11 +30,11 @@
 			component("AccountServiceComponent").
 			implementedBy(AccountServiceImpl.class).
 			uses(
-				reference("accountDataService").definedBy(AccountDataService.class).wiredTo("AccountDataServiceComponent/AccountDataService"),
+				reference("accountDataService").typedBy(AccountDataService.class).wiredTo("AccountDataServiceComponent/AccountDataService"),
 				reference("stockQuoteService").promotedAs("StockQuoteService")
 			).
 			provides(
-				service("AccountDataService").definedBy(AccountService.class).promoted()
+				service("AccountDataService").typedBy(AccountService.class).promoted()
 			).
 			declares(
 				property("currency").ofType("string").configuredTo("USD")
@@ -43,7 +43,7 @@
 			component("AccountDataServiceComponent").
 			implementedBy(AccountDataServiceImpl.class).
 			provides(
-				service("AccountDataService").definedBy(AccountDataService.class)
+				service("AccountDataService").typedBy(AccountDataService.class)
 			)
 		);
 		

Modified: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/assembly/builder/BigBankBuilderTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/assembly/builder/BigBankBuilderTestCase.java?view=diff&rev=521022&r1=521021&r2=521022
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/assembly/builder/BigBankBuilderTestCase.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/assembly/builder/BigBankBuilderTestCase.java Wed Mar 21 15:12:08 2007
@@ -27,7 +27,7 @@
 import junit.framework.TestCase;
 
 import org.apache.tuscany.assembly.model.Composite;
-import org.apache.tuscany.assembly.writer.CompositeWriter;
+import org.apache.tuscany.scdl.writer.CompositeWriter;
 
 public class BigBankBuilderTestCase extends TestCase {
 	

Added: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/reader/ReadTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/reader/ReadTestCase.java?view=auto&rev=521022
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/reader/ReadTestCase.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/reader/ReadTestCase.java Wed Mar 21 15:12:08 2007
@@ -0,0 +1,96 @@
+/*
+ * 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.scdl.reader;
+
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.assembly.model.AssemblyFactory;
+import org.apache.tuscany.assembly.model.impl.AssemblyFactoryImpl;
+import org.apache.tuscany.assembly.util.PrintUtil;
+import org.apache.tuscany.scdl.reader.ComponentTypeHandler;
+import org.apache.tuscany.scdl.reader.CompositeHandler;
+import org.apache.tuscany.scdl.reader.ConstrainingTypeHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * Test the usability of the assembly model API when loading SCDL
+ * 
+ * @version $Rev$ $Date$
+ */
+public class ReadTestCase extends TestCase {
+
+    AssemblyFactory factory;
+    XMLReader reader;
+    
+    public void setUp() throws Exception {
+        factory = new AssemblyFactoryImpl();
+
+        reader = XMLReaderFactory.createXMLReader();
+        reader.setFeature("http://xml.org/sax/features/namespaces", true);
+        reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
+        
+    }
+
+    public void tearDown() throws Exception {
+        factory = null;
+        reader = null;
+    }
+
+    public void testReadComponentType() throws Exception {
+        InputStream is = getClass().getClassLoader().getResourceAsStream("CalculatorImpl.componentType");
+        ComponentTypeHandler handler = new ComponentTypeHandler(factory, reader);
+        reader.setContentHandler(handler);
+        reader.parse(new InputSource(is));
+        assertNotNull(handler.getComponentType());
+        
+        new PrintUtil(System.out).print(handler.getComponentType());
+    }
+
+    public void testReadConstrainingType() throws Exception {
+        InputStream is = getClass().getClassLoader().getResourceAsStream("CalculatorComponent.constrainingType");
+        ConstrainingTypeHandler handler = new ConstrainingTypeHandler(factory, reader);
+        reader.setContentHandler(handler);
+        reader.parse(new InputSource(is));
+        assertNotNull(handler.getConstrainingType());
+
+        new PrintUtil(System.out).print(handler.getConstrainingType());
+    }
+    
+    public static void main(String[] args) throws Exception {
+		ReadTestCase tc = new ReadTestCase();
+		tc.setUp();
+		tc.testReadComposite();
+	}
+
+    public void testReadComposite() throws Exception {
+        InputStream is = getClass().getClassLoader().getResourceAsStream("Calculator.composite");
+        CompositeHandler handler = new CompositeHandler(factory, reader);
+        reader.setContentHandler(handler);
+        reader.parse(new InputSource(is));
+        assertNotNull(handler.getComposite());
+
+        new PrintUtil(System.out).print(handler.getComposite());
+    }
+
+}

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/reader/ReadTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/reader/ReadTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/writer/WriteTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/writer/WriteTestCase.java?view=auto&rev=521022
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/writer/WriteTestCase.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/writer/WriteTestCase.java Wed Mar 21 15:12:08 2007
@@ -0,0 +1,116 @@
+/*
+ * 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.scdl.writer;
+
+import java.io.InputStream;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamResult;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.assembly.model.AssemblyFactory;
+import org.apache.tuscany.assembly.model.impl.AssemblyFactoryImpl;
+import org.apache.tuscany.scdl.reader.ComponentTypeHandler;
+import org.apache.tuscany.scdl.reader.CompositeHandler;
+import org.apache.tuscany.scdl.reader.ConstrainingTypeHandler;
+import org.apache.tuscany.scdl.writer.ComponentTypeWriter;
+import org.apache.tuscany.scdl.writer.CompositeWriter;
+import org.apache.tuscany.scdl.writer.ConstrainingTypeWriter;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * Test the usability of the assembly model API when loading SCDL
+ * 
+ * @version $Rev$ $Date$
+ */
+public class WriteTestCase extends TestCase {
+
+    AssemblyFactory factory;
+    XMLReader reader;
+    Transformer transformer;
+
+    public void setUp() throws Exception {
+        factory = new AssemblyFactoryImpl();
+
+        reader = XMLReaderFactory.createXMLReader();
+        reader.setFeature("http://xml.org/sax/features/namespaces", true);
+        reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
+        
+        transformer = TransformerFactory.newInstance().newTransformer();
+        transformer.setOutputProperty("indent", "yes");
+    }
+
+    public void tearDown() throws Exception {
+        factory = null;
+        reader = null;
+        transformer = null;
+    }
+    
+    public static void main(String[] args) throws Exception {
+    	WriteTestCase tc = new WriteTestCase();
+    	tc.setUp();
+		tc.testWriteComponentType();
+	}
+
+    public void testWriteComponentType() throws Exception {
+        InputStream is = getClass().getClassLoader().getResourceAsStream("CalculatorImpl.componentType");
+        ComponentTypeHandler handler = new ComponentTypeHandler(factory, reader);
+        reader.setContentHandler(handler);
+        reader.parse(new InputSource(is));
+        assertNotNull(handler.getComponentType());
+
+        ComponentTypeWriter writer = new ComponentTypeWriter(handler.getComponentType());
+        System.out.println();
+        transformer.transform(new SAXSource(writer, null), new StreamResult(System.out));
+        System.out.println();
+    }
+
+    public void testWriteComposite() throws Exception {
+        InputStream is = getClass().getClassLoader().getResourceAsStream("Calculator.composite");
+        CompositeHandler handler = new CompositeHandler(factory, reader);
+        reader.setContentHandler(handler);
+        reader.parse(new InputSource(is));
+        assertNotNull(handler.getComposite());
+
+        CompositeWriter writer = new CompositeWriter(handler.getComposite());
+        System.out.println();
+        transformer.transform(new SAXSource(writer, null), new StreamResult(System.out));
+        System.out.println();
+    }
+
+    public void testWriteConstrainingType() throws Exception {
+        InputStream is = getClass().getClassLoader().getResourceAsStream("CalculatorComponent.constrainingType");
+        ConstrainingTypeHandler handler = new ConstrainingTypeHandler(factory, reader);
+        reader.setContentHandler(handler);
+        reader.parse(new InputSource(is));
+        assertNotNull(handler.getConstrainingType());
+
+        ConstrainingTypeWriter writer = new ConstrainingTypeWriter(handler.getConstrainingType());
+        System.out.println();
+        transformer.transform(new SAXSource(writer, null), new StreamResult(System.out));
+        System.out.println();
+    }
+
+}

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/writer/WriteTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/writer/WriteTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/xml/BuildCompositeXMLTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/xml/BuildCompositeXMLTestCase.java?view=auto&rev=521022
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/xml/BuildCompositeXMLTestCase.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/xml/BuildCompositeXMLTestCase.java Wed Mar 21 15:12:08 2007
@@ -0,0 +1,73 @@
+/*
+ * 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.scdl.xml;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.tuscany.scdl.xml.util.Attr;
+import org.apache.tuscany.scdl.xml.util.Element;
+import org.apache.tuscany.scdl.xml.util.ElementWriter;
+
+import junit.framework.TestCase;
+
+public class BuildCompositeXMLTestCase extends TestCase {
+	
+	public void testBuildComposite() throws Exception {
+		
+		Element element = new Element("http://www.osoa.org/xmlns/sca/1.0", "composite",
+				
+			new Element("service",
+				new Attr("name", "AccountService"),
+				new Attr("promote", "AccountServiceComponent/AccountService")),
+				
+			new Element("component",
+				new Attr("name", "AccountServiceComponent"),
+				new Element("service",
+					new Attr("name", "AccountService"),
+					new Element("interface.java",
+						new Attr("interface", "bigbank.account.AccountService")
+					)
+				),
+				new Element("reference",
+					new Attr("name", "stockQuoteService"),
+					new Element("interface.java",
+						new Attr("interface", "bigbank.stockquote.StockQuoteService")
+					)
+				),
+				new Element("implementation.java",
+					new Attr("class", "bigbank.account.AccountServiceImpl")
+				)
+			)
+		);
+		
+		ElementWriter writer = new ElementWriter(element);
+		
+        Transformer transformer = TransformerFactory.newInstance().newTransformer();
+        transformer.setOutputProperty("indent", "yes");
+        System.out.println();
+        transformer.transform(new SAXSource(writer, null), new StreamResult(System.out));
+        System.out.println();
+		
+	}
+
+}

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/xml/BuildCompositeXMLTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/sebastien/java/sca/assembly-scdl/src/test/java/org/apache/tuscany/scdl/xml/BuildCompositeXMLTestCase.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