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

svn commit: r525654 - in /incubator/tuscany/java/sca/modules/assembly-xml/src: main/java/org/apache/tuscany/assembly/xml/ main/java/org/apache/tuscany/assembly/xml/impl/ test/java/org/apache/tuscany/assembly/xml/

Author: jsdelfino
Date: Wed Apr  4 17:28:19 2007
New Revision: 525654

URL: http://svn.apache.org/viewvc?view=rev&rev=525654
Log:
Ported the assembly model readers to the contribution service ArtifactProcessor interface.

Added:
    incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/BaseArtifactProcessor.java   (with props)
    incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ComponentTypeProcessor.java   (with props)
    incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/CompositeProcessor.java   (with props)
    incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ConstrainingTypeProcessor.java   (with props)
Removed:
    incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/InvalidConfigurationException.java
    incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/LoaderException.java
    incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/UnrecognizedElementException.java
    incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/BaseLoader.java
    incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ComponentTypeLoader.java
    incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/CompositeLoader.java
    incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ConstrainingTypeLoader.java
    incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/LoaderRegistryImpl.java
Modified:
    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/ReadTestCase.java
    incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/StAXPerfTest.java

Added: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/BaseArtifactProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/BaseArtifactProcessor.java?view=auto&rev=525654
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/BaseArtifactProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/BaseArtifactProcessor.java Wed Apr  4 17:28:19 2007
@@ -0,0 +1,274 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.assembly.xml.impl;
+
+import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
+import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.assembly.AbstractProperty;
+import org.apache.tuscany.assembly.AbstractReference;
+import org.apache.tuscany.assembly.AssemblyFactory;
+import org.apache.tuscany.assembly.ConstrainingType;
+import org.apache.tuscany.assembly.Multiplicity;
+import org.apache.tuscany.assembly.Property;
+import org.apache.tuscany.assembly.xml.Constants;
+import org.apache.tuscany.idl.Operation;
+import org.apache.tuscany.policy.Intent;
+import org.apache.tuscany.policy.IntentAttachPoint;
+import org.apache.tuscany.policy.PolicyFactory;
+import org.apache.tuscany.policy.PolicySet;
+import org.apache.tuscany.policy.PolicySetAttachPoint;
+import org.apache.tuscany.services.spi.contribution.ContributionReadException;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * A base class with utility methods for the other artifact processors in this module. 
+ * 
+ * @version $Rev$ $Date$
+ */
+abstract class BaseArtifactProcessor implements Constants {
+
+    private AssemblyFactory factory;
+    private PolicyFactory policyFactory;
+
+    BaseArtifactProcessor() {
+    }
+
+    BaseArtifactProcessor(AssemblyFactory factory, PolicyFactory policyFactory) {
+        this.factory = factory;
+        this.policyFactory = policyFactory;
+    }
+
+    protected String getString(XMLStreamReader reader, String name) {
+        return reader.getAttributeValue(null, name);
+    }
+
+    protected QName getQName(XMLStreamReader reader, String name) {
+        String qname = reader.getAttributeValue(null, name);
+        return getQNameValue(reader, qname);
+    }
+
+    /**
+     * Get the value of xsi:type attribute
+     * 
+     * @param reader The XML stream reader
+     * @return The QName of the type, if the attribute is not present, null is
+     *         returned.
+     */
+    protected QName getXSIType(XMLStreamReader reader) {
+        String qname = reader.getAttributeValue(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "type");
+        return getQNameValue(reader, qname);
+    }
+
+    protected QName getQNameValue(XMLStreamReader reader, String value) {
+        if (value != null) {
+            int index = value.indexOf(':');
+            String prefix = index == -1 ? "" : value.substring(0, index);
+            String localName = index == -1 ? value : value.substring(index + 1);
+            String ns = reader.getNamespaceContext().getNamespaceURI(prefix);
+            if (ns == null) {
+                ns = "";
+            }
+            return new QName(ns, localName, prefix);
+        } else {
+            return null;
+        }
+    }
+
+    protected boolean getBoolean(XMLStreamReader reader, String name) {
+        String value = reader.getAttributeValue(null, name);
+        return Boolean.valueOf(value);
+    }
+
+    protected List<QName> getQNames(XMLStreamReader reader, String name) {
+        String value = reader.getAttributeValue(null, name);
+        if (value != null) {
+            List<QName> qnames = new ArrayList<QName>();
+            for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+                qnames.add(getQName(reader, tokens.nextToken()));
+            }
+            return qnames;
+        } else {
+            return Collections.emptyList();
+        }
+    }
+
+    protected void readIntents(IntentAttachPoint attachPoint, XMLStreamReader reader) {
+        readIntents(attachPoint, null, reader);
+    }
+
+    protected void readIntents(IntentAttachPoint attachPoint, Operation operation, XMLStreamReader reader) {
+        String value = reader.getAttributeValue(null, Constants.REQUIRES);
+        if (value != null) {
+            List<Intent> requiredIntents = attachPoint.getRequiredIntents();
+            for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+                QName qname = getQNameValue(reader, tokens.nextToken());
+                Intent intent = policyFactory.createIntent();
+                intent.setName(qname);
+                if (operation != null) {
+                    intent.getOperations().add(operation);
+                }
+                requiredIntents.add(intent);
+            }
+        }
+    }
+
+    protected void readPolicies(PolicySetAttachPoint attachPoint, XMLStreamReader reader) {
+        readPolicies(attachPoint, null, reader);
+    }
+
+    protected void readMultiplicity(AbstractReference reference, XMLStreamReader reader) {
+        String value = reader.getAttributeValue(null, MULTIPLICITY);
+        if (ZERO_ONE.equals(value)) {
+            reference.setMultiplicity(Multiplicity.ZERO_ONE);
+        } else if (ONE_N.equals(value)) {
+            reference.setMultiplicity(Multiplicity.ONE_N);
+        } else if (ZERO_N.equals(value)) {
+            reference.setMultiplicity(Multiplicity.ZERO_N);
+        }
+    }
+
+    protected void readPolicies(PolicySetAttachPoint attachPoint, Operation operation, XMLStreamReader reader) {
+        readIntents(attachPoint, operation, reader);
+
+        String value = reader.getAttributeValue(null, Constants.POLICY_SETS);
+        if (value != null) {
+            List<PolicySet> policySets = attachPoint.getPolicySets();
+            for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+                QName qname = getQNameValue(reader, tokens.nextToken());
+                PolicySet policySet = policyFactory.createPolicySet();
+                policySet.setName(qname);
+                if (operation != null) {
+                    policySet.getOperations().add(operation);
+                }
+                policySets.add(policySet);
+            }
+        }
+    }
+
+    protected ConstrainingType getConstrainingType(XMLStreamReader reader) {
+        QName constrainingTypeName = getQName(reader, "constrainingType");
+        if (constrainingTypeName != null) {
+            ConstrainingType constrainingType = factory.createConstrainingType();
+            constrainingType.setName(constrainingTypeName);
+            constrainingType.setUnresolved(true);
+            return constrainingType;
+        } else {
+            return null;
+        }
+    }
+
+    protected void readAbstractProperty(AbstractProperty prop, XMLStreamReader reader)
+        throws XMLStreamException, ContributionReadException {
+        prop.setName(getString(reader, "name"));
+        prop.setMany(getBoolean(reader, "many"));
+        prop.setMustSupply(getBoolean(reader, "mustSupply"));
+        prop.setXSDElement(getQName(reader, "element"));
+        prop.setXSDType(getQName(reader, "type"));
+        Node value = readPropertyValue(reader, prop.getXSDType());
+        prop.setDefaultValue(value);
+    }
+
+    protected void readProperty(Property prop, XMLStreamReader reader)
+        throws XMLStreamException, ContributionReadException {
+        readAbstractProperty(prop, reader);
+    }
+
+    protected boolean nextChildElement(XMLStreamReader reader) throws XMLStreamException {
+        while (reader.hasNext()) {
+            int event = reader.next();
+            if (event == END_ELEMENT) {
+                return false;
+            }
+            if (event == START_ELEMENT) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Advance the stream to the next END_ELEMENT event skipping any nested
+     * content.
+     * 
+     * @param reader the reader to advance
+     * @throws XMLStreamException if there was a problem reading the stream
+     */
+    protected void skipToEndElement(XMLStreamReader reader) throws XMLStreamException {
+        int depth = 0;
+        while (reader.hasNext()) {
+            int event = reader.next();
+            if (event == XMLStreamConstants.START_ELEMENT) {
+                depth++;
+            } else if (event == XMLStreamConstants.END_ELEMENT) {
+                if (depth == 0) {
+                    return;
+                }
+                depth--;
+            }
+        }
+    }
+
+    public static Document readPropertyValue(XMLStreamReader reader, QName type)
+        throws XMLStreamException, ContributionReadException {
+        Document doc = DOMUtil.newDocument();
+
+        // root element has no namespace and local name "value"
+        Element root = doc.createElementNS(null, "value");
+        if (type != null) {
+            Attr xsi = doc.createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, "xmlns:xsi");
+            xsi.setValue(W3C_XML_SCHEMA_INSTANCE_NS_URI);
+            root.setAttributeNodeNS(xsi);
+
+            String prefix = type.getPrefix();
+            if (prefix == null || prefix.length() == 0) {
+                prefix = "ns";
+            }
+
+            DOMUtil.declareNamespace(root, prefix, type.getNamespaceURI());
+
+            Attr xsiType = doc.createAttributeNS(W3C_XML_SCHEMA_INSTANCE_NS_URI, "xsi:type");
+            xsiType.setValue(prefix + ":" + type.getLocalPart());
+            root.setAttributeNodeNS(xsiType);
+        }
+        doc.appendChild(root);
+
+        DOMUtil.loadDOM(reader, root);
+        return doc;
+    }
+
+
+}

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

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

