You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sl...@apache.org on 2008/10/30 14:10:20 UTC

svn commit: r709156 [1/2] - in /tuscany/branches/sca-java-1.3.3: itest/validation/src/main/resources/contribution/xml/MultipleCompositeErrors/ itest/validation/src/test/java/binding/jms/ itest/validation/src/test/java/contribution/xml/ itest/validation...

Author: slaws
Date: Thu Oct 30 06:10:19 2008
New Revision: 709156

URL: http://svn.apache.org/viewvc?rev=709156&view=rev
Log:
TUSCANY-2631 - Make the contribution processor more fault tolerant. Apply Ram's patches (and a few other changes). Doesn't do everything asked for in the JIRA but a step in the right direction

Added:
    tuscany/branches/sca-java-1.3.3/itest/validation/src/main/resources/contribution/xml/MultipleCompositeErrors/
    tuscany/branches/sca-java-1.3.3/itest/validation/src/main/resources/contribution/xml/MultipleCompositeErrors/Calculator.composite   (with props)
    tuscany/branches/sca-java-1.3.3/itest/validation/src/main/resources/contribution/xml/MultipleCompositeErrors/sca-contribution.xml   (with props)
    tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/contribution/xml/MultipleCompositeErrorsTestCase.java   (with props)
    tuscany/branches/sca-java-1.3.3/modules/assembly-xsd/src/main/resources/sca-contributions.xsd   (with props)
Modified:
    tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/binding/jms/MissingActivationSpecNameTestCase.java
    tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/binding/jms/MissingConnectionFactoryNameTestCase.java
    tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/binding/jms/MissingResponseActivationSpecTestCase.java
    tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/binding/jms/MissingResponseConnectionFactoryTestCase.java
    tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/domain/CustomCompositeBuilder.java
    tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java
    tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
    tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java
    tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/main/resources/assembly-xml-validation-messages.properties
    tuscany/branches/sca-java-1.3.3/modules/assembly-xsd/src/main/resources/sca.xsd
    tuscany/branches/sca-java-1.3.3/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportProcessor.java
    tuscany/branches/sca-java-1.3.3/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportProcessor.java
    tuscany/branches/sca-java-1.3.3/modules/contribution-java/src/main/resources/contribution-java-validation-messages.properties
    tuscany/branches/sca-java-1.3.3/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java
    tuscany/branches/sca-java-1.3.3/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java
    tuscany/branches/sca-java-1.3.3/modules/contribution-namespace/src/main/resources/contribution-namespace-validation-messages.properties
    tuscany/branches/sca-java-1.3.3/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceExportProcessor.java
    tuscany/branches/sca-java-1.3.3/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceImportProcessor.java
    tuscany/branches/sca-java-1.3.3/modules/contribution-resource/src/main/resources/contribution-resource-validation-messages.properties
    tuscany/branches/sca-java-1.3.3/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataDocumentProcessor.java
    tuscany/branches/sca-java-1.3.3/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java
    tuscany/branches/sca-java-1.3.3/modules/contribution-xml/src/main/resources/contribution-xml-validation-messages.properties

Added: tuscany/branches/sca-java-1.3.3/itest/validation/src/main/resources/contribution/xml/MultipleCompositeErrors/Calculator.composite
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.3.3/itest/validation/src/main/resources/contribution/xml/MultipleCompositeErrors/Calculator.composite?rev=709156&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.3.3/itest/validation/src/main/resources/contribution/xml/MultipleCompositeErrors/Calculator.composite (added)
+++ tuscany/branches/sca-java-1.3.3/itest/validation/src/main/resources/contribution/xml/MultipleCompositeErrors/Calculator.composite Thu Oct 30 06:10:19 2008
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+	xmlns:calc="http://calc"
+	targetNamespace="http://calc"
+	name="Calculator">
+
+    <service name="CalculatorService" promote="CalculatorServiceComponent">
+        <interface.java interface="calculator.warning.CalculatorService"/>
+    </service>
+
+    <component name="CalculatorServiceComponent">
+		<implementation.java class="calculator.warning.CalculatorServiceImpl"/>
+        <reference name="addService" target="AddServiceComponent"/>
+        <reference name="subtractService" target="SubtractServiceComponent"/>
+        <reference name="multiplyService" target="MultiplyServiceComponent"/>
+        <reference name="divideService" target="DivideServiceComponent"/>
+    </component>
+
+    <component name="AddServiceComponent">
+        <implementation.java class="calculator.warning.AddServiceImpl"/>
+    </component>
+
+    <component name="SubtractServiceComponent">
+        <implementation.java class="calculator.warning.SubtractServiceImpl"/>
+    </component>
+
+    <component name="MultiplyServiceComponent">
+        <implementation.java class="calculator.warning.MultiplyServiceImpl"/>
+    </component>
+
+    <component name="DivideServiceComponent">
+        <implementation.java class="calculator.warning.DivideServiceImpl"/>
+    </component>
+
+</composite>

Propchange: tuscany/branches/sca-java-1.3.3/itest/validation/src/main/resources/contribution/xml/MultipleCompositeErrors/Calculator.composite
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/branches/sca-java-1.3.3/itest/validation/src/main/resources/contribution/xml/MultipleCompositeErrors/Calculator.composite
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: tuscany/branches/sca-java-1.3.3/itest/validation/src/main/resources/contribution/xml/MultipleCompositeErrors/Calculator.composite
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: tuscany/branches/sca-java-1.3.3/itest/validation/src/main/resources/contribution/xml/MultipleCompositeErrors/sca-contribution.xml
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.3.3/itest/validation/src/main/resources/contribution/xml/MultipleCompositeErrors/sca-contribution.xml?rev=709156&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.3.3/itest/validation/src/main/resources/contribution/xml/MultipleCompositeErrors/sca-contribution.xml (added)
+++ tuscany/branches/sca-java-1.3.3/itest/validation/src/main/resources/contribution/xml/MultipleCompositeErrors/sca-contribution.xml Thu Oct 30 06:10:19 2008
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    * Licensed to the Apache Software Foundation (ASF) under one
+    * or more contributor license agreements.  See the NOTICE file
+    * distributed with this work for additional information
+    * regarding copyright ownership.  The ASF licenses this file
+    * to you under the Apache License, Version 2.0 (the
+    * "License"); you may not use this file except in compliance
+    * with the License.  You may obtain a copy of the License at
+    * 
+    *   http://www.apache.org/licenses/LICENSE-2.0
+    * 
+    * Unless required by applicable law or agreed to in writing,
+    * software distributed under the License is distributed on an
+    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    * KIND, either express or implied.  See the License for the
+    * specific language governing permissions and limitations
+    * under the License.    
+-->
+
+<!-- to test TUSCANY-2631 -->
+
+<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
+	          targetNamespace="http://sample"
+              xmlns:sample="http://sample">
+    <deployable xmlns:ns1="http://temp"></deployable>              
+	<deployable composite="ns1:aaaa" xmlns:ns1="http://temp"></deployable>
+	<deployable xmlns:ns1="http://temp"></deployable>
+	<deployable composite="ns1:dfsdf" xmlns:ns1="x"></deployable>
+	<deployable composite="ns1:dsfs" xmlns:ns1="http://temp"></deployable> 
+</contribution>
\ No newline at end of file

