tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsdelf...@apache.org
Subject svn commit: r572267 [5/6] - in /incubator/tuscany/java/sca: itest/ modules/ modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ modules/binding-jms/src/main/jav...
Date Mon, 03 Sep 2007 09:46:47 GMT
Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java?rev=572267&r1=572266&r2=572267&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java Mon Sep  3 02:46:41 2007
@@ -72,71 +72,60 @@
         return wsdlInterface;
     }
 
-    public WSDLInterfaceContract read(XMLStreamReader reader) throws ContributionReadException {
-        try {
-    
-            // Read an <interface.wsdl>
-            WSDLInterfaceContract wsdlInterfaceContract = wsdlFactory.createWSDLInterfaceContract();
-            
-            // Read wsdlLocation
-            String location = reader.getAttributeValue(WSDLI_NS, WSDL_LOCATION);
-            wsdlInterfaceContract.setLocation(location);
-            
-            String uri = reader.getAttributeValue(null, INTERFACE);
-            if (uri != null) {
-                WSDLInterface wsdlInterface = createWSDLInterface(uri);
-                wsdlInterfaceContract.setInterface(wsdlInterface);
-            }
+    public WSDLInterfaceContract read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+        // Read an <interface.wsdl>
+        WSDLInterfaceContract wsdlInterfaceContract = wsdlFactory.createWSDLInterfaceContract();
+        
+        // Read wsdlLocation
+        String location = reader.getAttributeValue(WSDLI_NS, WSDL_LOCATION);
+        wsdlInterfaceContract.setLocation(location);
+        
+        String uri = reader.getAttributeValue(null, INTERFACE);
+        if (uri != null) {
+            WSDLInterface wsdlInterface = createWSDLInterface(uri);
+            wsdlInterfaceContract.setInterface(wsdlInterface);
+        }
+        
+        uri = reader.getAttributeValue(null, CALLBACK_INTERFACE);
+        if (uri != null) {
+            WSDLInterface wsdlCallbackInterface = createWSDLInterface(uri);
+            wsdlInterfaceContract.setCallbackInterface(wsdlCallbackInterface);
+        }
             
-            uri = reader.getAttributeValue(null, CALLBACK_INTERFACE);
-            if (uri != null) {
-                WSDLInterface wsdlCallbackInterface = createWSDLInterface(uri);
-                wsdlInterfaceContract.setCallbackInterface(wsdlCallbackInterface);
+        // Skip to end element
+        while (reader.hasNext()) {
+            if (reader.next() == END_ELEMENT && INTERFACE_WSDL_QNAME.equals(reader.getName())) {
+                break;
             }
-                
-            // Skip to end element
-            while (reader.hasNext()) {
-                if (reader.next() == END_ELEMENT && INTERFACE_WSDL_QNAME.equals(reader.getName())) {
-                    break;
-                }
-            }
-            return wsdlInterfaceContract;
-            
-        } catch (XMLStreamException e) {
-            throw new ContributionReadException(e);
         }
+        return wsdlInterfaceContract;
     }
     
-    public void write(WSDLInterfaceContract wsdlInterfaceContract, XMLStreamWriter writer) throws ContributionWriteException {
-        try {
-            // Write an <interface.wsdl>
-            writer.writeStartElement(Constants.SCA10_NS, INTERFACE_WSDL);
+    public void write(WSDLInterfaceContract wsdlInterfaceContract, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+        // Write an <interface.wsdl>
+        writer.writeStartElement(Constants.SCA10_NS, INTERFACE_WSDL);
 
-            // Write interface name
-            WSDLInterface wsdlInterface = (WSDLInterface)wsdlInterfaceContract.getInterface();
-            if (wsdlInterface != null) {
-                QName qname = wsdlInterface.getName();
-                String uri = qname.getNamespaceURI() + "#wsdl.interface(" + qname.getLocalPart() + ")";
-                writer.writeAttribute(INTERFACE, uri);
-            }
+        // Write interface name
+        WSDLInterface wsdlInterface = (WSDLInterface)wsdlInterfaceContract.getInterface();
+        if (wsdlInterface != null) {
+            QName qname = wsdlInterface.getName();
+            String uri = qname.getNamespaceURI() + "#wsdl.interface(" + qname.getLocalPart() + ")";
+            writer.writeAttribute(INTERFACE, uri);
+        }
 
-            WSDLInterface wsdlCallbackInterface = (WSDLInterface)wsdlInterfaceContract.getCallbackInterface();
-            if (wsdlCallbackInterface != null) {
-                QName qname = wsdlCallbackInterface.getName();
-                String uri = qname.getNamespaceURI() + "#wsdl.interface(" + qname.getLocalPart() + ")";
-                writer.writeAttribute(CALLBACK_INTERFACE, uri);
-            }
-            
-            // Write location
-            if (wsdlInterfaceContract.getLocation() != null) {
-                writer.writeAttribute(WSDLI_NS, WSDL_LOCATION, wsdlInterfaceContract.getLocation());
-            }
-            
-            writer.writeEndElement();
-            
-        } catch (XMLStreamException e) {
-            throw new ContributionWriteException(e);
+        WSDLInterface wsdlCallbackInterface = (WSDLInterface)wsdlInterfaceContract.getCallbackInterface();
+        if (wsdlCallbackInterface != null) {
+            QName qname = wsdlCallbackInterface.getName();
+            String uri = qname.getNamespaceURI() + "#wsdl.interface(" + qname.getLocalPart() + ")";
+            writer.writeAttribute(CALLBACK_INTERFACE, uri);
+        }
+        
+        // Write location
+        if (wsdlInterfaceContract.getLocation() != null) {
+            writer.writeAttribute(WSDLI_NS, WSDL_LOCATION, wsdlInterfaceContract.getLocation());
         }
+        
+        writer.writeEndElement();
     }
     
     private WSDLInterface resolveWSDLInterface(WSDLInterface wsdlInterface, ModelResolver resolver) throws ContributionResolveException {

Modified: incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java?rev=572267&r1=572266&r2=572267&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java Mon Sep  3 02:46:41 2007
@@ -29,7 +29,7 @@
 /* 
  * Processor for handling xml models of BindingType meta data definitions
  */
-public class BindingTypeProcessor extends IntentAttachPointProcessor {
+public class BindingTypeProcessor extends IntentAttachPointTypeProcessor {
 
     public BindingTypeProcessor(PolicyFactory policyFactory, IntentAttachPointTypeFactory intentAttachPointTypeFactory, StAXArtifactProcessor<Object> extensionProcessor) {
         super(policyFactory, intentAttachPointTypeFactory, extensionProcessor);

Modified: incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java?rev=572267&r1=572266&r2=572267&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java Mon Sep  3 02:46:41 2007
@@ -29,7 +29,7 @@
 /* 
  * Processor for handling xml models of ImplementationType meta data definitions
  */
-public class ImplementationTypeProcessor extends IntentAttachPointProcessor {
+public class ImplementationTypeProcessor extends IntentAttachPointTypeProcessor {
 
     public ImplementationTypeProcessor(PolicyFactory policyFactory, IntentAttachPointTypeFactory intentAttachPointTypeFactory, StAXArtifactProcessor<Object> extensionProcessor) {
         super(policyFactory, intentAttachPointTypeFactory, extensionProcessor);

Copied: incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointTypeProcessor.java (from r572232, incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointProcessor.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointTypeProcessor.java?p2=incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointTypeProcessor.java&p1=incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointProcessor.java&r1=572232&r2=572267&rev=572267&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointTypeProcessor.java Mon Sep  3 02:46:41 2007
@@ -27,6 +27,7 @@
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
 import org.apache.tuscany.sca.contribution.service.ContributionReadException;
@@ -43,32 +44,30 @@
 /* 
  * Processor for handling xml models of ExtensionType meta data definitions
  */
-public abstract class IntentAttachPointProcessor implements StAXArtifactProcessor<IntentAttachPointType>, PolicyConstants {
+public abstract class IntentAttachPointTypeProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<IntentAttachPointType>, PolicyConstants {
 
-    protected IntentAttachPointTypeFactory extnTypeFactory;
-    protected PolicyFactory policyFactory; 
-    protected StAXArtifactProcessor<Object> extensionProcessor;
+    private IntentAttachPointTypeFactory attachPointTypeFactory;
+    private PolicyFactory policyFactory; 
     
 
-    public IntentAttachPointProcessor(PolicyFactory policyFactory, IntentAttachPointTypeFactory extnTypeFactory, StAXArtifactProcessor<Object> extensionProcessor) {
+    public IntentAttachPointTypeProcessor(PolicyFactory policyFactory, IntentAttachPointTypeFactory attachPointTypeFactory, StAXArtifactProcessor<Object> extensionProcessor) {
         this.policyFactory = policyFactory;
-        this.extnTypeFactory = extnTypeFactory;
-        this.extensionProcessor = extensionProcessor;
+        this.attachPointTypeFactory = attachPointTypeFactory;
     }
     
-    public IntentAttachPointType read(XMLStreamReader reader) throws ContributionReadException {
+    public IntentAttachPointType read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
         QName type = getQName(reader, TYPE);
         
         if ( type != null ) {
             if ( type.getLocalPart().startsWith(BINDING) ) {
-                IntentAttachPointType bindingType = extnTypeFactory.createBindingType();
+                IntentAttachPointType bindingType = attachPointTypeFactory.createBindingType();
                 bindingType.setName(type);
                 
                 readAlwaysProvidedIntents(bindingType, reader);
                 readMayProvideIntents(bindingType, reader);
                 return bindingType; 
             } else if ( type.getLocalPart().startsWith(IMPLEMENTATION) ) {
-                IntentAttachPointType implType = extnTypeFactory.createImplementationType();
+                IntentAttachPointType implType = attachPointTypeFactory.createImplementationType();
                 implType.setName(type);
                 
                 readAlwaysProvidedIntents(implType, reader);
@@ -83,7 +82,7 @@
         }
     }
 
-    protected void readAlwaysProvidedIntents(IntentAttachPointType extnType, XMLStreamReader reader) {
+    private void readAlwaysProvidedIntents(IntentAttachPointType extnType, XMLStreamReader reader) {
         String value = reader.getAttributeValue(null, ALWAYS_PROVIDES);
         if (value != null) {
             List<Intent> alwaysProvided = extnType.getAlwaysProvidedIntents();
@@ -96,7 +95,7 @@
         }
     }
     
-    protected void readMayProvideIntents(IntentAttachPointType extnType, XMLStreamReader reader) {
+    private void readMayProvideIntents(IntentAttachPointType extnType, XMLStreamReader reader) {
         String value = reader.getAttributeValue(null, MAY_PROVIDE);
         if (value != null) {
             List<Intent> mayProvide = extnType.getMayProvideIntents();
@@ -109,26 +108,22 @@
         }
     }
   
-    public void write(IntentAttachPointType extnType, XMLStreamWriter writer) throws ContributionWriteException {
-        try {
-            // Write an <sca:bindingType or sca:implementationType>
-            if ( extnType instanceof BindingTypeImpl ) {
-                writer.writeStartElement(SCA10_NS, BINDING_TYPE);
-            } else if ( extnType instanceof ImplementationTypeImpl ) {
-                writer.writeStartElement(SCA10_NS, IMPLEMENATION_TYPE);
-            }
-            
-            writeAlwaysProvidesIntentsAttribute(extnType, writer);
-            writeMayProvideIntentsAttribute(extnType, writer);
-            
-            writer.writeEndElement();
-            
-        } catch (XMLStreamException e) {
-            throw new ContributionWriteException(e);
+    public void write(IntentAttachPointType extnType, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+
+        // Write an <sca:bindingType or sca:implementationType>
+        if ( extnType instanceof BindingTypeImpl ) {
+            writer.writeStartElement(SCA10_NS, BINDING_TYPE);
+        } else if ( extnType instanceof ImplementationTypeImpl ) {
+            writer.writeStartElement(SCA10_NS, IMPLEMENTATION_TYPE);
         }
+        
+        writeAlwaysProvidesIntentsAttribute(extnType, writer);
+        writeMayProvideIntentsAttribute(extnType, writer);
+        
+        writer.writeEndElement();
     }
     
-    protected void writeMayProvideIntentsAttribute(IntentAttachPointType extnType, XMLStreamWriter writer) throws XMLStreamException {
+    private void writeMayProvideIntentsAttribute(IntentAttachPointType extnType, XMLStreamWriter writer) throws XMLStreamException {
         StringBuffer sb  = new StringBuffer();
         for ( Intent intent : extnType.getMayProvideIntents() ) {
             writer.writeNamespace(intent.getName().getPrefix(), intent.getName().getNamespaceURI());
@@ -141,7 +136,7 @@
         }
     }
     
-    protected void writeAlwaysProvidesIntentsAttribute(IntentAttachPointType extnType, XMLStreamWriter writer) throws XMLStreamException {
+    private void writeAlwaysProvidesIntentsAttribute(IntentAttachPointType extnType, XMLStreamWriter writer) throws XMLStreamException {
         StringBuffer sb  = new StringBuffer();
         for ( Intent intent : extnType.getAlwaysProvidedIntents() ) {
             writer.writeNamespace(intent.getName().getPrefix(), intent.getName().getNamespaceURI());
@@ -209,31 +204,6 @@
 //        }
 //        extnType.setUnresolved(isUnresolved);
 //    }
-    
-    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 QName getQName(XMLStreamReader reader, String name) {
-        String qname = reader.getAttributeValue(null, name);
-        return getQNameValue(reader, qname);
-    }
-    
-
-    protected String getString(XMLStreamReader reader, String name) {
-        return reader.getAttributeValue(null, name);
-    }
     
     public Class<IntentAttachPointType> getModelType() {
         return IntentAttachPointType.class;

Modified: incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java?rev=572267&r1=572266&r2=572267&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java (original)
+++ incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java Mon Sep  3 02:46:41 2007
@@ -47,9 +47,9 @@
     String ALWAYS_PROVIDES = "alwaysProvides";
     String MAY_PROVIDE = "mayProvide";
     String TYPE = "type";
-    String IMPLEMENATION_TYPE = "implementationType";
+    String IMPLEMENTATION_TYPE = "implementationType";
     String BINDING_TYPE = "bindingType";
-    QName IMPLEMENTATION_TYPE_QNAME = new QName(SCA10_NS, IMPLEMENATION_TYPE);
+    QName IMPLEMENTATION_TYPE_QNAME = new QName(SCA10_NS, IMPLEMENTATION_TYPE);
     QName BINDING_TYPE_QNAME = new QName(SCA10_NS, BINDING_TYPE);
     String BINDING = "binding";
     String IMPLEMENTATION = "implementation";
@@ -57,7 +57,7 @@
     QName POLICY_INTENT_QNAME = new QName(SCA10_NS, INTENT);
     QName POLICY_SET_QNAME = new QName(SCA10_NS, POLICY_SET);
     QName POLICY_INTENT_MAP_QNAME = new QName(SCA10_NS, INTENT_MAP); 
-    QName SCA_DEFNS_QNAME = new QName(SCA10_NS, SCA_DEFINITIONS);
+    QName SCA_DEFINITIONS_QNAME = new QName(SCA10_NS, SCA_DEFINITIONS);
     QName DESCRIPTION_QNAME = new QName(SCA10_NS, DESCRIPTION);
     QName POLICY_INTENT_MAP_QUALIFIER_QNAME = new QName(SCA10_NS, INTENT_MAP_QUALIFIER);
     QName POLICY_SET_REFERENCE_QNAME = new QName(SCA10_NS, POLICY_SET_REFERENCE);

Modified: incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java?rev=572267&r1=572266&r2=572267&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java Mon Sep  3 02:46:41 2007
@@ -30,6 +30,7 @@
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
 import org.apache.tuscany.sca.contribution.service.ContributionReadException;
@@ -44,119 +45,107 @@
  * Processor for handling xml models of PolicyIntent definitions
  */
 
-public abstract class PolicyIntentProcessor<T extends Intent> implements StAXArtifactProcessor<T>, PolicyConstants {
+public abstract class PolicyIntentProcessor<T extends Intent> extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<T>, PolicyConstants {
 
     private PolicyFactory policyFactory;
-    protected StAXArtifactProcessor<Object> extensionProcessor;
 
     public PolicyIntentProcessor(PolicyFactory policyFactory, StAXArtifactProcessor<Object> extensionProcessor) {
         this.policyFactory = policyFactory;
-        this.extensionProcessor = extensionProcessor;
     }
 
-    public T read(XMLStreamReader reader) throws ContributionReadException {
-        try {
-            Intent policyIntent = null;
-            String policyIntentName = reader.getAttributeValue(null, NAME);
-            // Read an <sca:intent>
-            if (reader.getAttributeValue(null, REQUIRES) != null) {
-                policyIntent = policyFactory.createProfileIntent();
-            } else if ( policyIntentName != null && policyIntentName.indexOf(QUALIFIER) != -1) {
-                policyIntent = policyFactory.createQualifiedIntent();
-                
-                int qualifierIndex = policyIntentName.lastIndexOf(QUALIFIER);
-                Intent qualifiableIntent = policyFactory.createIntent();
-                qualifiableIntent.setUnresolved(true);
-                qualifiableIntent.setName(getQNameValue(reader, 
-                                                        policyIntentName.substring(0, qualifierIndex)));
-                
-                ((QualifiedIntent)policyIntent).setQualifiableIntent(qualifiableIntent);
-            } else {
-                policyIntent = policyFactory.createIntent();
-            }
-            policyIntent.setName(getQNameValue(reader, policyIntentName));
-            
-            if ( policyIntent instanceof ProfileIntent ) {
-                readRequiredIntents((ProfileIntent)policyIntent, reader);
-            }
-            
-            readConstrainedArtifacts(policyIntent, reader);
+    public T read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+        Intent policyIntent = null;
+        String policyIntentName = reader.getAttributeValue(null, NAME);
+        // Read an <sca:intent>
+        if (reader.getAttributeValue(null, REQUIRES) != null) {
+            policyIntent = policyFactory.createProfileIntent();
+        } else if ( policyIntentName != null && policyIntentName.indexOf(QUALIFIER) != -1) {
+            policyIntent = policyFactory.createQualifiedIntent();
+            
+            int qualifierIndex = policyIntentName.lastIndexOf(QUALIFIER);
+            Intent qualifiableIntent = policyFactory.createIntent();
+            qualifiableIntent.setUnresolved(true);
+            qualifiableIntent.setName(getQNameValue(reader, 
+                                                    policyIntentName.substring(0, qualifierIndex)));
             
-            int event = reader.getEventType();
-            QName name = null;
-            while (reader.hasNext()) {
-                event = reader.getEventType();
-                switch (event) {
-                    case START_ELEMENT : {
-                        name = reader.getName();
-                        if (DESCRIPTION_QNAME.equals(name)) {
-                            policyIntent.setDescription(reader.getElementText());
-                        }
-                        break;
+            ((QualifiedIntent)policyIntent).setQualifiableIntent(qualifiableIntent);
+        } else {
+            policyIntent = policyFactory.createIntent();
+        }
+        policyIntent.setName(getQNameValue(reader, policyIntentName));
+        
+        if ( policyIntent instanceof ProfileIntent ) {
+            readRequiredIntents((ProfileIntent)policyIntent, reader);
+        }
+        
+        readConstrainedArtifacts(policyIntent, reader);
+        
+        int event = reader.getEventType();
+        QName name = null;
+        while (reader.hasNext()) {
+            event = reader.getEventType();
+            switch (event) {
+                case START_ELEMENT : {
+                    name = reader.getName();
+                    if (DESCRIPTION_QNAME.equals(name)) {
+                        policyIntent.setDescription(reader.getElementText());
                     }
-                }
-                if (event == END_ELEMENT && POLICY_INTENT_QNAME.equals(reader.getName())) {
                     break;
                 }
-                
-                //Read the next element
-                if (reader.hasNext()) {
-                    reader.next();
-                }
             }
-            return (T)policyIntent;
-            
-        } catch (XMLStreamException e) {
-            throw new ContributionReadException(e);
-        }
-    }
-    
-    public void write(T policyIntent, XMLStreamWriter writer) throws ContributionWriteException {
-        try {
-            // Write an <sca:intent>
-            writer.writeStartElement(PolicyConstants.SCA10_NS, INTENT);
-            writer.writeNamespace(policyIntent.getName().getPrefix(), policyIntent.getName().getNamespaceURI());
-            writer.writeAttribute(PolicyConstants.NAME, 
-                                  policyIntent.getName().getPrefix() + COLON + policyIntent.getName().getLocalPart());
-            if (policyIntent instanceof ProfileIntent) {
-                ProfileIntent profileIntent = (ProfileIntent)policyIntent;
-                if (profileIntent.getRequiredIntents() != null && 
-                    profileIntent.getRequiredIntents().size() > 0) {
-                    StringBuffer sb = new StringBuffer();
-                    for (Intent requiredIntents : profileIntent.getRequiredIntents()) {
-                        sb.append(requiredIntents.getName());
-                        sb.append(" ");
-                    }
-                    writer.writeAttribute(PolicyConstants.REQUIRES, sb.toString());
-                }
+            if (event == END_ELEMENT && POLICY_INTENT_QNAME.equals(reader.getName())) {
+                break;
             }
             
-            if (!(policyIntent instanceof QualifiedIntent) ) {
-                if (policyIntent.getConstrains() != null && 
-                    policyIntent.getConstrains().size() > 0) {
-                    StringBuffer sb = new StringBuffer();
-                    for (QName contrainedArtifact : policyIntent.getConstrains()) {
-                        sb.append(contrainedArtifact.toString());
-                        sb.append(" ");
-                    }
-                    writer.writeAttribute(CONSTRAINS, sb.toString());
-                } else {
-                    throw new ContributionWriteException("Contrains attribute missing from " +
-                                    "Policy Intent Definition" + policyIntent.getName());
+            //Read the next element
+            if (reader.hasNext()) {
+                reader.next();
+            }
+        }
+        return (T)policyIntent;
+    }
+    
+    public void write(T policyIntent, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+        // Write an <sca:intent>
+        writer.writeStartElement(PolicyConstants.SCA10_NS, INTENT);
+        writer.writeNamespace(policyIntent.getName().getPrefix(), policyIntent.getName().getNamespaceURI());
+        writer.writeAttribute(PolicyConstants.NAME, 
+                              policyIntent.getName().getPrefix() + COLON + policyIntent.getName().getLocalPart());
+        if (policyIntent instanceof ProfileIntent) {
+            ProfileIntent profileIntent = (ProfileIntent)policyIntent;
+            if (profileIntent.getRequiredIntents() != null && 
+                profileIntent.getRequiredIntents().size() > 0) {
+                StringBuffer sb = new StringBuffer();
+                for (Intent requiredIntents : profileIntent.getRequiredIntents()) {
+                    sb.append(requiredIntents.getName());
+                    sb.append(" ");
                 }
+                writer.writeAttribute(PolicyConstants.REQUIRES, sb.toString());
             }
-            
-            if ( policyIntent.getDescription() != null && policyIntent.getDescription().length() > 0) {
-                writer.writeStartElement(PolicyConstants.SCA10_NS, DESCRIPTION);
-                writer.writeCData(policyIntent.getDescription());
-                writer.writeEndElement();
+        }
+        
+        if (!(policyIntent instanceof QualifiedIntent) ) {
+            if (policyIntent.getConstrains() != null && 
+                policyIntent.getConstrains().size() > 0) {
+                StringBuffer sb = new StringBuffer();
+                for (QName contrainedArtifact : policyIntent.getConstrains()) {
+                    sb.append(contrainedArtifact.toString());
+                    sb.append(" ");
+                }
+                writer.writeAttribute(CONSTRAINS, sb.toString());
+            } else {
+                throw new ContributionWriteException("Contrains attribute missing from " +
+                                "Policy Intent Definition" + policyIntent.getName());
             }
-            
+        }
+        
+        if ( policyIntent.getDescription() != null && policyIntent.getDescription().length() > 0) {
+            writer.writeStartElement(PolicyConstants.SCA10_NS, DESCRIPTION);
+            writer.writeCData(policyIntent.getDescription());
             writer.writeEndElement();
-            
-        } catch (XMLStreamException e) {
-            throw new ContributionWriteException(e);
         }
+        
+        writer.writeEndElement();
     }
 
     //FIXME This method is never used
@@ -201,7 +190,7 @@
 //        return policyIntent;
 //    }
     
-    protected void resolveContrainedArtifacts(Intent policyIntent, ModelResolver resolver) {
+    private void resolveContrainedArtifacts(Intent policyIntent, ModelResolver resolver) {
         //FIXME : need to figure out this resolution. 
         policyIntent.setUnresolved(false);
     }
@@ -218,7 +207,7 @@
         return POLICY_INTENT_QNAME;
     }
     
-    protected void readConstrainedArtifacts(Intent policyIntent, XMLStreamReader reader) throws ContributionReadException {
+    private void readConstrainedArtifacts(Intent policyIntent, XMLStreamReader reader) throws ContributionReadException {
         String value = reader.getAttributeValue(null, CONSTRAINS);
         if ( policyIntent instanceof QualifiedIntent && value != null) {
             String errorMsg = 
@@ -235,7 +224,7 @@
         }
     }
     
-    protected void readRequiredIntents(ProfileIntent policyIntent, XMLStreamReader reader) {
+    private void readRequiredIntents(ProfileIntent policyIntent, XMLStreamReader reader) {
         String value = reader.getAttributeValue(null, REQUIRES);
         if (value != null) {
             List<Intent> requiredIntents = policyIntent.getRequiredIntents();
@@ -249,18 +238,4 @@
         }
     }
     
-    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;
-        }
-    }
 }

Modified: incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java?rev=572267&r1=572266&r2=572267&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java Mon Sep  3 02:46:41 2007
@@ -32,6 +32,7 @@
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
 import org.apache.tuscany.sca.contribution.service.ContributionReadException;
@@ -46,10 +47,10 @@
 /* 
  * Processor for handling xml models of PolicySet definitions
  */
-public class PolicySetProcessor implements StAXArtifactProcessor<PolicySet>, PolicyConstants {
+public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<PolicySet>, PolicyConstants {
 
     private PolicyFactory policyFactory;
-    protected StAXArtifactProcessor<Object> extensionProcessor;
+    private StAXArtifactProcessor<Object> extensionProcessor;
     
 
     public PolicySetProcessor(PolicyFactory policyFactory, StAXArtifactProcessor<Object> extensionProcessor) {
@@ -57,58 +58,53 @@
         this.extensionProcessor = extensionProcessor;
     }
 
-    public PolicySet read(XMLStreamReader reader) throws ContributionReadException {
-        try {
-            PolicySet policySet = policyFactory.createPolicySet();
-            policySet.setName(getQName(reader, NAME));
-            policySet.setAppliesTo(reader.getAttributeValue(null, APPLIES_TO));
-            readProvidedIntents(policySet, reader);
-            
-            int event = reader.getEventType();
-            QName name = null;
-            reader.next();
-            while (reader.hasNext()) {
-                event = reader.getEventType();
-                switch (event) {
-                    case START_ELEMENT : {
-                        name = reader.getName();
-                        if ( POLICY_INTENT_MAP_QNAME.equals(name) ) {
-                            Intent mappedIntent = policyFactory.createIntent();
-                            mappedIntent.setName(getQName(reader, PROVIDES));
-                            if ( policySet.getProvidedIntents().contains(mappedIntent) ) {
-                                readIntentMap(reader, policySet, mappedIntent);
-                            } else {
-                                throw new ContributionReadException("Intent Map provides for Intent not spcified as provided by parent PolicySet - " +policySet.getName());
-                            }
-                        } else if ( POLICY_SET_REFERENCE_QNAME.equals(name) )  {
-                            PolicySet referredPolicySet = policyFactory.createPolicySet();
-                            referredPolicySet.setName(getQName(reader, NAME));
-                            policySet.getReferencedPolicySets().add(referredPolicySet);
+    public PolicySet read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+        PolicySet policySet = policyFactory.createPolicySet();
+        policySet.setName(getQName(reader, NAME));
+        policySet.setAppliesTo(reader.getAttributeValue(null, APPLIES_TO));
+        readProvidedIntents(policySet, reader);
+        
+        int event = reader.getEventType();
+        QName name = null;
+        reader.next();
+        while (reader.hasNext()) {
+            event = reader.getEventType();
+            switch (event) {
+                case START_ELEMENT : {
+                    name = reader.getName();
+                    if ( POLICY_INTENT_MAP_QNAME.equals(name) ) {
+                        Intent mappedIntent = policyFactory.createIntent();
+                        mappedIntent.setName(getQName(reader, PROVIDES));
+                        if ( policySet.getProvidedIntents().contains(mappedIntent) ) {
+                            readIntentMap(reader, policySet, mappedIntent);
                         } else {
-                            Object extension = extensionProcessor.read(reader);
-                            if ( extension instanceof Policy ) {
-                                policySet.getPolicies().add(extension);
-                            }
+                            throw new ContributionReadException("Intent Map provides for Intent not spcified as provided by parent PolicySet - " +policySet.getName());
+                        }
+                    } else if ( POLICY_SET_REFERENCE_QNAME.equals(name) )  {
+                        PolicySet referredPolicySet = policyFactory.createPolicySet();
+                        referredPolicySet.setName(getQName(reader, NAME));
+                        policySet.getReferencedPolicySets().add(referredPolicySet);
+                    } else {
+                        Object extension = extensionProcessor.read(reader);
+                        if ( extension instanceof Policy ) {
+                            policySet.getPolicies().add(extension);
                         }
-                        break;
                     }
+                    break;
                 }
-                if ( event == END_ELEMENT ) {
-                    if ( POLICY_SET_QNAME.equals(reader.getName()) ) {
-                        break;
-                    } 
-                }
-                
-                //Read the next element
-                if (reader.hasNext()) {
-                    reader.next();
-                }
             }
-            return policySet;
+            if ( event == END_ELEMENT ) {
+                if ( POLICY_SET_QNAME.equals(reader.getName()) ) {
+                    break;
+                } 
+            }
             
-        } catch (XMLStreamException e) {
-            throw new ContributionReadException(e);
+            //Read the next element
+            if (reader.hasNext()) {
+                reader.next();
+            }
         }
+        return policySet;
     }
     
     
@@ -199,26 +195,21 @@
         }
     }
     
-    public void write(PolicySet policySet, XMLStreamWriter writer) throws ContributionWriteException {
-        try {
-            // Write an <sca:policySet>
-            writer.writeStartElement(SCA10_NS, POLICY_SET);
-            writer.writeNamespace(policySet.getName().getPrefix(), policySet.getName().getNamespaceURI());
-            writer.writeAttribute(NAME, 
-                                  policySet.getName().getPrefix() + COLON + policySet.getName().getLocalPart());
-            writer.writeAttribute(APPLIES_TO, policySet.getAppliesTo());
-            
-            writeProvidedIntents(policySet, writer);
-            
-            
-            writer.writeEndElement();
-            
-        } catch (XMLStreamException e) {
-            throw new ContributionWriteException(e);
-        }
+    public void write(PolicySet policySet, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+
+        // Write an <sca:policySet>
+        writer.writeStartElement(SCA10_NS, POLICY_SET);
+        writer.writeNamespace(policySet.getName().getPrefix(), policySet.getName().getNamespaceURI());
+        writer.writeAttribute(NAME, 
+                              policySet.getName().getPrefix() + COLON + policySet.getName().getLocalPart());
+        writer.writeAttribute(APPLIES_TO, policySet.getAppliesTo());
+        
+        writeProvidedIntents(policySet, writer);
+        
+        writer.writeEndElement();
     }
     
-    protected void readProvidedIntents(PolicySet policySet, XMLStreamReader reader) {
+    private void readProvidedIntents(PolicySet policySet, XMLStreamReader reader) {
         String value = reader.getAttributeValue(null, PROVIDES);
         if (value != null) {
             List<Intent> providedIntents = policySet.getProvidedIntents();
@@ -231,7 +222,7 @@
         }
     }
     
-    protected void writeProvidedIntents(PolicySet policySet, XMLStreamWriter writer) throws XMLStreamException {
+    private void writeProvidedIntents(PolicySet policySet, XMLStreamWriter writer) throws XMLStreamException {
         if (policySet.getProvidedIntents() != null && 
             policySet.getProvidedIntents().size() > 0) {
             StringBuffer sb = new StringBuffer();
@@ -315,28 +306,4 @@
         return PolicySet.class;
     }
     
-    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 QName getQName(XMLStreamReader reader, String name) {
-        String qname = reader.getAttributeValue(null, name);
-        return getQNameValue(reader, qname);
-    }
-    
-
-    protected String getString(XMLStreamReader reader, String name) {
-        return reader.getAttributeValue(null, name);
-    }
 }

Modified: incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsDocumentProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsDocumentProcessor.java?rev=572267&r1=572266&r2=572267&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsDocumentProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsDocumentProcessor.java Mon Sep  3 02:46:41 2007
@@ -45,14 +45,9 @@
  * 
  */
 public class SCADefinitionsDocumentProcessor  implements URLArtifactProcessor<SCADefinitions> {
-    protected StAXArtifactProcessor<Object> extensionProcessor;
-    protected SCADefinitionsBuilder defnBuilder = null;
-    protected ModelResolver domainModelResolver;
-
-    private static final DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
-    static {
-        domFactory.setNamespaceAware(true);
-    }
+    private StAXArtifactProcessor<Object> extensionProcessor;
+    private SCADefinitionsBuilder definitionsBuilder;
+    private ModelResolver domainModelResolver;
     private XMLInputFactory inputFactory;
 
     /**
@@ -60,21 +55,14 @@
      * @param assemblyFactory
      * @param policyFactory
      * @param staxProcessor
-    
-    public SCADefinitionsDocumentProcessor(StAXArtifactProcessor staxProcessor, XMLInputFactory inputFactory) {
-        this.extensionProcessor = staxProcessor;
-        this.inputFactory = inputFactory;
-        defnBuilder = new SCADefinitionsBuilderImpl();
-        this.domainModelResolver =  new SCADefinitionsResolver();
-    } */
-     
+     */
     public SCADefinitionsDocumentProcessor(StAXArtifactProcessorExtensionPoint staxProcessors,
-                                           StAXArtifactProcessor staxProcessor,
+                                           StAXArtifactProcessor<Object> staxProcessor,
                                            XMLInputFactory inputFactory,
                                            PolicyFactory policyFactory) {
         this.extensionProcessor = (StAXArtifactProcessor<Object>)staxProcessor;
         this.inputFactory = inputFactory;
-        defnBuilder = new SCADefinitionsBuilderImpl();
+        definitionsBuilder = new SCADefinitionsBuilderImpl();
         this.domainModelResolver = new SCADefinitionsResolver();
         
         IntentAttachPointTypeFactory intentAttachPointFactory = new DefaultIntentAttachPointTypeFactoryImpl();
@@ -122,7 +110,7 @@
             if ( resolver == null ) {
                 resolver = this.domainModelResolver;
             }
-            defnBuilder.build(scaDefinitions);
+            definitionsBuilder.build(scaDefinitions);
             extensionProcessor.resolve(scaDefinitions, resolver);
         } catch (SCADefinitionsBuilderException e) {
             throw new ContributionResolveException(e);

Modified: incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsProcessor.java?rev=572267&r1=572266&r2=572267&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsProcessor.java Mon Sep  3 02:46:41 2007
@@ -31,7 +31,9 @@
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor.XAttr;
 import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
 import org.apache.tuscany.sca.contribution.service.ContributionReadException;
 import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
@@ -47,13 +49,10 @@
  * Processor for SCA Definitions
  * 
  */
-public class SCADefinitionsProcessor implements StAXArtifactProcessor<SCADefinitions>, PolicyConstants {
+public class SCADefinitionsProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<SCADefinitions>, PolicyConstants {
     
-    protected PolicyFactory policyFactory;
-    protected StAXArtifactProcessor<Object> extensionProcessor;
-    protected ModelResolver definitionsResolver;
-    
-    //protected PolicyIntentProcessor policyIntentResolver;
+    private StAXArtifactProcessor<Object> extensionProcessor;
+    private ModelResolver definitionsResolver;
     
     /**
      * Construct a new (sca) definitions processor
@@ -61,10 +60,8 @@
      * @param extensionProcessor 
      */
     public SCADefinitionsProcessor(PolicyFactory policyFactory,
-                              StAXArtifactProcessor extensionProcessor) {
-        this.policyFactory = policyFactory;
+                              StAXArtifactProcessor<Object> extensionProcessor) {
         this.extensionProcessor = extensionProcessor;
-        //this.policyIntentResolver = new PolicyIntentProcessor(policyFactory, extensionProcessor);
     }
     
     /**
@@ -74,193 +71,86 @@
      * @param modelResolver 
      */
     public SCADefinitionsProcessor(PolicyFactory policyFactory,
-                              StAXArtifactProcessor extensionProcessor,
+                              StAXArtifactProcessor<Object> extensionProcessor,
                               ModelResolver modelResolver) {
-        this.policyFactory = policyFactory;
         this.extensionProcessor = extensionProcessor;
-        //this.policyIntentResolver = new PolicyIntentProcessor(policyFactory, extensionProcessor);
         this.definitionsResolver = modelResolver;
     }
 
-    /**
-     * Returns a qname from a string.  
-     * @param reader
-     * @param value
-     * @return
-     */
-    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;
-        }
-    }
-    
-    /**
-     * Returns the qname value of an attribute.
-     * @param reader
-     * @param name
-     * @return
-     */
-    protected QName getQName(XMLStreamReader reader, String name) {
-        String qname = reader.getAttributeValue(null, name);
-        return getQNameValue(reader, qname);
-    }
-    
-    public SCADefinitions read(XMLStreamReader reader) throws ContributionReadException {
+    public SCADefinitions read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
         QName name = null;
-        SCADefinitions scaDefns = null;
-        try {
-            // Read the composite document
-            while (reader.hasNext()) {
-                int event = reader.getEventType();
-                switch (event) {
-                    case START_ELEMENT: {
-                        name = reader.getName();
-                        if ( SCA_DEFNS_QNAME.equals(name)) {
-                            scaDefns = new SCADefinitionsImpl();
-                            try {
-                                scaDefns.setTargetNamespace(new URI(reader.getAttributeValue(null, TARGET_NAMESPACE)));
-                            } catch ( URISyntaxException e ) {
-                                throw new ContributionReadException(e);
-                            }
-                        } else {
-                            Object extension = extensionProcessor.read(reader);
-                            if (extension != null) {
-                                if ( extension instanceof Intent ) {
-                                    scaDefns.getPolicyIntents().add((Intent)extension);
-                                } else if ( extension instanceof PolicySet ) {
-                                    scaDefns.getPolicySets().add((PolicySet)extension);
-                                } else if ( extension instanceof IntentAttachPointType ) {
-                                    IntentAttachPointType type = (IntentAttachPointType)extension;
-                                    if ( type.getName().getLocalPart().startsWith(BINDING)) {
-                                        scaDefns.getBindingTypes().add((IntentAttachPointType)extension);
-                                    } else if ( type.getName().getLocalPart().startsWith(IMPLEMENTATION)) {
-                                        scaDefns.getImplementationTypes().add((IntentAttachPointType)extension);
-                                    }
-                                } 
-                                
-                                if ( getDefinitionsResolver() != null ) {
-                                    getDefinitionsResolver().addModel(extension);
+        SCADefinitions definitions = null;
+
+        // Read the composite document
+        while (reader.hasNext()) {
+            int event = reader.getEventType();
+            switch (event) {
+                case START_ELEMENT: {
+                    name = reader.getName();
+                    if ( SCA_DEFINITIONS_QNAME.equals(name)) {
+                        definitions = new SCADefinitionsImpl();
+                        definitions.setTargetNamespace(reader.getAttributeValue(null, TARGET_NAMESPACE));
+                    } else {
+                        Object extension = extensionProcessor.read(reader);
+                        if (extension != null) {
+                            if ( extension instanceof Intent ) {
+                                definitions.getPolicyIntents().add((Intent)extension);
+                            } else if ( extension instanceof PolicySet ) {
+                                definitions.getPolicySets().add((PolicySet)extension);
+                            } else if ( extension instanceof IntentAttachPointType ) {
+                                IntentAttachPointType type = (IntentAttachPointType)extension;
+                                if ( type.getName().getLocalPart().startsWith(BINDING)) {
+                                    definitions.getBindingTypes().add((IntentAttachPointType)extension);
+                                } else if ( type.getName().getLocalPart().startsWith(IMPLEMENTATION)) {
+                                    definitions.getImplementationTypes().add((IntentAttachPointType)extension);
                                 }
+                            } 
+                            
+                            if ( getDefinitionsResolver() != null ) {
+                                getDefinitionsResolver().addModel(extension);
                             }
-                            break;
                         }
-                    }
-    
-                    case XMLStreamConstants.CHARACTERS:
                         break;
-    
-                    case END_ELEMENT:
-                        break;
-                }
-                
-                //Read the next element
-                if (reader.hasNext()) {
-                    reader.next();
+                    }
                 }
+
+                case XMLStreamConstants.CHARACTERS:
+                    break;
+
+                case END_ELEMENT:
+                    break;
             }
-            return scaDefns;
             
-        } catch (XMLStreamException e) {
-            throw new ContributionReadException(e);
-        }
-    }
-    
-    /**
-     * Write attributes to the current element.
-     * @param writer
-     * @param attrs
-     * @throws XMLStreamException
-     */
-    protected void writeAttributes(XMLStreamWriter writer, XAttr... attrs) throws XMLStreamException {
-        for (XAttr attr : attrs) {
-            if (attr != null)
-                attr.write(writer);
+            //Read the next element
+            if (reader.hasNext()) {
+                reader.next();
+            }
         }
+        return definitions;
     }
     
-    /**
-     * Start an element.
-     * @param uri
-     * @param name
-     * @param attrs
-     * @throws XMLStreamException
-     */
-    protected void writeStart(XMLStreamWriter writer, String uri, String name, XAttr... attrs) throws XMLStreamException {
-        writer.writeStartElement(uri, name);
-        writeAttributes(writer, attrs);
-    }
+    public void write(SCADefinitions definitions, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
 
-    /**
-     * Start an element.
-     * @param writer
-     * @param name
-     * @param attrs
-     * @throws XMLStreamException
-     */
-    protected void writeStart(XMLStreamWriter writer, String name, XAttr... attrs) throws XMLStreamException {
-        writer.writeStartElement(SCA10_NS, name);
-        writeAttributes(writer, attrs);
-    }
-    
-    /**
-     * Start a document.
-     * @param writer
-     * @throws XMLStreamException
-     */
-    protected void writeStartDocument(XMLStreamWriter writer, String name, XAttr... attrs) throws XMLStreamException {
-        writer.writeStartDocument();
-        writer.setDefaultNamespace(SCA10_NS);
-        writeStart(writer, name, attrs);
-        writer.writeDefaultNamespace(SCA10_NS);
-    }
+        writeStartDocument(writer, SCA10_NS, SCA_DEFINITIONS, 
+                               new XAttr(TARGET_NAMESPACE, definitions.getTargetNamespace().toString()));
     
-    /**
-     * End a document.
-     * @param writer
-     * @throws XMLStreamException
-     */
-    protected void writeEndDocument(XMLStreamWriter writer) throws XMLStreamException {
-        writer.writeEndDocument();
-    }
-    
-    public void write(SCADefinitions scaDefns, XMLStreamWriter writer) throws ContributionWriteException {
-
-        try {
-            writeStartDocument(writer, 
-                                   SCA_DEFINITIONS,
-                                   new XAttr(TARGET_NAMESPACE, scaDefns.getTargetNamespace().toString())
-                );
-    
-            for (Intent policyIntent : scaDefns.getPolicyIntents()) {
-                extensionProcessor.write(policyIntent, writer);
-            }
-            
-            for (PolicySet policySet : scaDefns.getPolicySets()) {
-                extensionProcessor.write(policySet, writer);
-            }
-            
-            for (IntentAttachPointType bindingType : scaDefns.getBindingTypes()) {
-                extensionProcessor.write(bindingType, writer);
-            }
-            
-            for (IntentAttachPointType implType : scaDefns.getImplementationTypes()) {
-                extensionProcessor.write(implType, writer);
-            }
-
-            writeEndDocument(writer);
-            
-        } catch (XMLStreamException e) {
-            throw new ContributionWriteException(e);
+        for (Intent policyIntent : definitions.getPolicyIntents()) {
+            extensionProcessor.write(policyIntent, writer);
         }
+        
+        for (PolicySet policySet : definitions.getPolicySets()) {
+            extensionProcessor.write(policySet, writer);
+        }
+        
+        for (IntentAttachPointType bindingType : definitions.getBindingTypes()) {
+            extensionProcessor.write(bindingType, writer);
+        }
+        
+        for (IntentAttachPointType implType : definitions.getImplementationTypes()) {
+            extensionProcessor.write(implType, writer);
+        }
+
+        writeEndDocument(writer);
     }
     
     public void resolve(SCADefinitions scaDefns, ModelResolver resolver) throws ContributionResolveException {
@@ -286,7 +176,7 @@
     }
     
     public QName getArtifactType() {
-        return SCA_DEFNS_QNAME;
+        return SCA_DEFINITIONS_QNAME;
     }
     
     public Class<SCADefinitions> getModelType() {

Modified: incubator/tuscany/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/MockPolicyProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/MockPolicyProcessor.java?rev=572267&r1=572266&r2=572267&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/MockPolicyProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/MockPolicyProcessor.java Mon Sep  3 02:46:41 2007
@@ -46,7 +46,6 @@
 
     public void write(Policy arg0, XMLStreamWriter arg1) throws ContributionWriteException,
                                                         XMLStreamException {
-
     }
 
     public Class<Policy> getModelType() {

Modified: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/SCADefinitions.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/SCADefinitions.java?rev=572267&r1=572266&r2=572267&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/SCADefinitions.java (original)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/SCADefinitions.java Mon Sep  3 02:46:41 2007
@@ -18,7 +18,6 @@
  */
 package org.apache.tuscany.sca.policy;
 
-import java.net.URI;
 import java.util.List;
 
 
@@ -31,14 +30,14 @@
      * Returns the target namespace for this SCA Definition
      * @return the target namespace
      */
-    URI getTargetNamespace();
+    String getTargetNamespace();
     
     /**
      * Sets the target names for this SCA Definition
      * 
      * @param the target namespace for this SCA Definition
      */
-    void setTargetNamespace(URI ns);
+    void setTargetNamespace(String ns);
 
     /**
      * Returns a list of domain wide Policy Intents

Modified: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/SCADefinitionsImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/SCADefinitionsImpl.java?rev=572267&r1=572266&r2=572267&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/SCADefinitionsImpl.java (original)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/SCADefinitionsImpl.java Mon Sep  3 02:46:41 2007
@@ -19,7 +19,6 @@
 
 package org.apache.tuscany.sca.policy.impl;
 
-import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -33,7 +32,7 @@
  *
  */
 public class SCADefinitionsImpl implements SCADefinitions {
-    private URI targetNamespace = null;
+    private String targetNamespace = null;
     private List<Intent> policyIntents = new ArrayList<Intent>();
     private List<PolicySet> policySets = new ArrayList<PolicySet>();
     private List<IntentAttachPointType> bindingTypes = new ArrayList<IntentAttachPointType>();
@@ -56,11 +55,11 @@
         return policySets;
     }
 
-    public URI getTargetNamespace() {
+    public String getTargetNamespace() {
         return targetNamespace;
     }
 
-    public void setTargetNamespace(URI ns) {
+    public void setTargetNamespace(String ns) {
        this.targetNamespace = ns;
     }
 

Modified: incubator/tuscany/java/sca/modules/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/pom.xml?rev=572267&r1=572266&r2=572267&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/pom.xml (original)
+++ incubator/tuscany/java/sca/modules/pom.xml Mon Sep  3 02:46:41 2007
@@ -70,9 +70,9 @@
                 <module>databinding-sdo</module>
                 <module>databinding-sdo-axiom</module>
                 <module>databinding-json</module>
-<!--
+                <!--
                 <module>databinding-saxon</module>
--->
+                -->
                 <module>databinding-xmlbeans</module>
                 <module>data-engine-helper</module>
                 <!--
@@ -102,13 +102,15 @@
                 <module>implementation-java-xml</module>
                 <module>implementation-java-runtime</module>
                 <module>implementation-notification</module>
+                <!--
                 <module>implementation-osgi</module>
+                -->
                 <module>implementation-resource</module>
                 <module>implementation-script</module>
                 <module>implementation-spring</module>
-<!--
+                <!--
                 <module>implementation-xquery</module>
--->
+                -->
                 <module>java2wsdl</module>
                 <!--
                 <module>jmx</module>

Copied: incubator/tuscany/java/sca/modules/topology-xml/src/main/java/org/apache/tuscany/sca/topology/xml/BaseTopologyArtifactProcessor.java (from r572232, incubator/tuscany/java/sca/modules/topology-xml/src/main/java/org/apache/tuscany/sca/topology/xml/BaseArtifactProcessor.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/topology-xml/src/main/java/org/apache/tuscany/sca/topology/xml/BaseTopologyArtifactProcessor.java?p2=incubator/tuscany/java/sca/modules/topology-xml/src/main/java/org/apache/tuscany/sca/topology/xml/BaseTopologyArtifactProcessor.java&p1=incubator/tuscany/java/sca/modules/topology-xml/src/main/java/org/apache/tuscany/sca/topology/xml/BaseArtifactProcessor.java&r1=572232&r2=572267&rev=572267&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/topology-xml/src/main/java/org/apache/tuscany/sca/topology/xml/BaseArtifactProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/topology-xml/src/main/java/org/apache/tuscany/sca/topology/xml/BaseTopologyArtifactProcessor.java Mon Sep  3 02:46:41 2007
@@ -19,23 +19,17 @@
 
 package org.apache.tuscany.sca.topology.xml;
 
-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.parsers.DocumentBuilderFactory;
 import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
-
 import org.apache.tuscany.sca.assembly.AssemblyFactory;
 import org.apache.tuscany.sca.assembly.Binding;
 import org.apache.tuscany.sca.assembly.Contract;
 import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
 import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
@@ -47,7 +41,7 @@
  * 
  * @version $Rev$ $Date$
  */
-public abstract class BaseArtifactProcessor implements Constants {
+public abstract class BaseTopologyArtifactProcessor extends BaseStAXArtifactProcessor implements Constants {
 
     protected TopologyFactory               topologyFactory;
     protected AssemblyFactory               assemblyFactory;    
@@ -64,111 +58,13 @@
      * @param policyFactory
      */
     @SuppressWarnings("unchecked")
-    public BaseArtifactProcessor(TopologyFactory topologyFactory, AssemblyFactory assemblyFactory, StAXArtifactProcessor extensionProcessor) {
+    public BaseTopologyArtifactProcessor(TopologyFactory topologyFactory, AssemblyFactory assemblyFactory, StAXArtifactProcessor extensionProcessor) {
         this.topologyFactory = topologyFactory;
         this.assemblyFactory = assemblyFactory;
         this.extensionProcessor = extensionProcessor;
     }
 
     /**
-     * Returns the string value of an attribute.
-     * @param reader
-     * @param name
-     * @return
-     */
-    protected String getString(XMLStreamReader reader, String name) {
-        return reader.getAttributeValue(null, name);
-    }
-
-    /**
-     * Returns the qname value of an attribute.
-     * @param reader
-     * @param name
-     * @return
-     */
-    protected QName getQName(XMLStreamReader reader, String name) {
-        String qname = reader.getAttributeValue(null, name);
-        return getQNameValue(reader, qname);
-    }
-
-    /**
-     * Returns 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);
-    }
-
-    /**
-     * Returns a qname from a string.  
-     * @param reader
-     * @param value
-     * @return
-     */
-    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;
-        }
-    }
-
-    /**
-     * Returns the boolean value of an attribute.
-     * @param reader
-     * @param name
-     * @return
-     */
-    protected boolean getBoolean(XMLStreamReader reader, String name) {
-        String value = reader.getAttributeValue(null, name);
-        if (value == null) {
-            value = Boolean.toString(false);
-        }
-        return Boolean.valueOf(value);
-    }
-
-    /**
-     * Returns the value of an attribute as a list of qnames.
-     * @param reader
-     * @param name
-     * @return
-     */
-    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();
-        }
-    }
-
-    /**
-     * Start an element.
-     * @param uri
-     * @param name
-     * @param attrs
-     * @throws XMLStreamException
-     */
-    protected void writeStart(XMLStreamWriter writer, String uri, String name, XAttr... attrs) throws XMLStreamException {
-        writer.writeStartElement(uri, name);
-        writeAttributes(writer, attrs);
-    }
-
-    /**
      * Start an element.
      * @param writer
      * @param name
@@ -176,17 +72,7 @@
      * @throws XMLStreamException
      */
     protected void writeStart(XMLStreamWriter writer, String name, XAttr... attrs) throws XMLStreamException {
-        writer.writeStartElement(TUSCANY_TOPOLOGY_10_NS, name);
-        writeAttributes(writer, attrs);
-    }
-
-    /**
-     * End an element. 
-     * @param writer
-     * @throws XMLStreamException
-     */
-    protected void writeEnd(XMLStreamWriter writer) throws XMLStreamException {
-        writer.writeEndElement();
+        writeStart(writer, TUSCANY_TOPOLOGY_10_NS, name, attrs);
     }
 
     /**
@@ -195,32 +81,7 @@
      * @throws XMLStreamException
      */
     protected void writeStartDocument(XMLStreamWriter writer, String name, XAttr... attrs) throws XMLStreamException {
-        writer.writeStartDocument();
-        writer.setDefaultNamespace(TUSCANY_TOPOLOGY_10_NS);
-        writeStart(writer, name, attrs);
-        writer.writeDefaultNamespace(TUSCANY_TOPOLOGY_10_NS);
-    }
-    
-    /**
-     * End a document.
-     * @param writer
-     * @throws XMLStreamException
-     */
-    protected void writeEndDocument(XMLStreamWriter writer) throws XMLStreamException {
-        writer.writeEndDocument();
-    }
-
-    /**
-     * Write attributes to the current element.
-     * @param writer
-     * @param attrs
-     * @throws XMLStreamException
-     */
-    protected void writeAttributes(XMLStreamWriter writer, XAttr... attrs) throws XMLStreamException {
-        for (XAttr attr : attrs) {
-            if (attr != null)
-                attr.write(writer);
-        }
+        writeStartDocument(writer, TUSCANY_TOPOLOGY_10_NS, name, attrs);
     }
     
     /**

Modified: incubator/tuscany/java/sca/modules/topology-xml/src/main/java/org/apache/tuscany/sca/topology/xml/TopologyDocumentProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/topology-xml/src/main/java/org/apache/tuscany/sca/topology/xml/TopologyDocumentProcessor.java?rev=572267&r1=572266&r2=572267&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/topology-xml/src/main/java/org/apache/tuscany/sca/topology/xml/TopologyDocumentProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/topology-xml/src/main/java/org/apache/tuscany/sca/topology/xml/TopologyDocumentProcessor.java Mon Sep  3 02:46:41 2007
@@ -40,7 +40,7 @@
  * 
  * @version $Rev$ $Date$
  */
-public class TopologyDocumentProcessor extends BaseArtifactProcessor implements URLArtifactProcessor<Runtime> {
+public class TopologyDocumentProcessor extends BaseTopologyArtifactProcessor implements URLArtifactProcessor<Runtime> {
     private XMLInputFactory inputFactory;
 
     /**

Modified: incubator/tuscany/java/sca/modules/topology-xml/src/main/java/org/apache/tuscany/sca/topology/xml/TopologyProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/topology-xml/src/main/java/org/apache/tuscany/sca/topology/xml/TopologyProcessor.java?rev=572267&r1=572266&r2=572267&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/topology-xml/src/main/java/org/apache/tuscany/sca/topology/xml/TopologyProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/topology-xml/src/main/java/org/apache/tuscany/sca/topology/xml/TopologyProcessor.java Mon Sep  3 02:46:41 2007
@@ -44,7 +44,7 @@
  * 
  * @version $Rev$ $Date$
  */
-public class TopologyProcessor extends BaseArtifactProcessor implements StAXArtifactProcessor<Runtime> {
+public class TopologyProcessor extends BaseTopologyArtifactProcessor implements StAXArtifactProcessor<Runtime> {
     
     /**
      * Construct a new composite processor
@@ -58,119 +58,108 @@
         super(topologyFactory, assemblyFactory, extensionProcessor);
     }
     
-    public Runtime read(XMLStreamReader reader) throws ContributionReadException {
+    public Runtime read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
         QName name = null;
         Runtime runtime = null;
         Node node = null;
         String domainName = DEFAULT_DOMAIN;
       
-        try {
-            
-            // Read the composite document
-            while (reader.hasNext()) {
-                int event = reader.getEventType();
-                switch (event) {
-                    case START_ELEMENT:
-                        name = reader.getName();
-                        
-                        if (RUNTIME_QNAME.equals(name)) {
-                            // Read a <runtime>
-                            runtime = topologyFactory.createRuntime();
-                        } else if (NODE_QNAME.equals(name)) {
-                            // Read a <node>
-                            node = topologyFactory.createNode();
-                            node.setName(getString(reader, NAME));
-                            
-                            // add node to runtime
-                            runtime.getNodes().add(node);
-                            
-                            // reset domain name to the default
-                            domainName = DEFAULT_DOMAIN;
-                        } else if (DOMAIN_QNAME.equals(name)) {
-                            // Read a <domain>
-                            domainName = getString(reader, NAME);                            
-                        } else if (SCHEME_QNAME.equals(name)) {
-                            // Read a <scheme>
-                            Scheme scheme = topologyFactory.createScheme();
-                            scheme.setName(getString(reader, NAME));
-                            scheme.setBaseURL(getString(reader, BASE_URL));
-                            
-                            scheme.setDomainName(domainName);
-                            
-                            // Add scheme to the node
-                            node.getSchemes(domainName).add(scheme);
-                        } else if (COMPONENT_QNAME.equals(name)) {
-                            // Read a <component>
-                            Component component = topologyFactory.createComponent();
-                            component.setName(getString(reader, NAME));
-                            
-                            component.setDomainName(domainName);
-                            
-                            // Add scheme to the node
-                            node.getComponents(domainName).add(component);                            
+        // Read the composite document
+        while (reader.hasNext()) {
+            int event = reader.getEventType();
+            switch (event) {
+                case START_ELEMENT:
+                    name = reader.getName();
+                    
+                    if (RUNTIME_QNAME.equals(name)) {
+                        // Read a <runtime>
+                        runtime = topologyFactory.createRuntime();
+                    } else if (NODE_QNAME.equals(name)) {
+                        // Read a <node>
+                        node = topologyFactory.createNode();
+                        node.setName(getString(reader, NAME));
+                        
+                        // add node to runtime
+                        runtime.getNodes().add(node);
+                        
+                        // reset domain name to the default
+                        domainName = DEFAULT_DOMAIN;
+                    } else if (DOMAIN_QNAME.equals(name)) {
+                        // Read a <domain>
+                        domainName = getString(reader, NAME);                            
+                    } else if (SCHEME_QNAME.equals(name)) {
+                        // Read a <scheme>
+                        Scheme scheme = topologyFactory.createScheme();
+                        scheme.setName(getString(reader, NAME));
+                        scheme.setBaseURL(getString(reader, BASE_URL));
+                        
+                        scheme.setDomainName(domainName);
+                        
+                        // Add scheme to the node
+                        node.getSchemes(domainName).add(scheme);
+                    } else if (COMPONENT_QNAME.equals(name)) {
+                        // Read a <component>
+                        Component component = topologyFactory.createComponent();
+                        component.setName(getString(reader, NAME));
+                        
+                        component.setDomainName(domainName);
+                        
+                        // Add scheme to the node
+                        node.getComponents(domainName).add(component);                            
 
-                        } else {
-                            
-                            // Read an extension element
-                            Object extension = extensionProcessor.read(reader);
-                            
-                            if (extension != null) {
-                                // no extensions are supported
-                            }
+                    } else {
+                        
+                        // Read an extension element
+                        Object extension = extensionProcessor.read(reader);
+                        
+                        if (extension != null) {
+                            // no extensions are supported
                         }
-    
-                    case END_ELEMENT:
-                        name = reader.getName();
-                        // Clear current state when reading reaching end element                
-                }
-                
-                if (reader.hasNext()) {
-                    reader.next();
-                }
+                    }
+
+                case END_ELEMENT:
+                    name = reader.getName();
+                    // Clear current state when reading reaching end element                
             }
-            return runtime;
-                        
-        } catch (XMLStreamException e) {
-            throw new ContributionReadException(e);
-        }        
+            
+            if (reader.hasNext()) {
+                reader.next();
+            }
+        }
+        return runtime;
     }
 
     
-    public void write(Runtime runtime, XMLStreamWriter writer) throws ContributionWriteException {
-        try {
-            writeStartDocument(writer, RUNTIME);
-            
-            // TODO - write out the scheme definitions
-    
-            for (Node node : runtime.getNodes()) {
-                writeStart(writer, NODE, new XAttr(NAME, node.getName()));
+    public void write(Runtime runtime, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+
+        writeStartDocument(writer, RUNTIME);
+        
+        // TODO - write out the scheme definitions
+
+        for (Node node : runtime.getNodes()) {
+            writeStart(writer, NODE, new XAttr(NAME, node.getName()));
+           
+            for (String domainName : node.getDomainNames()) {
+                
+                writeStart(writer, DOMAIN, new XAttr(NAME, domainName));
                
-    
-                for (String domainName : node.getDomainNames()) {
-                    
-                    writeStart(writer, DOMAIN, new XAttr(NAME, domainName));
-                   
-                    for (Scheme scheme: node.getSchemes(domainName)) {
-                        writeStart(writer, SCHEME, new XAttr(NAME, scheme.getName()), new XAttr(BASE_URL, scheme.getBaseURL()));
-                        writeEnd(writer);
-                    }
-                    
-                    for (Component component: node.getComponents(domainName)) {
-                        writeStart(writer, COMPONENT, new XAttr(NAME, component.getName()));
-                        writeEnd(writer);
-                    }                    
-                    
+                for (Scheme scheme: node.getSchemes(domainName)) {
+                    writeStart(writer, SCHEME, new XAttr(NAME, scheme.getName()), new XAttr(BASE_URL, scheme.getBaseURL()));
                     writeEnd(writer);
                 }
-      
+                
+                for (Component component: node.getComponents(domainName)) {
+                    writeStart(writer, COMPONENT, new XAttr(NAME, component.getName()));
+                    writeEnd(writer);
+                }                    
+                
                 writeEnd(writer);
             }
-       
-            writeEndDocument(writer);
-            
-        } catch (XMLStreamException e) {
-            throw new ContributionWriteException(e);
+  
+            writeEnd(writer);
         }
+   
+        writeEndDocument(writer);
     }
     
     public void resolve(Runtime runtime, ModelResolver resolver) throws ContributionResolveException {



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


Mime
View raw message