Added: 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=auto&rev=525654
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ComponentTypeProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ComponentTypeProcessor.java Wed Apr  4 17:28:19 2007
@@ -0,0 +1,220 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.assembly.xml.impl;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.assembly.AssemblyFactory;
+import org.apache.tuscany.assembly.Binding;
+import org.apache.tuscany.assembly.Callback;
+import org.apache.tuscany.assembly.ComponentService;
+import org.apache.tuscany.assembly.ComponentType;
+import org.apache.tuscany.assembly.Contract;
+import org.apache.tuscany.assembly.Property;
+import org.apache.tuscany.assembly.Reference;
+import org.apache.tuscany.assembly.Service;
+import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.assembly.xml.Constants;
+import org.apache.tuscany.idl.Interface;
+import org.apache.tuscany.idl.Operation;
+import org.apache.tuscany.policy.PolicyFactory;
+import org.apache.tuscany.policy.impl.DefaultPolicyFactory;
+import org.apache.tuscany.services.spi.contribution.ArtifactResolver;
+import org.apache.tuscany.services.spi.contribution.ContributionException;
+import org.apache.tuscany.services.spi.contribution.ContributionReadException;
+import org.apache.tuscany.services.spi.contribution.StAXArtifactProcessor;
+import org.apache.tuscany.services.spi.contribution.StAXArtifactProcessorRegistry;
+
+/**
+ * A componentType processor.
+ * 
+ * @version $Rev$ $Date$
+ */
+public class ComponentTypeProcessor extends BaseArtifactProcessor implements StAXArtifactProcessor<ComponentType> {
+    private AssemblyFactory factory;
+    private StAXArtifactProcessorRegistry registry;
+    
+    /**
+     * Constructs a new componentType processor.
+     * @param factory
+     * @param policyFactory
+     * @param registry
+     */
+    public ComponentTypeProcessor(AssemblyFactory factory, PolicyFactory policyFactory, StAXArtifactProcessorRegistry registry) {
+        super(factory, policyFactory);
+        this.factory = factory;
+        this.registry = registry;
+    }
+    
+    /**
+     * Constructs a new componentType processor.
+     * @param registry
+     */
+    public ComponentTypeProcessor(StAXArtifactProcessorRegistry registry) {
+        this(new DefaultAssemblyFactory(), new DefaultPolicyFactory(), registry);
+    }
+    
+    public ComponentType read(XMLStreamReader reader) throws ContributionReadException {
+        ComponentType componentType = null;
+        Service service = null;
+        Reference reference = null;
+        Contract contract = null;
+        Property property = null;
+        Callback callback = null;
+        QName name = null;
+        
+        try {
+    
+            // Read the componentType document
+            while (reader.hasNext()) {
+                int event = reader.getEventType();
+                switch (event) {
+                    case START_ELEMENT:
+                        name = reader.getName();
+    
+                        if (Constants.COMPONENT_TYPE_QNAME.equals(name)) {
+    
+                            // Read a <componentType>
+                            componentType = factory.createComponentType();
+                            componentType.setConstrainingType(getConstrainingType(reader));
+                            readPolicies(componentType, reader);
+    
+                        } else if (Constants.SERVICE_QNAME.equals(name)) {
+    
+                            // Read a <service>
+                            service = factory.createService();
+                            contract = service;
+                            service.setName(getString(reader, Constants.NAME));
+                            componentType.getServices().add(service);
+                            readPolicies(service, reader);
+    
+                        } else if (Constants.REFERENCE_QNAME.equals(name)) {
+    
+                            // Read a <reference>
+                            reference = factory.createReference();
+                            contract = reference;
+                            reference.setName(getString(reader, Constants.NAME));
+                            readMultiplicity(reference, reader);
+    
+                            // TODO support multivalued attribute
+                            ComponentService target = factory.createComponentService();
+                            target.setUnresolved(true);
+                            target.setName(getString(reader, Constants.TARGET));
+                            reference.getTargets().add(target);
+    
+                            componentType.getReferences().add(reference);
+                            readPolicies(reference, reader);
+    
+                        } else if (Constants.PROPERTY_QNAME.equals(name)) {
+    
+                            // Read a <property>
+                            property = factory.createProperty();
+                            readProperty(property, reader);
+                            componentType.getProperties().add(property);
+                            readPolicies(property, reader);
+    
+                        } else if (Constants.CALLBACK_QNAME.equals(name)) {
+    
+                            // Read a <callback>
+                            callback = factory.createCallback();
+                            contract.setCallback(callback);
+                            readPolicies(callback, reader);
+    
+                        } else if (OPERATION.equals(name)) {
+    
+                            // Read an <operation>
+                            Operation operation = factory.createOperation();
+                            operation.setName(getString(reader, NAME));
+                            operation.setUnresolved(true);
+                            if (callback != null) {
+                                readPolicies(callback, operation, reader);
+                            } else {
+                                readPolicies(contract, operation, reader);
+                            }
+                        } else {
+    
+                            // Read an extension element
+                            Object extension = registry.read(reader);
+                            if (extension != null) {
+                                if (extension instanceof Interface) {
+    
+                                    // <service><interface> and <reference><interface>
+                                    contract.setInterface((Interface)extension);
+    
+                                } else if (extension instanceof Binding) {
+    
+                                    // <service><binding> and <reference><binding>
+                                    contract.getBindings().add((Binding)extension);
+                                }
+                            }
+                        }
+                        break;
+    
+                    case END_ELEMENT:
+                        name = reader.getName();
+    
+                        // Clear current state when reading reaching end element
+                        if (SERVICE_QNAME.equals(name)) {
+                            service = null;
+                            contract = null;
+                        } else if (REFERENCE_QNAME.equals(name)) {
+                            reference = null;
+                            contract = null;
+                        } else if (PROPERTY_QNAME.equals(name)) {
+                            property = null;
+                        } else if (CALLBACK_QNAME.equals(name)) {
+                            callback = null;
+                        }
+                        break;
+                }
+                
+                // Read the next element
+                if (reader.hasNext()) {
+                    reader.next();
+                }
+            }
+            
+        } catch (XMLStreamException e) {
+            throw new ContributionReadException(e);
+        }
+        return componentType;
+    }
+    
+    public void resolve(ComponentType model, ArtifactResolver resolver) throws ContributionException {
+        //TODO resolve pointers to other models
+    }
+    
+    public void optimize(ComponentType model) throws ContributionException {
+        //TODO optimize the model 
+    }
+    
+    public QName getArtifactType() {
+        return COMPONENT_TYPE_QNAME;
+    }
+    
+    public Class<ComponentType> getModelType() {
+        return ComponentType.class;
+    }
+}

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

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