Propchange: tuscany/branches/sca-java-1.3.3/itest/validation/src/main/resources/contribution/xml/MultipleCompositeErrors/sca-contribution.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/branches/sca-java-1.3.3/itest/validation/src/main/resources/contribution/xml/MultipleCompositeErrors/sca-contribution.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: tuscany/branches/sca-java-1.3.3/itest/validation/src/main/resources/contribution/xml/MultipleCompositeErrors/sca-contribution.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/binding/jms/MissingActivationSpecNameTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/binding/jms/MissingActivationSpecNameTestCase.java?rev=709156&r1=709155&r2=709156&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/binding/jms/MissingActivationSpecNameTestCase.java (original)
+++ tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/binding/jms/MissingActivationSpecNameTestCase.java Thu Oct 30 06:10:19 2008
@@ -52,7 +52,7 @@
 
     public void testCalculator() {
     	Monitor monitor = customDomain.getMonitorInstance();
-    	Problem problem = ((DefaultLoggingMonitorImpl)monitor).getLastLoggedProblem();
+    	Problem problem = ((DefaultLoggingMonitorImpl)monitor).getProblems().get(1);
         
     	assertNotNull(problem);
         assertEquals("MissingActivationSpecName", problem.getMessageId()); 

Modified: tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/binding/jms/MissingConnectionFactoryNameTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/binding/jms/MissingConnectionFactoryNameTestCase.java?rev=709156&r1=709155&r2=709156&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/binding/jms/MissingConnectionFactoryNameTestCase.java (original)
+++ tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/binding/jms/MissingConnectionFactoryNameTestCase.java Thu Oct 30 06:10:19 2008
@@ -52,7 +52,7 @@
 
     public void testCalculator() {
     	Monitor monitor = customDomain.getMonitorInstance();
-    	Problem problem = ((DefaultLoggingMonitorImpl)monitor).getLastLoggedProblem();
+    	Problem problem = ((DefaultLoggingMonitorImpl)monitor).getProblems().get(1);
         
     	assertNotNull(problem);
         assertEquals("MissingConnectionFactoryName", problem.getMessageId()); 

Modified: tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/binding/jms/MissingResponseActivationSpecTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/binding/jms/MissingResponseActivationSpecTestCase.java?rev=709156&r1=709155&r2=709156&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/binding/jms/MissingResponseActivationSpecTestCase.java (original)
+++ tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/binding/jms/MissingResponseActivationSpecTestCase.java Thu Oct 30 06:10:19 2008
@@ -52,7 +52,7 @@
 
     public void testCalculator() {
     	Monitor monitor = customDomain.getMonitorInstance();
-    	Problem problem = ((DefaultLoggingMonitorImpl)monitor).getLastLoggedProblem();
+    	Problem problem = ((DefaultLoggingMonitorImpl)monitor).getProblems().get(1);
         
     	assertNotNull(problem);
         assertEquals("MissingResponseActivationSpec", problem.getMessageId()); 

Modified: tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/binding/jms/MissingResponseConnectionFactoryTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/binding/jms/MissingResponseConnectionFactoryTestCase.java?rev=709156&r1=709155&r2=709156&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/binding/jms/MissingResponseConnectionFactoryTestCase.java (original)
+++ tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/binding/jms/MissingResponseConnectionFactoryTestCase.java Thu Oct 30 06:10:19 2008
@@ -52,7 +52,7 @@
 
     public void testCalculator() {
     	Monitor monitor = customDomain.getMonitorInstance();
-    	Problem problem = ((DefaultLoggingMonitorImpl)monitor).getLastLoggedProblem();
+    	Problem problem = ((DefaultLoggingMonitorImpl)monitor).getProblems().get(1);
         
     	assertNotNull(problem);
         assertEquals("MissingResponseConnectionFactory", problem.getMessageId()); 

Added: tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/contribution/xml/MultipleCompositeErrorsTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/contribution/xml/MultipleCompositeErrorsTestCase.java?rev=709156&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/contribution/xml/MultipleCompositeErrorsTestCase.java (added)
+++ tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/contribution/xml/MultipleCompositeErrorsTestCase.java Thu Oct 30 06:10:19 2008
@@ -0,0 +1,64 @@
+/*
+ * 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 contribution.xml;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.logging.impl.DefaultLoggingMonitorImpl;
+
+import domain.CustomCompositeBuilder;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class MultipleCompositeErrorsTestCase extends TestCase {
+	
+	private CustomCompositeBuilder customDomain;
+    
+    @Override
+    protected void setUp() throws Exception 
+    {
+    	customDomain = CustomCompositeBuilder.getInstance();
+        try {
+        	customDomain.loadContribution("src/main/resources/contribution/xml/MultipleCompositeErrors/Calculator.composite", 
+        			                      "TestContribution", 
+        			                      "src/main/resources/contribution/xml/MultipleCompositeErrors/");
+        } catch (Exception ex){
+            //throw ex;
+        	System.out.println("Got Exception");
+        }
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        //node.stop();
+    }
+
+    public void testCalculator() {
+    	Monitor monitor = customDomain.getMonitorInstance();
+    	Problem problem = ((DefaultLoggingMonitorImpl)monitor).getLastLoggedProblem();
+        
+    	assertNotNull(problem);
+    	assertEquals(5, monitor.getProblems().size());
+        assertEquals("AttributeCompositeMissing", problem.getMessageId());
+ 
+    }
+}

Propchange: tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/contribution/xml/MultipleCompositeErrorsTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/contribution/xml/MultipleCompositeErrorsTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/domain/CustomCompositeBuilder.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/domain/CustomCompositeBuilder.java?rev=709156&r1=709155&r2=709156&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/domain/CustomCompositeBuilder.java (original)
+++ tuscany/branches/sca-java-1.3.3/itest/validation/src/test/java/domain/CustomCompositeBuilder.java Thu Oct 30 06:10:19 2008
@@ -38,11 +38,14 @@
 import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl;
 import org.apache.tuscany.sca.contribution.Contribution;
 import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.DefaultValidatingXMLInputFactory;
+import org.apache.tuscany.sca.contribution.processor.DefaultValidationSchemaExtensionPoint;
 import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
 import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint;
 import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver;
 import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint;
 import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
@@ -111,7 +114,13 @@
         // Get XML input/output factories
         modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
         XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class);
-        outputFactory = modelFactories.getFactory(XMLOutputFactory.class);       
+        outputFactory = modelFactories.getFactory(XMLOutputFactory.class);
+        
+        // create the validating input factory out here just so that the 
+        // monitor can be passed in
+        ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint();
+        XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas, monitor);
+        modelFactories.addFactory(validatingInputFactory);
         
         // Get contribution workspace and assembly model factories
         workspaceFactory = modelFactories.getFactory(WorkspaceFactory.class); 

Modified: tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java?rev=709156&r1=709155&r2=709156&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java (original)
+++ tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java Thu Oct 30 06:10:19 2008
@@ -84,7 +84,7 @@
               modelFactories.getFactory(PolicyFactory.class), extensionProcessor, monitor);
     }
     
-    public ComponentType read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+    public ComponentType read(XMLStreamReader reader) throws ContributionReadException {
         ComponentType componentType = null;
         Service service = null;
         Reference reference = null;
@@ -93,136 +93,143 @@
         Callback callback = null;
         QName name = null;
         
-        // 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 = assemblyFactory.createComponentType();
-                        componentType.setConstrainingType(readConstrainingType(reader));
-
-                    } else if (Constants.SERVICE_QNAME.equals(name)) {
-
-                        // Read a <service>
-                        service = assemblyFactory.createService();
-                        contract = service;
-                        service.setName(getString(reader, Constants.NAME));
-                        componentType.getServices().add(service);
-                        policyProcessor.readPolicies(service, reader);
-
-                    } else if (Constants.REFERENCE_QNAME.equals(name)) {
-
-                        // Read a <reference>
-                        reference = assemblyFactory.createReference();
-                        contract = reference;
-                        reference.setName(getString(reader, Constants.NAME));
-                        reference.setWiredByImpl(getBoolean(reader, Constants.WIRED_BY_IMPL));
-                        readMultiplicity(reference, reader);
-                        readTargets(reference, reader);
-                        componentType.getReferences().add(reference);
-                        policyProcessor.readPolicies(reference, reader);
-
-                    } else if (Constants.PROPERTY_QNAME.equals(name)) {
-
-                        // Read a <property>
-                        property = assemblyFactory.createProperty();
-                        readAbstractProperty(property, reader);
-                        policyProcessor.readPolicies(property, reader);
-                        
-                        // Read the property value
-                        Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader);
-                        property.setValue(value);
-                        
-                        componentType.getProperties().add(property);
-                        
-                    } else if (Constants.IMPLEMENTATION_QNAME.equals(name)) {
-                        
-                        // Read an <implementation> element
-                        policyProcessor.readPolicies(componentType, reader);
-                        
-                    } else if (Constants.CALLBACK_QNAME.equals(name)) {
-
-                        // Read a <callback>
-                        callback = assemblyFactory.createCallback();
-                        contract.setCallback(callback);
-                        policyProcessor.readPolicies(callback, reader);
-
-                    } else if (OPERATION_QNAME.equals(name)) {
-
-                        // Read an <operation>
-                        Operation operation = new OperationImpl();
-                        operation.setName(getString(reader, NAME));
-                        operation.setUnresolved(true);
-                        if (callback != null) {
-                            policyProcessor.readPolicies(callback, operation, reader);
-                        } else {
-                            policyProcessor.readPolicies(contract, operation, reader);
-                        }
-                    } else {
-
-                        // Read an extension element
-                        Object extension = extensionProcessor.read(reader);
-                        if (extension != null) {
-                            if (extension instanceof InterfaceContract) {
-
-                                // <service><interface> and <reference><interface>
-                                contract.setInterfaceContract((InterfaceContract)extension);
-
-                            } else if (extension instanceof Binding) {
-
-                                // <service><binding> and <reference><binding>
-                                if (callback != null) {
-                                    callback.getBindings().add((Binding)extension);
-                                } else {
-                                    contract.getBindings().add((Binding)extension);
-                                }
+        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 = assemblyFactory.createComponentType();
+                            componentType.setConstrainingType(readConstrainingType(reader));
+    
+                        } else if (Constants.SERVICE_QNAME.equals(name)) {
+    
+                            // Read a <service>
+                            service = assemblyFactory.createService();
+                            contract = service;
+                            service.setName(getString(reader, Constants.NAME));
+                            componentType.getServices().add(service);
+                            policyProcessor.readPolicies(service, reader);
+    
+                        } else if (Constants.REFERENCE_QNAME.equals(name)) {
+    
+                            // Read a <reference>
+                            reference = assemblyFactory.createReference();
+                            contract = reference;
+                            reference.setName(getString(reader, Constants.NAME));
+                            reference.setWiredByImpl(getBoolean(reader, Constants.WIRED_BY_IMPL));
+                            readMultiplicity(reference, reader);
+                            readTargets(reference, reader);
+                            componentType.getReferences().add(reference);
+                            policyProcessor.readPolicies(reference, reader);
+    
+                        } else if (Constants.PROPERTY_QNAME.equals(name)) {
+    
+                            // Read a <property>
+                            property = assemblyFactory.createProperty();
+                            readAbstractProperty(property, reader);
+                            policyProcessor.readPolicies(property, reader);
+                            
+                            // Read the property value
+                            Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader);
+                            property.setValue(value);
+                            
+                            componentType.getProperties().add(property);
+                            
+                        } else if (Constants.IMPLEMENTATION_QNAME.equals(name)) {
+                            
+                            // Read an <implementation> element
+                            policyProcessor.readPolicies(componentType, reader);
+                            
+                        } else if (Constants.CALLBACK_QNAME.equals(name)) {
+    
+                            // Read a <callback>
+                            callback = assemblyFactory.createCallback();
+                            contract.setCallback(callback);
+                            policyProcessor.readPolicies(callback, reader);
+    
+                        } else if (OPERATION_QNAME.equals(name)) {
+    
+                            // Read an <operation>
+                            Operation operation = new OperationImpl();
+                            operation.setName(getString(reader, NAME));
+                            operation.setUnresolved(true);
+                            if (callback != null) {
+                                policyProcessor.readPolicies(callback, operation, reader);
                             } else {
-                                
-                                // Add the extension element to the current element
-                                if (callback != null) {
-                                    callback.getExtensions().add(extension);
-                                } else if (contract != null) {
-                                    contract.getExtensions().add(extension);
-                                } else if (property != null) {
-                                    property.getExtensions().add(extension);
+                                policyProcessor.readPolicies(contract, operation, reader);
+                            }
+                        } else {
+    
+                            // Read an extension element
+                            Object extension = extensionProcessor.read(reader);
+                            if (extension != null) {
+                                if (extension instanceof InterfaceContract) {
+    
+                                    // <service><interface> and <reference><interface>
+                                    contract.setInterfaceContract((InterfaceContract)extension);
+    
+                                } else if (extension instanceof Binding) {
+    
+                                    // <service><binding> and <reference><binding>
+                                    if (callback != null) {
+                                        callback.getBindings().add((Binding)extension);
+                                    } else {
+                                        contract.getBindings().add((Binding)extension);
+                                    }
                                 } else {
-                                    if (componentType instanceof Extensible) {
-                                        ((Extensible)componentType).getExtensions().add(extension);
+                                    
+                                    // Add the extension element to the current element
+                                    if (callback != null) {
+                                        callback.getExtensions().add(extension);
+                                    } else if (contract != null) {
+                                        contract.getExtensions().add(extension);
+                                    } else if (property != null) {
+                                        property.getExtensions().add(extension);
+                                    } else {
+                                        if (componentType instanceof Extensible) {
+                                            ((Extensible)componentType).getExtensions().add(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();
+                        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) {
+            ContributionReadException ex = new ContributionReadException(e);
+            error("XMLStreamException", reader, ex);
+        }
+        
         return componentType;
     }
     

Modified: tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java?rev=709156&r1=709155&r2=709156&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java (original)
+++ tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java Thu Oct 30 06:10:19 2008
@@ -149,7 +149,7 @@
         super(contributionFactory, assemblyFactory, policyFactory, extensionProcessor, monitor);
     }    
 
-    public Composite read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+    public Composite read(XMLStreamReader reader) throws ContributionReadException {
         Composite composite = null;
         Composite include = null;
         Component component = null;
@@ -164,411 +164,418 @@
         Callback callback = null;
         QName name = null;
 
-        // 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 = assemblyFactory.createComposite();
-                        
-                        composite.setName(new QName(getString(reader, TARGET_NAMESPACE), getString(reader, NAME)));
-
-                        if(!isSet(reader, TARGET_NAMESPACE)){
-                            // spec says that a composite must have a namespace
-                            warning("NoCompositeNamespace", composite, composite.getName().toString());   
-                        }
-                        
-                        if(isSet(reader, AUTOWIRE)) {
-                            composite.setAutowire(getBoolean(reader, AUTOWIRE));
-                        }
-                        
-                        //handle extension attributes
-                        this.readExtendedAttributes(reader, name, composite, extensionAttributeProcessor);
-
-                        composite.setLocal(getBoolean(reader, LOCAL));
-                        composite.setConstrainingType(readConstrainingType(reader));
-                        policyProcessor.readPolicies(composite, reader);
-
-                    } else if (INCLUDE_QNAME.equals(name)) {
-
-                        // Read an <include>
-                        include = assemblyFactory.createComposite();
-                        include.setName(getQName(reader, NAME));
-                        include.setURI(getString(reader, URI));
-                        include.setUnresolved(true);
-                        composite.getIncludes().add(include);
-
-                    } else if (SERVICE_QNAME.equals(name)) {
-                        if (component != null) {
-
-                            // Read a <component><service>
-                            componentService = assemblyFactory.createComponentService();
-                            contract = componentService;
-                            componentService.setName(getString(reader, NAME));
+        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 = assemblyFactory.createComposite();
                             
-                            //handle extension attributes
-                            this.readExtendedAttributes(reader, name, componentService, extensionAttributeProcessor);
-
-                            component.getServices().add(componentService);
-                            policyProcessor.readPolicies(contract, reader);
-                        } else {
-
-                            // Read a <composite><service>
-                            compositeService = assemblyFactory.createCompositeService();
-                            contract = compositeService;
-                            compositeService.setName(getString(reader, NAME));
-
-                            String promoted = getString(reader, PROMOTE);
-                            if (promoted != null) {
-                                String promotedComponentName;
-                                String promotedServiceName;
-                                int s = promoted.indexOf('/');
-                                if (s == -1) {
-                                    promotedComponentName = promoted;
-                                    promotedServiceName = null;
-                                } else {
-                                    promotedComponentName = promoted.substring(0, s);
-                                    promotedServiceName = promoted.substring(s + 1);
-                                }
+                            composite.setName(new QName(getString(reader, TARGET_NAMESPACE), getString(reader, NAME)));
     
-                                Component promotedComponent = assemblyFactory.createComponent();
-                                promotedComponent.setUnresolved(true);
-                                promotedComponent.setName(promotedComponentName);
-                                compositeService.setPromotedComponent(promotedComponent);
-    
-                                ComponentService promotedService = assemblyFactory.createComponentService();
-                                promotedService.setUnresolved(true);
-                                promotedService.setName(promotedServiceName);
-                                compositeService.setPromotedService(promotedService);
+                            if(!isSet(reader, TARGET_NAMESPACE)){
+                                // spec says that a composite must have a namespace
+                                warning("NoCompositeNamespace", composite, composite.getName().toString());   
                             }
-
-                            //handle extension attributes
-                            this.readExtendedAttributes(reader, name, compositeService, extensionAttributeProcessor);
-
-                            composite.getServices().add(compositeService);
-                            policyProcessor.readPolicies(contract, reader);
-                        }
-
-                    } else if (REFERENCE_QNAME.equals(name)) {
-                        if (component != null) {
-                            // Read a <component><reference>
-                            componentReference = assemblyFactory.createComponentReference();
-                            contract = componentReference;
-                            componentReference.setName(getString(reader, NAME));
-                            readMultiplicity(componentReference, reader);
-                            if (isSet(reader, AUTOWIRE)) {
-                                componentReference.setAutowire(getBoolean(reader, AUTOWIRE));
+                            
+                            if(isSet(reader, AUTOWIRE)) {
+                                composite.setAutowire(getBoolean(reader, AUTOWIRE));
                             }
-                            readTargets(componentReference, reader);
-                            componentReference.setWiredByImpl(getBoolean(reader, WIRED_BY_IMPL));
                             
                             //handle extension attributes
-                            this.readExtendedAttributes(reader, name, componentReference, extensionAttributeProcessor);
-
-                            component.getReferences().add(componentReference);
-                            policyProcessor.readPolicies(contract, reader);
-                        } else {
-                            // Read a <composite><reference>
-                            compositeReference = assemblyFactory.createCompositeReference();
-                            contract = compositeReference;
-                            compositeReference.setName(getString(reader, NAME));
-                            readMultiplicity(compositeReference, reader);
-                            readTargets(compositeReference, reader);
-                            String promote = reader.getAttributeValue(null, Constants.PROMOTE);
-                            if (promote != null) {
-                                for (StringTokenizer tokens = new StringTokenizer(promote); tokens.hasMoreTokens();) {
-                                    ComponentReference promotedReference =
-                                        assemblyFactory.createComponentReference();
-                                    promotedReference.setUnresolved(true);
-                                    promotedReference.setName(tokens.nextToken());
-                                    compositeReference.getPromotedReferences().add(promotedReference);
+                            this.readExtendedAttributes(reader, name, composite, extensionAttributeProcessor);
+    
+                            composite.setLocal(getBoolean(reader, LOCAL));
+                            composite.setConstrainingType(readConstrainingType(reader));
+                            policyProcessor.readPolicies(composite, reader);
+    
+                        } else if (INCLUDE_QNAME.equals(name)) {
+    
+                            // Read an <include>
+                            include = assemblyFactory.createComposite();
+                            include.setName(getQName(reader, NAME));
+                            include.setURI(getString(reader, URI));
+                            include.setUnresolved(true);
+                            composite.getIncludes().add(include);
+    
+                        } else if (SERVICE_QNAME.equals(name)) {
+                            if (component != null) {
+    
+                                // Read a <component><service>
+                                componentService = assemblyFactory.createComponentService();
+                                contract = componentService;
+                                componentService.setName(getString(reader, NAME));
+                                
+                                //handle extension attributes
+                                this.readExtendedAttributes(reader, name, componentService, extensionAttributeProcessor);
+    
+                                component.getServices().add(componentService);
+                                policyProcessor.readPolicies(contract, reader);
+                            } else {
+    
+                                // Read a <composite><service>
+                                compositeService = assemblyFactory.createCompositeService();
+                                contract = compositeService;
+                                compositeService.setName(getString(reader, NAME));
+    
+                                String promoted = getString(reader, PROMOTE);
+                                if (promoted != null) {
+                                    String promotedComponentName;
+                                    String promotedServiceName;
+                                    int s = promoted.indexOf('/');
+                                    if (s == -1) {
+                                        promotedComponentName = promoted;
+                                        promotedServiceName = null;
+                                    } else {
+                                        promotedComponentName = promoted.substring(0, s);
+                                        promotedServiceName = promoted.substring(s + 1);
+                                    }
+        
+                                    Component promotedComponent = assemblyFactory.createComponent();
+                                    promotedComponent.setUnresolved(true);
+                                    promotedComponent.setName(promotedComponentName);
+                                    compositeService.setPromotedComponent(promotedComponent);
+        
+                                    ComponentService promotedService = assemblyFactory.createComponentService();
+                                    promotedService.setUnresolved(true);
+                                    promotedService.setName(promotedServiceName);
+                                    compositeService.setPromotedService(promotedService);
                                 }
+    
+                                //handle extension attributes
+                                this.readExtendedAttributes(reader, name, compositeService, extensionAttributeProcessor);
+    
+                                composite.getServices().add(compositeService);
+                                policyProcessor.readPolicies(contract, reader);
                             }
-                            compositeReference.setWiredByImpl(getBoolean(reader, WIRED_BY_IMPL));
-                            
-                            //handle extension attributes
-                            this.readExtendedAttributes(reader, name, compositeReference, extensionAttributeProcessor);
-
-                            composite.getReferences().add(compositeReference);                            
-                            policyProcessor.readPolicies(contract, reader);
-                        }
-
-                    } else if (PROPERTY_QNAME.equals(name)) {
-                        if (component != null) {
-
-                            // Read a <component><property>
-                            componentProperty = assemblyFactory.createComponentProperty();
-                            property = componentProperty;
-                            String source = getString(reader, SOURCE);
-                            if(source!=null) {
-                                source = source.trim();
+    
+                        } else if (REFERENCE_QNAME.equals(name)) {
+                            if (component != null) {
+                                // Read a <component><reference>
+                                componentReference = assemblyFactory.createComponentReference();
+                                contract = componentReference;
+                                componentReference.setName(getString(reader, NAME));
+                                readMultiplicity(componentReference, reader);
+                                if (isSet(reader, AUTOWIRE)) {
+                                    componentReference.setAutowire(getBoolean(reader, AUTOWIRE));
+                                }
+                                readTargets(componentReference, reader);
+                                componentReference.setWiredByImpl(getBoolean(reader, WIRED_BY_IMPL));
+                                
+                                //handle extension attributes
+                                this.readExtendedAttributes(reader, name, componentReference, extensionAttributeProcessor);
+    
+                                component.getReferences().add(componentReference);
+                                policyProcessor.readPolicies(contract, reader);
+                            } else {
+                                // Read a <composite><reference>
+                                compositeReference = assemblyFactory.createCompositeReference();
+                                contract = compositeReference;
+                                compositeReference.setName(getString(reader, NAME));
+                                readMultiplicity(compositeReference, reader);
+                                readTargets(compositeReference, reader);
+                                String promote = reader.getAttributeValue(null, Constants.PROMOTE);
+                                if (promote != null) {
+                                    for (StringTokenizer tokens = new StringTokenizer(promote); tokens.hasMoreTokens();) {
+                                        ComponentReference promotedReference =
+                                            assemblyFactory.createComponentReference();
+                                        promotedReference.setUnresolved(true);
+                                        promotedReference.setName(tokens.nextToken());
+                                        compositeReference.getPromotedReferences().add(promotedReference);
+                                    }
+                                }
+                                compositeReference.setWiredByImpl(getBoolean(reader, WIRED_BY_IMPL));
+                                
+                                //handle extension attributes
+                                this.readExtendedAttributes(reader, name, compositeReference, extensionAttributeProcessor);
+    
+                                composite.getReferences().add(compositeReference);                            
+                                policyProcessor.readPolicies(contract, reader);
                             }
-                            componentProperty.setSource(source);
-                            if (source != null) {
-                                // $<name>/...
-                                if (source.charAt(0) == '$') {
-                                    int index = source.indexOf('/');
-                                    if (index == -1) {
-                                        // Tolerating $prop
-                                        source = source + "/";
-                                        index = source.length() - 1;
+    
+                        } else if (PROPERTY_QNAME.equals(name)) {
+                            if (component != null) {
+    
+                                // Read a <component><property>
+                                componentProperty = assemblyFactory.createComponentProperty();
+                                property = componentProperty;
+                                String source = getString(reader, SOURCE);
+                                if(source!=null) {
+                                    source = source.trim();
+                                }
+                                componentProperty.setSource(source);
+                                if (source != null) {
+                                    // $<name>/...
+                                    if (source.charAt(0) == '$') {
+                                        int index = source.indexOf('/');
+                                        if (index == -1) {
+                                            // Tolerating $prop
+                                            source = source + "/";
+                                            index = source.length() - 1;
+                                        }
+                                        source = source.substring(index + 1);
+                                        if ("".equals(source)) {
+                                            source = ".";
+                                        }
                                     }
-                                    source = source.substring(index + 1);
-                                    if ("".equals(source)) {
-                                        source = ".";
+                                    XPath xpath = xPathFactory.newXPath();
+                                    xpath.setNamespaceContext(reader.getNamespaceContext());
+                                    try {
+                                        componentProperty.setSourceXPathExpression(xpath.compile(source));
+                                    } catch (XPathExpressionException e) {
+                                    	ContributionReadException ce = new ContributionReadException(e);
+                                    	error("ContributionReadException", xpath, ce);
+                                        //throw ce;
                                     }
                                 }
-                                XPath xpath = xPathFactory.newXPath();
-                                xpath.setNamespaceContext(reader.getNamespaceContext());
-                                try {
-                                    componentProperty.setSourceXPathExpression(xpath.compile(source));
-                                } catch (XPathExpressionException e) {
-                                	ContributionReadException ce = new ContributionReadException(e);
-                                	error("ContributionReadException", xpath, ce);
-                                    //throw ce;
-                                }
+                                componentProperty.setFile(getString(reader, FILE));
+                                
+                                //handle extension attributes
+                                this.readExtendedAttributes(reader, name, componentProperty, extensionAttributeProcessor);
+    
+                                policyProcessor.readPolicies(property, reader);
+                                readAbstractProperty(componentProperty, reader);
+                                
+                                // Read the property value
+                                Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader);
+                                property.setValue(value);
+                                
+                                component.getProperties().add(componentProperty);
+                            } else {
+    
+                                // Read a <composite><property>
+                                property = assemblyFactory.createProperty();
+                                policyProcessor.readPolicies(property, reader);
+                                readAbstractProperty(property, reader);
+                                
+                                // Read the property value
+                                Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader);
+                                property.setValue(value);
+                                
+                                composite.getProperties().add(property);
+                            }
+                            
+                            // TUSCANY-1949
+                            // If the property doesn't have a value, the END_ELEMENT event is read by the readPropertyValue
+                            if (reader.getEventType() == END_ELEMENT && PROPERTY_QNAME.equals(reader.getName())) {
+                                property = null;
+                                componentProperty = null;
+                            }
+    
+                        } else if (COMPONENT_QNAME.equals(name)) {
+    
+                            // Read a <component>
+                            component = assemblyFactory.createComponent();
+                            component.setName(getString(reader, NAME));
+                            if (isSet(reader, AUTOWIRE)) {
+                                component.setAutowire(getBoolean(reader, AUTOWIRE));
+                            }
+                            if (isSet(reader, URI)) {
+                                component.setURI(getString(reader, URI));
                             }
-                            componentProperty.setFile(getString(reader, FILE));
                             
                             //handle extension attributes
-                            this.readExtendedAttributes(reader, name, componentProperty, extensionAttributeProcessor);
-
-                            policyProcessor.readPolicies(property, reader);
-                            readAbstractProperty(componentProperty, reader);
+                           this.readExtendedAttributes(reader, name, component, extensionAttributeProcessor);
+                            
+                            component.setConstrainingType(readConstrainingType(reader));
+                            composite.getComponents().add(component);
+                            policyProcessor.readPolicies(component, reader);
+    
+                        } else if (WIRE_QNAME.equals(name)) {
+    
+                            // Read a <wire>
+                            wire = assemblyFactory.createWire();
+                            ComponentReference source = assemblyFactory.createComponentReference();
+                            source.setUnresolved(true);
+                            source.setName(getString(reader, SOURCE));
+                            wire.setSource(source);
+    
+                            ComponentService target = assemblyFactory.createComponentService();
+                            target.setUnresolved(true);
+                            target.setName(getString(reader, TARGET));
+                            wire.setTarget(target);
+    
+                            //handle extension attributes
+                            this.readExtendedAttributes(reader, name, wire, extensionAttributeProcessor);
+    
+                            composite.getWires().add(wire);
+                            policyProcessor.readPolicies(wire, reader);
+    
+                        } else if (CALLBACK_QNAME.equals(name)) {
+    
+                            // Read a <callback>
+                            callback = assemblyFactory.createCallback();
+                            contract.setCallback(callback);
                             
-                            // Read the property value
-                            Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader);
-                            property.setValue(value);
+                            //handle extension attributes
+                            this.readExtendedAttributes(reader, name, callback, extensionAttributeProcessor);
                             
-                            component.getProperties().add(componentProperty);
-                        } else {
-
-                            // Read a <composite><property>
-                            property = assemblyFactory.createProperty();
-                            policyProcessor.readPolicies(property, reader);
-                            readAbstractProperty(property, reader);
+                            policyProcessor.readPolicies(callback, reader);
+    
+                        } else if (OPERATION_QNAME.equals(name)) {
+    
+                            // Read an <operation>
+                            ConfiguredOperation operation = assemblyFactory.createConfiguredOperation();
+                            operation.setName(getString(reader, NAME));
+                            operation.setUnresolved(true);
+                            if (callback != null) {
+                                policyProcessor.readPolicies(operation, reader);
+                            } else {
+                                policyProcessor.readPolicies(operation, reader);
+                            }
                             
-                            // Read the property value
-                            Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader);
-                            property.setValue(value);
+                            OperationsConfigurator opConfigurator = null;
+                            if ( compositeService != null ) {
+                                opConfigurator = compositeService;
+                            } else if ( componentService != null ) {
+                                opConfigurator = componentService;
+                            } else if ( compositeReference != null ) {
+                                opConfigurator = compositeReference;
+                            } else if ( componentReference != null ) {
+                                opConfigurator = componentReference;
+                            }
                             
-                            composite.getProperties().add(property);
-                        }
-                        
-                        // TUSCANY-1949
-                        // If the property doesn't have a value, the END_ELEMENT event is read by the readPropertyValue
-                        if (reader.getEventType() == END_ELEMENT && PROPERTY_QNAME.equals(reader.getName())) {
-                            property = null;
-                            componentProperty = null;
-                        }
-
-                    } else if (COMPONENT_QNAME.equals(name)) {
-
-                        // Read a <component>
-                        component = assemblyFactory.createComponent();
-                        component.setName(getString(reader, NAME));
-                        if (isSet(reader, AUTOWIRE)) {
-                            component.setAutowire(getBoolean(reader, AUTOWIRE));
-                        }
-                        if (isSet(reader, URI)) {
-                            component.setURI(getString(reader, URI));
-                        }
-                        
-                        //handle extension attributes
-                       this.readExtendedAttributes(reader, name, component, extensionAttributeProcessor);
-                        
-                        component.setConstrainingType(readConstrainingType(reader));
-                        composite.getComponents().add(component);
-                        policyProcessor.readPolicies(component, reader);
-
-                    } else if (WIRE_QNAME.equals(name)) {
-
-                        // Read a <wire>
-                        wire = assemblyFactory.createWire();
-                        ComponentReference source = assemblyFactory.createComponentReference();
-                        source.setUnresolved(true);
-                        source.setName(getString(reader, SOURCE));
-                        wire.setSource(source);
-
-                        ComponentService target = assemblyFactory.createComponentService();
-                        target.setUnresolved(true);
-                        target.setName(getString(reader, TARGET));
-                        wire.setTarget(target);
-
-                        //handle extension attributes
-                        this.readExtendedAttributes(reader, name, wire, extensionAttributeProcessor);
-
-                        composite.getWires().add(wire);
-                        policyProcessor.readPolicies(wire, reader);
-
-                    } else if (CALLBACK_QNAME.equals(name)) {
-
-                        // Read a <callback>
-                        callback = assemblyFactory.createCallback();
-                        contract.setCallback(callback);
-                        
-                        //handle extension attributes
-                        this.readExtendedAttributes(reader, name, callback, extensionAttributeProcessor);
-                        
-                        policyProcessor.readPolicies(callback, reader);
-
-                    } else if (OPERATION_QNAME.equals(name)) {
-
-                        // Read an <operation>
-                        ConfiguredOperation operation = assemblyFactory.createConfiguredOperation();
-                        operation.setName(getString(reader, NAME));
-                        operation.setUnresolved(true);
-                        if (callback != null) {
-                            policyProcessor.readPolicies(operation, reader);
+                            opConfigurator.getConfiguredOperations().add(operation);
+                        } else if (IMPLEMENTATION_COMPOSITE_QNAME.equals(name)) {
+    
+                            // Read an implementation.composite
+                            Composite implementation = assemblyFactory.createComposite();
+                            implementation.setName(getQName(reader, NAME));
+                            implementation.setUnresolved(true);
+                            
+                            //handle extension attributes
+                            this.readExtendedAttributes(reader, name, implementation, extensionAttributeProcessor);
+    
+                            component.setImplementation(implementation);
+                            policyProcessor.readPolicies(implementation, reader);
                         } else {
-                            policyProcessor.readPolicies(operation, reader);
-                        }
-                        
-                        OperationsConfigurator opConfigurator = null;
-                        if ( compositeService != null ) {
-                            opConfigurator = compositeService;
-                        } else if ( componentService != null ) {
-                            opConfigurator = componentService;
-                        } else if ( compositeReference != null ) {
-                            opConfigurator = compositeReference;
-                        } else if ( componentReference != null ) {
-                            opConfigurator = componentReference;
-                        }
-                        
-                        opConfigurator.getConfiguredOperations().add(operation);
-                    } else if (IMPLEMENTATION_COMPOSITE_QNAME.equals(name)) {
-
-                        // Read an implementation.composite
-                        Composite implementation = assemblyFactory.createComposite();
-                        implementation.setName(getQName(reader, NAME));
-                        implementation.setUnresolved(true);
-                        
-                        //handle extension attributes
-                        this.readExtendedAttributes(reader, name, implementation, extensionAttributeProcessor);
-
-                        component.setImplementation(implementation);
-                        policyProcessor.readPolicies(implementation, reader);
-                    } else {
-
-                        // Read an extension element
-                        Object extension = extensionProcessor.read(reader);
-                        if (extension != null) {
-                            if (extension instanceof InterfaceContract) {
-
-                                // <service><interface> and
-                                // <reference><interface>
-                                if (contract != null) {
-                                    contract.setInterfaceContract((InterfaceContract)extension);
-                                } else {
-                                    if (name.getNamespaceURI().equals(SCA10_NS)) {
-                                    	error("UnexpectedInterfaceElement", extension);
-                                        //throw new ContributionReadException("Unexpected <interface> element found. It should appear inside a <service> or <reference> element");
+    
+                            // Read an extension element
+                            Object extension = extensionProcessor.read(reader);
+                            if (extension != null) {
+                                if (extension instanceof InterfaceContract) {
+    
+                                    // <service><interface> and
+                                    // <reference><interface>
+                                    if (contract != null) {
+                                        contract.setInterfaceContract((InterfaceContract)extension);
                                     } else {
-                                        composite.getExtensions().add(extension);
+                                        if (name.getNamespaceURI().equals(SCA10_NS)) {
+                                        	error("UnexpectedInterfaceElement", extension);
+                                            //throw new ContributionReadException("Unexpected <interface> element found. It should appear inside a <service> or <reference> element");
+                                        } else {
+                                            composite.getExtensions().add(extension);
+                                        }
                                     }
-                                }
-                            } else if (extension instanceof Binding) {
-                                if ( extension instanceof PolicySetAttachPoint ) {
-                                    IntentAttachPointType bindingType = intentAttachPointTypeFactory.createBindingType();
-                                    bindingType.setName(name);
-                                    bindingType.setUnresolved(true);
-                                    ((PolicySetAttachPoint)extension).setType(bindingType);
-                                }
-                                // <service><binding> and
-                                // <reference><binding>
-                                if (callback != null) {
-                                    callback.getBindings().add((Binding)extension);
-                                } else {
-                                    if (contract != null) {
-                                        contract.getBindings().add((Binding)extension);
+                                } else if (extension instanceof Binding) {
+                                    if ( extension instanceof PolicySetAttachPoint ) {
+                                        IntentAttachPointType bindingType = intentAttachPointTypeFactory.createBindingType();
+                                        bindingType.setName(name);
+                                        bindingType.setUnresolved(true);
+                                        ((PolicySetAttachPoint)extension).setType(bindingType);
+                                    }
+                                    // <service><binding> and
+                                    // <reference><binding>
+                                    if (callback != null) {
+                                        callback.getBindings().add((Binding)extension);
+                                    } else {
+                                        if (contract != null) {
+                                            contract.getBindings().add((Binding)extension);
+                                        } else {
+                                            if (name.getNamespaceURI().equals(SCA10_NS)) {
+                                            	error("UnexpectedBindingElement", extension);
+                                                //throw new ContributionReadException("Unexpected <binding> element found. It should appear inside a <service> or <reference> element");
+                                            } else {
+                                                composite.getExtensions().add(extension);
+                                            }
+                                        }
+                                    }
+    
+                                } else if (extension instanceof Implementation) {
+                                    if ( extension instanceof PolicySetAttachPoint ) {
+                                        IntentAttachPointType implType = intentAttachPointTypeFactory.createImplementationType();
+                                        implType.setName(name);
+                                        implType.setUnresolved(true);
+                                        ((PolicySetAttachPoint)extension).setType(implType);
+                                    }
+                                    // <component><implementation>
+                                    if (component != null) {
+                                        component.setImplementation((Implementation)extension);
                                     } else {
                                         if (name.getNamespaceURI().equals(SCA10_NS)) {
-                                        	error("UnexpectedBindingElement", extension);
-                                            //throw new ContributionReadException("Unexpected <binding> element found. It should appear inside a <service> or <reference> element");
+                                        	error("UnexpectedImplementationElement", extension);
+                                            //throw new ContributionReadException("Unexpected <implementation> element found. It should appear inside a <component> element");
                                         } else {
                                             composite.getExtensions().add(extension);
                                         }
                                     }
-                                }
-
-                            } else if (extension instanceof Implementation) {
-                                if ( extension instanceof PolicySetAttachPoint ) {
-                                    IntentAttachPointType implType = intentAttachPointTypeFactory.createImplementationType();
-                                    implType.setName(name);
-                                    implType.setUnresolved(true);
-                                    ((PolicySetAttachPoint)extension).setType(implType);
-                                }
-                                // <component><implementation>
-                                if (component != null) {
-                                    component.setImplementation((Implementation)extension);
                                 } else {
-                                    if (name.getNamespaceURI().equals(SCA10_NS)) {
-                                    	error("UnexpectedImplementationElement", extension);
-                                        //throw new ContributionReadException("Unexpected <implementation> element found. It should appear inside a <component> element");
+    
+                                    // Add the extension element to the current
+                                    // element
+                                    if (callback != null) {
+                                        callback.getExtensions().add(extension);
+                                    } else if (contract != null) {
+                                        contract.getExtensions().add(extension);
+                                    } else if (property != null) {
+                                        property.getExtensions().add(extension);
+                                    } else if (component != null) {
+                                        component.getExtensions().add(extension);
                                     } else {
                                         composite.getExtensions().add(extension);
                                     }
                                 }
-                            } else {
-
-                                // Add the extension element to the current
-                                // element
-                                if (callback != null) {
-                                    callback.getExtensions().add(extension);
-                                } else if (contract != null) {
-                                    contract.getExtensions().add(extension);
-                                } else if (property != null) {
-                                    property.getExtensions().add(extension);
-                                } else if (component != null) {
-                                    component.getExtensions().add(extension);
-                                } else {
-                                    composite.getExtensions().add(extension);
-                                }
                             }
                         }
-                    }
-                    break;
-
-                case XMLStreamConstants.CHARACTERS:
-                    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();
+                        break;
+    
+                    case XMLStreamConstants.CHARACTERS:
+                        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();
+                }
             }
         }
+        catch (XMLStreamException e) {
+            ContributionReadException ex = new ContributionReadException(e);
+            error("XMLStreamException", reader, ex);
+        }
+        
         return composite;
     }