Added: 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=auto&rev=525654
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/CompositeProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/CompositeProcessor.java Wed Apr  4 17:28:19 2007
@@ -0,0 +1,336 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.assembly.xml.impl;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.assembly.AssemblyFactory;
+import org.apache.tuscany.assembly.Binding;
+import org.apache.tuscany.assembly.Callback;
+import org.apache.tuscany.assembly.Component;
+import org.apache.tuscany.assembly.ComponentProperty;
+import org.apache.tuscany.assembly.ComponentReference;
+import org.apache.tuscany.assembly.ComponentService;
+import org.apache.tuscany.assembly.Composite;
+import org.apache.tuscany.assembly.CompositeReference;
+import org.apache.tuscany.assembly.CompositeService;
+import org.apache.tuscany.assembly.Contract;
+import org.apache.tuscany.assembly.Implementation;
+import org.apache.tuscany.assembly.Property;
+import org.apache.tuscany.assembly.Wire;
+import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.idl.Interface;
+import org.apache.tuscany.idl.Operation;
+import org.apache.tuscany.policy.PolicyFactory;
+import org.apache.tuscany.policy.impl.DefaultPolicyFactory;
+import org.apache.tuscany.services.spi.contribution.ArtifactResolver;
+import org.apache.tuscany.services.spi.contribution.ContributionException;
+import org.apache.tuscany.services.spi.contribution.ContributionReadException;
+import org.apache.tuscany.services.spi.contribution.StAXArtifactProcessor;
+import org.apache.tuscany.services.spi.contribution.StAXArtifactProcessorRegistry;
+
+/**
+ * A composite processor.
+ * 
+ * @version $Rev$ $Date$
+ */
+public class CompositeProcessor extends BaseArtifactProcessor implements StAXArtifactProcessor<Composite> {
+    private AssemblyFactory factory;
+    private StAXArtifactProcessorRegistry registry;
+
+    /**
+     * Construct a new composite processor
+     * @param assemblyFactory
+     * @param policyFactory
+     * @param registry
+     */
+    public CompositeProcessor(AssemblyFactory factory, PolicyFactory policyFactory, StAXArtifactProcessorRegistry registry) {
+        super(factory, policyFactory);
+        this.factory = factory;
+        this.registry = registry;
+    }
+
+    /**
+     * Construct a new composite processor.
+     * @param registry
+     */
+    public CompositeProcessor(StAXArtifactProcessorRegistry registry) {
+        this(new DefaultAssemblyFactory(), new DefaultPolicyFactory(), registry);
+    }
+
+    public Composite read(XMLStreamReader reader) throws ContributionReadException {
+        Composite composite = null;
+        Composite include = null;
+        Component component = null;
+        Property property = null;
+        ComponentService componentService = null;
+        ComponentReference componentReference = null;
+        ComponentProperty componentProperty = null;
+        CompositeService compositeService = null;
+        CompositeReference compositeReference = null;
+        Contract contract = null;
+        Wire wire = null;
+        Callback callback = null;
+        QName name = null;
+        
+        try {
+    
+            // Read the composite document
+            while (reader.hasNext()) {
+                int event = reader.getEventType();
+                switch (event) {
+                    case START_ELEMENT:
+                        name = reader.getName();
+    
+                        if (COMPOSITE_QNAME.equals(name)) {
+    
+                            // Read a <composite>
+                            composite = factory.createComposite();
+                            composite.setName(getQName(reader, NAME));
+                            composite.setAutowire(getBoolean(reader, AUTOWIRE));
+                            composite.setLocal(getBoolean(reader, LOCAL));
+                            composite.setConstrainingType(getConstrainingType(reader));
+                            readPolicies(composite, reader);
+    
+                        } else if (INCLUDE_QNAME.equals(name)) {
+    
+                            // Read an <include>
+                            include = factory.createComposite();
+                            include.setUnresolved(true);
+                            composite.getIncludes().add(include);
+    
+                        } else if (SERVICE_QNAME.equals(name)) {
+                            if (component != null) {
+    
+                                // Read a <component><service>
+                                componentService = factory.createComponentService();
+                                contract = componentService;
+                                componentService.setName(getString(reader, NAME));
+                                component.getServices().add(componentService);
+                                readPolicies(contract, reader);
+                            } else {
+    
+                                // Read a <composite><service>
+                                compositeService = factory.createCompositeService();
+                                contract = compositeService;
+                                compositeService.setName(getString(reader, NAME));
+    
+                                ComponentService promoted = factory.createComponentService();
+                                promoted.setUnresolved(true);
+                                promoted.setName(getString(reader, PROMOTE));
+                                compositeService.setPromotedService(promoted);
+    
+                                composite.getServices().add(compositeService);
+                                readPolicies(contract, reader);
+                            }
+    
+                        } else if (REFERENCE_QNAME.equals(name)) {
+                            if (component != null) {
+    
+                                // Read a <component><reference>
+                                componentReference = factory.createComponentReference();
+                                contract = componentReference;
+                                componentReference.setName(getString(reader, NAME));
+                                readMultiplicity(componentReference, reader);
+    
+                                // TODO support multivalued attribute
+                                ComponentService target = factory.createComponentService();
+                                target.setUnresolved(true);
+                                target.setName(getString(reader, TARGET));
+                                componentReference.getTargets().add(target);
+    
+                                component.getReferences().add(componentReference);
+                                readPolicies(contract, reader);
+                            } else {
+    
+                                // Read a <composite><reference>
+                                compositeReference = factory.createCompositeReference();
+                                contract = compositeReference;
+                                compositeReference.setName(getString(reader, NAME));
+                                readMultiplicity(compositeReference, reader);
+    
+                                // TODO support multivalued attribute
+                                ComponentReference promoted = factory.createComponentReference();
+                                promoted.setUnresolved(true);
+                                promoted.setName(getString(reader, PROMOTE));
+                                compositeReference.getPromotedReferences().add(promoted);
+    
+                                composite.getReferences().add(compositeReference);
+                                readPolicies(contract, reader);
+                            }
+    
+                        } else if (PROPERTY_QNAME.equals(name)) {
+                            if (component != null) {
+    
+                                // Read a <component><property>
+                                componentProperty = factory.createComponentProperty();
+                                property = componentProperty;
+                                readPolicies(property, reader);
+                                readProperty(componentProperty, reader);
+                                component.getProperties().add(componentProperty);
+                            } else {
+    
+                                // Read a <composite><property>
+                                property = factory.createProperty();
+                                readPolicies(property, reader);
+                                readProperty(property, reader);
+                                composite.getProperties().add(property);
+                            }
+    
+                        } else if (COMPONENT_QNAME.equals(name)) {
+    
+                            // Read a <component>
+                            component = factory.createComponent();
+                            component.setName(getString(reader, NAME));
+                            component.setConstrainingType(getConstrainingType(reader));
+                            composite.getComponents().add(component);
+                            readPolicies(component, reader);
+    
+                        } else if (WIRE_QNAME.equals(name)) {
+    
+                            // Read a <wire>
+                            wire = factory.createWire();
+                            ComponentReference source = factory.createComponentReference();
+                            source.setUnresolved(true);
+                            source.setName(getString(reader, SOURCE));
+                            wire.setSource(source);
+    
+                            ComponentService target = factory.createComponentService();
+                            target.setUnresolved(true);
+                            target.setName(getString(reader, TARGET));
+                            wire.setTarget(target);
+    
+                            composite.getWires().add(wire);
+                            readPolicies(wire, reader);
+    
+                        } else if (CALLBACK_QNAME.equals(name)) {
+    
+                            // Read a <callback>
+                            callback = factory.createCallback();
+                            contract.setCallback(callback);
+                            readPolicies(callback, reader);
+    
+                        } else if (OPERATION.equals(name)) {
+    
+                            // Read an <operation>
+                            Operation operation = factory.createOperation();
+                            operation.setName(getString(reader, NAME));
+                            operation.setUnresolved(true);
+                            if (callback != null) {
+                                readPolicies(callback, operation, reader);
+                            } else {
+                                readPolicies(contract, operation, reader);
+                            }
+                        } else {
+    
+                            // Read an extension element
+                            Object extension = registry.read(reader);
+                            if (extension != null) {
+                                if (extension instanceof Interface) {
+    
+                                    // <service><interface> and
+                                    // <reference><interface>
+                                    contract.setInterface((Interface)extension);
+    
+                                } else if (extension instanceof Binding) {
+                                    // <service><binding> and <reference><binding>
+                                    contract.getBindings().add((Binding)extension);
+    
+                                } else if (extension instanceof Implementation) {
+    
+                                    // <component><implementation>
+                                    component.setImplementation((Implementation)extension);
+                                }
+                            }
+                        }
+                        break;
+    
+                    case XMLStreamConstants.CHARACTERS:
+    
+                        // Read an <include>qname</include>
+                        if (include != null && INCLUDE_QNAME.equals(name)) {
+                            include.setName(getQNameValue(reader, reader.getText().trim()));
+                        }
+    
+                        break;
+    
+                    case END_ELEMENT:
+                        name = reader.getName();
+    
+                        // Clear current state when reading reaching end element
+                        if (SERVICE_QNAME.equals(name)) {
+                            componentService = null;
+                            compositeService = null;
+                            contract = null;
+                        } else if (INCLUDE_QNAME.equals(name)) {
+                            include = null;
+                        } else if (REFERENCE_QNAME.equals(name)) {
+                            componentReference = null;
+                            compositeReference = null;
+                            contract = null;
+                        } else if (PROPERTY_QNAME.equals(name)) {
+                            componentProperty = null;
+                            property = null;
+                        } else if (COMPONENT_QNAME.equals(name)) {
+                            component = null;
+                        } else if (WIRE_QNAME.equals(name)) {
+                            wire = null;
+                        } else if (CALLBACK_QNAME.equals(name)) {
+                            callback = null;
+                        }
+                        break;
+                }
+    
+                // Read the next element
+                if (reader.hasNext()) {
+                    reader.next();
+                }
+            }
+            return composite;
+            
+        } catch (XMLStreamException e) {
+            throw new ContributionReadException(e);
+        }
+    }
+    
+    public void resolve(Composite model, ArtifactResolver resolver) throws ContributionException {
+        // TODO Auto-generated method stub
+        
+    }
+    
+    public void optimize(Composite model) throws ContributionException {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public QName getArtifactType() {
+        return COMPOSITE_QNAME;
+    }
+    
+    public Class<Composite> getModelType() {
+        return Composite.class;
+    }
+}

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

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

Added: 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=auto&rev=525654
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ConstrainingTypeProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ConstrainingTypeProcessor.java Wed Apr  4 17:28:19 2007
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.assembly.xml.impl;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.assembly.AbstractContract;
+import org.apache.tuscany.assembly.AbstractProperty;
+import org.apache.tuscany.assembly.AbstractReference;
+import org.apache.tuscany.assembly.AbstractService;
+import org.apache.tuscany.assembly.AssemblyFactory;
+import org.apache.tuscany.assembly.ConstrainingType;
+import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.assembly.xml.Constants;
+import org.apache.tuscany.idl.Interface;
+import org.apache.tuscany.idl.Operation;
+import org.apache.tuscany.policy.PolicyFactory;
+import org.apache.tuscany.policy.impl.DefaultPolicyFactory;
+import org.apache.tuscany.services.spi.contribution.ArtifactResolver;
+import org.apache.tuscany.services.spi.contribution.ContributionException;
+import org.apache.tuscany.services.spi.contribution.ContributionReadException;
+import org.apache.tuscany.services.spi.contribution.StAXArtifactProcessor;
+import org.apache.tuscany.services.spi.contribution.StAXArtifactProcessorRegistry;
+
+/**
+ * A contrainingType content handler.
+ * 
+ * @version $Rev$ $Date$
+ */
+public class ConstrainingTypeProcessor extends BaseArtifactProcessor implements StAXArtifactProcessor<ConstrainingType> {
+    private AssemblyFactory factory;
+    private StAXArtifactProcessorRegistry registry;
+
+    /**
+     * Construct a new constrainingType processor.
+     * @param factory
+     * @param policyFactory
+     * @param registry
+     */
+    public ConstrainingTypeProcessor(AssemblyFactory factory, PolicyFactory policyFactory, StAXArtifactProcessorRegistry registry) {
+        super(factory, policyFactory);
+        this.factory = factory;
+        this.registry = registry;
+    }
+
+    /**
+     * Construct a new constrainingType processor.
+     * @param registry
+     */
+    public ConstrainingTypeProcessor(StAXArtifactProcessorRegistry registry) {
+        this(new DefaultAssemblyFactory(), new DefaultPolicyFactory(), registry);
+        this.registry = registry;
+    }
+
+    public ConstrainingType read(XMLStreamReader reader) throws ContributionReadException {
+        ConstrainingType constrainingType = null;
+        AbstractService abstractService = null;
+        AbstractReference abstractReference = null;
+        AbstractProperty abstractProperty = null;
+        AbstractContract abstractContract = null;
+        QName name = null;
+        
+        try {
+            
+            // Read the constrainingType document
+            while (reader.hasNext()) {
+                int event = reader.getEventType();
+                switch (event) {
+    
+                    case START_ELEMENT:
+                        name = reader.getName();
+                        
+                        // Read a <constrainingType>
+                        if (Constants.CONSTRAINING_TYPE_QNAME.equals(name)) {
+                            constrainingType = factory.createConstrainingType();
+                            constrainingType.setName(getQName(reader, Constants.NAME));
+                            readIntents(constrainingType, reader);
+    
+                        } else if (Constants.SERVICE_QNAME.equals(name)) {
+                            
+                            // Read a <service>
+                            abstractService = factory.createAbstractService();
+                            abstractContract = abstractService;
+                            abstractService.setName(getString(reader, Constants.NAME));
+                            constrainingType.getServices().add(abstractService);
+                            readIntents(abstractService, reader);
+    
+                        } else if (Constants.REFERENCE_QNAME.equals(name)) {
+                            
+                            // Read a <reference>
+                            abstractReference = factory.createAbstractReference();
+                            abstractContract = abstractReference;
+                            abstractReference.setName(getString(reader, Constants.NAME));
+                            readMultiplicity(abstractReference, reader);
+                            constrainingType.getReferences().add(abstractReference);
+                            readIntents(abstractReference, reader);
+    
+                        } else if (Constants.PROPERTY_QNAME.equals(name)) {
+                            
+                            // Read a <property>
+                            abstractProperty = factory.createAbstractProperty();
+                            readAbstractProperty(abstractProperty, reader);
+                            constrainingType.getProperties().add(abstractProperty);
+                            readIntents(abstractProperty, reader);
+                            
+                        } else if (OPERATION.equals(name)) {
+    
+                            // Read an <operation>
+                            Operation operation = factory.createOperation();
+                            operation.setName(getString(reader, NAME));
+                            operation.setUnresolved(true);
+                            readIntents(abstractContract, operation, reader);
+                            
+                        } else {
+    
+                            // Read an extension element
+                            Object extension = registry.read(reader);
+                            if (extension instanceof Interface) {
+                                // <service><interface> and <reference><interface>
+                                abstractContract.setInterface((Interface)extension);
+                            }
+                        }
+                        break;
+    
+                    case END_ELEMENT:
+                        name = reader.getName();
+    
+                        // Clear current state when reading reaching end element
+                        if (SERVICE_QNAME.equals(name)) {
+                            abstractService = null;
+                            abstractContract = null;
+                        } else if (REFERENCE_QNAME.equals(name)) {
+                            abstractReference = null;
+                            abstractContract = null;
+                        } else if (PROPERTY_QNAME.equals(name)) {
+                            abstractProperty = null;
+                        }
+                        break;
+                }
+                if (reader.hasNext()) {
+                    reader.next();
+                }
+            }
+            return constrainingType;
+            
+        } catch (XMLStreamException e) {
+            throw new ContributionReadException(e);
+        }
+    }
+    
+    public void resolve(ConstrainingType model, ArtifactResolver resolver) throws ContributionException {
+        // TODO Auto-generated method stub
+    }
+    
+    public void optimize(ConstrainingType model) throws ContributionException {
+        // TODO Auto-generated method stub
+    }
+
+    public QName getArtifactType() {
+        return CONSTRAINING_TYPE_QNAME;
+    }
+    
+    public Class<ConstrainingType> getModelType() {
+        return ConstrainingType.class;
+    }
+}

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

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

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=525654&r1=525653&r2=525654
==============================================================================
--- 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 Wed Apr  4 17:28:19 2007
@@ -34,9 +34,13 @@
 import org.apache.tuscany.assembly.CompositeService;
 import org.apache.tuscany.assembly.Multiplicity;
 import org.apache.tuscany.assembly.Property;
+import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
 import org.apache.tuscany.assembly.util.CompositeUtil;
 import org.apache.tuscany.assembly.util.PrintUtil;
-import org.apache.tuscany.services.spi.contribution.StAXArtifactProcessorRegistry;
+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;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
@@ -46,19 +50,22 @@
  * @version $Rev$ $Date$
  */
 public class ReadAllTestCase extends TestCase {
-    private StAXArtifactProcessorRegistry loaderRegistry;
+    private DefaultStAXArtifactProcessorRegistry registry;
 
     public void setUp() throws Exception {
-        loaderRegistry = new LoaderRegistryImpl();
+        registry = new DefaultStAXArtifactProcessorRegistry();
+        registry.addArtifactProcessor(new CompositeProcessor(registry));
+        registry.addArtifactProcessor(new ComponentTypeProcessor(registry));
+        registry.addArtifactProcessor(new ConstrainingTypeProcessor(registry));
     }
 
     public void tearDown() throws Exception {
-        loaderRegistry = null;
+        registry = null;
     }
 
     public void testReadComposite() throws Exception {
         URL url = getClass().getClassLoader().getResource("TestAllCalculator.composite");
-        Composite composite = loaderRegistry.load(url, Composite.class);
+        Composite composite = registry.read(url, Composite.class);
         assertNotNull(composite);
         assertEquals(composite.getName(), new QName("http://calc", "TestAllCalculator"));
         assertEquals(composite.getConstrainingType().getName(), new QName("http://calc", "Calculator"));
@@ -138,14 +145,14 @@
         assertNotNull(calcCallback);
         // TODO test operations
 
-        new PrintUtil(System.out).print(loaderRegistry.getLoader(Constants.COMPOSITE_QNAME));
+        new PrintUtil(System.out).print(composite);
     }
 
     public void testReadCompositeAndWireIt() throws Exception {
         URL url = getClass().getClassLoader().getResource("TestAllCalculator.composite");
-        Composite composite = loaderRegistry.load(url, Composite.class);
+        Composite composite = registry.read(url, Composite.class);
         assertNotNull(composite);
-        new CompositeUtil(loaderRegistry.getAssemblyFactory(), composite).configure(null);
+        new CompositeUtil(new DefaultAssemblyFactory(), composite).configure(null);
 
         Component calcComponent = composite.getComponents().get(0);
         CompositeService calcCompositeService = (CompositeService)composite.getServices().get(0);

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=525654&r1=525653&r2=525654
==============================================================================
--- 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 Wed Apr  4 17:28:19 2007
@@ -26,15 +26,11 @@
 
 import junit.framework.TestCase;
 
-import org.apache.tuscany.assembly.AssemblyFactory;
-import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
-import org.apache.tuscany.assembly.xml.LoaderRegistry;
 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.assembly.xml.impl.LoaderRegistryImpl;
-import org.apache.tuscany.policy.PolicyFactory;
-import org.apache.tuscany.policy.impl.DefaultPolicyFactory;
+import org.apache.tuscany.services.spi.contribution.DefaultStAXArtifactProcessorRegistry;
+import org.apache.tuscany.services.spi.contribution.StAXArtifactProcessorRegistry;
 
 /**
  * Test the usability of the assembly model API when loading SCDL
@@ -44,55 +40,49 @@
 public class ReadTestCase extends TestCase {
 
     private XMLInputFactory inputFactory;
-    private AssemblyFactory assemblyFactory;
-    private PolicyFactory policyFactory;
-    private LoaderRegistry loaderRegistry;
+    private StAXArtifactProcessorRegistry registry;
 
     public void setUp() throws Exception {
         inputFactory = XMLInputFactory.newInstance();
-        assemblyFactory = new DefaultAssemblyFactory();
-        policyFactory = new DefaultPolicyFactory();
-        loaderRegistry = new LoaderRegistryImpl();
+        registry = new DefaultStAXArtifactProcessorRegistry();
     }
 
     public void tearDown() throws Exception {
-        assemblyFactory = null;
-        policyFactory = null;
         inputFactory = null;
-        loaderRegistry = null;
+        registry = null;
     }
 
     public void testReadComponentType() throws Exception {
-        ComponentTypeProcessor componentTypeReader = new ComponentTypeProcessor(assemblyFactory, policyFactory, loaderRegistry);
+        ComponentTypeProcessor componentTypeReader = new ComponentTypeProcessor(registry);
         InputStream is = getClass().getClassLoader().getResourceAsStream("CalculatorImpl.componentType");
         XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
-        assertNotNull(componentTypeReader.load(reader));
+        assertNotNull(componentTypeReader.read(reader));
         is.close();
     }
 
     public void testReadConstrainingType() throws Exception {
         InputStream is = getClass().getClassLoader().getResourceAsStream("CalculatorComponent.constrainingType");
-        ConstrainingTypeProcessor constrainingTypeReader = new ConstrainingTypeProcessor(assemblyFactory, policyFactory, loaderRegistry);
+        ConstrainingTypeProcessor constrainingTypeReader = new ConstrainingTypeProcessor(registry);
         XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
-        assertNotNull(constrainingTypeReader.load(reader));
+        assertNotNull(constrainingTypeReader.read(reader));
         is.close();
 
     }
 
     public void testReadComposite() throws Exception {
         InputStream is = getClass().getClassLoader().getResourceAsStream("Calculator.composite");
-        CompositeProcessor compositeReader = new CompositeProcessor(assemblyFactory, policyFactory, loaderRegistry);
+        CompositeProcessor compositeReader = new CompositeProcessor(registry);
         XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
-        assertNotNull(compositeReader.load(reader));
+        assertNotNull(compositeReader.read(reader));
         is.close();
 
     }
 
     public void testReadCompositeAndWireIt() throws Exception {
         InputStream is = getClass().getClassLoader().getResourceAsStream("Calculator.composite");
-        CompositeProcessor compositeReader = new CompositeProcessor(assemblyFactory, policyFactory, loaderRegistry);
+        CompositeProcessor compositeReader = new CompositeProcessor(registry);
         XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
-        assertNotNull(compositeReader.load(reader));
+        assertNotNull(compositeReader.read(reader));
         is.close();
     }
 

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=525654&r1=525653&r2=525654
==============================================================================
--- 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 Wed Apr  4 17:28:19 2007
@@ -27,11 +27,11 @@
 import org.apache.tuscany.assembly.AssemblyFactory;
 import org.apache.tuscany.assembly.Composite;
 import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
-import org.apache.tuscany.assembly.xml.LoaderRegistry;
 import org.apache.tuscany.assembly.xml.impl.CompositeProcessor;
-import org.apache.tuscany.assembly.xml.impl.LoaderRegistryImpl;
 import org.apache.tuscany.policy.PolicyFactory;
 import org.apache.tuscany.policy.impl.DefaultPolicyFactory;
+import org.apache.tuscany.services.spi.contribution.DefaultStAXArtifactProcessorRegistry;
+import org.apache.tuscany.services.spi.contribution.StAXArtifactProcessorRegistry;
 
 /**
  * Test the usability of the assembly model API when loading SCDL
@@ -43,7 +43,7 @@
     private XMLInputFactory inputFactory;
     private AssemblyFactory assemblyFactory;
     private PolicyFactory policyFactory;
-    private LoaderRegistry loaderRegistry;
+    private StAXArtifactProcessorRegistry registry;
 
     public static void main(String[] args) throws Exception {
 
@@ -72,22 +72,22 @@
         inputFactory = XMLInputFactory.newInstance();
         assemblyFactory = new DefaultAssemblyFactory();
         policyFactory = new DefaultPolicyFactory();
-        loaderRegistry = new LoaderRegistryImpl();
+        registry = new DefaultStAXArtifactProcessorRegistry();
     }
 
     public void tearDown() throws Exception {
         assemblyFactory = null;
         policyFactory = null;
         inputFactory = null;
-        loaderRegistry = null;
+        registry = null;
     }
 
     public void testReadComposite() throws Exception {
         InputStream is = getClass().getClassLoader().getResourceAsStream("TestAllCalculator.composite");
-        CompositeProcessor loader = new CompositeProcessor(assemblyFactory, policyFactory, loaderRegistry);
+        CompositeProcessor loader = new CompositeProcessor(assemblyFactory, policyFactory, registry);
         XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
 
-        Composite composite = loader.load(reader);
+        Composite composite = loader.read(reader);
         is.close();
 
         if (composite == null) {



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