Hi, Jeremy.
 
Attached is a patch for the SDO DataBinding code in your sandbox. It ports the code to the new SPIs in the sandbox. Please review and apply.
 
There're several TODOs in the code. We need to understand how to get the corresponding SDO TypeHelper for a given DeploymentContext.
 
Thanks,
Raymond
Index: 
sdo/src/main/java/org/apache/tuscany/databinding/sdo/DataObjectLoader.java
===================================================================
--- sdo/src/main/java/org/apache/tuscany/databinding/sdo/DataObjectLoader.java  
(revision 0)
+++ sdo/src/main/java/org/apache/tuscany/databinding/sdo/DataObjectLoader.java  
(revision 0)
@@ -0,0 +1,51 @@
+package org.apache.tuscany.databinding.sdo;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sdo.helper.XMLStreamHelper;
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.model.ModelObject;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XSDHelper;
+
+/**
+ * A SDO model-based Loader to load DataObject from the XML stream
+ *
+ */
+public class DataObjectLoader extends LoaderExtension {
+    private QName propertyQName;
+
+    public DataObjectLoader(Property property) {
+        super();
+        this.propertyQName = new 
QName(XSDHelper.INSTANCE.getNamespaceURI(property), 
XSDHelper.INSTANCE.getLocalName(property));
+    }
+
+    public DataObjectLoader(QName propertyQName) {
+        super();
+        this.propertyQName = propertyQName;
+    }
+
+    @Override
+    protected QName getXMLType() {
+        return propertyQName;
+    }
+
+    public ModelObject load(XMLStreamReader reader, DeploymentContext 
deploymentContext) throws XMLStreamException, LoaderException {
+        assert propertyQName.equals(reader.getName());
+        // TODO: We need a way to get TypeHelper from deploymentContext
+        TypeHelper typeHelper = TypeHelper.INSTANCE;
+        XMLStreamHelper streamHelper = 
SDOUtil.createXMLStreamHelper(typeHelper);
+        DataObject dataObject = streamHelper.loadObject(reader);
+        // TODO: Is it required that the object always extends from 
ModelObject?
+        return (ModelObject) dataObject;
+    }
+
+}

Property changes on: 
sdo\src\main\java\org\apache\tuscany\databinding\sdo\DataObjectLoader.java
___________________________________________________________________
Name: svn:keywords
   + Rev,Date
Name: svn:eol-style
   + native

Index: sdo/src/main/java/org/apache/tuscany/databinding/sdo/ImportSDOLoader.java
===================================================================
--- sdo/src/main/java/org/apache/tuscany/databinding/sdo/ImportSDOLoader.java   
(revision 412487)
+++ sdo/src/main/java/org/apache/tuscany/databinding/sdo/ImportSDOLoader.java   
(working copy)
@@ -19,37 +19,37 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
-import commonj.sdo.helper.XSDHelper;
-import org.apache.tuscany.common.resource.ResourceLoader;
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.core.config.SidefileLoadException;
-import org.apache.tuscany.core.loader.LoaderContext;
+import org.apache.tuscany.core.loader.AssemblyConstants;
 import org.apache.tuscany.core.loader.StAXUtil;
-import org.apache.tuscany.core.loader.assembly.AbstractLoader;
-import org.apache.tuscany.core.loader.assembly.AssemblyConstants;
-import org.apache.tuscany.model.assembly.AssemblyContext;
-import org.apache.tuscany.model.assembly.AssemblyObject;
 import org.apache.tuscany.sdo.util.SDOUtil;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.model.ModelObject;
 import org.osoa.sca.annotations.Scope;
 
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XSDHelper;
+
 /**
  * Loader that handles <import.sdo> elements.
- *
+ * 
  * @version $Rev$ $Date$
  */
 @Scope("MODULE")
-public class ImportSDOLoader extends AbstractLoader {
+public class ImportSDOLoader extends LoaderExtension {
     public static final QName IMPORT_SDO = new 
QName(AssemblyConstants.SCA_NAMESPACE, "import.sdo");
 
     public QName getXMLType() {
         return IMPORT_SDO;
     }
 
-    public AssemblyObject load(XMLStreamReader reader, LoaderContext 
loaderContext) throws XMLStreamException, ConfigurationLoadException {
+    public ModelObject load(XMLStreamReader reader, DeploymentContext 
loaderContext) throws XMLStreamException, LoaderException {
         assert IMPORT_SDO.equals(reader.getName());
         importFactory(reader, loaderContext);
         importWSDL(reader, loaderContext);
@@ -57,42 +57,42 @@
         return null;
     }
 
-    private void importFactory(XMLStreamReader reader, LoaderContext 
loaderContext) throws ConfigurationLoadException {
+    private void importFactory(XMLStreamReader reader, DeploymentContext 
deploymentContext) throws LoaderException {
         String factoryName = reader.getAttributeValue(null, "factory");
         if (factoryName != null) {
-            ResourceLoader resourceLoader = loaderContext.getResourceLoader();
             ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
             try {
-                // set TCCL as SDO needs it
-                
Thread.currentThread().setContextClassLoader(resourceLoader.getClassLoader());
-                Class<?> factoryClass = resourceLoader.loadClass(factoryName);
+                // TODO: set TCCL as SDO needs it
+                
Thread.currentThread().setContextClassLoader(deploymentContext.getClassLoader());
+                Class<?> factoryClass = 
deploymentContext.getClassLoader().loadClass(factoryName);
                 SDOUtil.registerStaticTypes(factoryClass);
             } catch (ClassNotFoundException e) {
-                throw new ConfigurationLoadException(e.getMessage(), e);
+                throw new LoaderException(e.getMessage(), e);
             } finally {
                 Thread.currentThread().setContextClassLoader(oldCL);
             }
         }
     }
 
-    private void importWSDL(XMLStreamReader reader, LoaderContext 
loaderContext) throws ConfigurationLoadException {
+    private void importWSDL(XMLStreamReader reader, DeploymentContext 
deploymentContext) throws LoaderException {
         String wsdLLocation = reader.getAttributeValue(null, "wsdlLocation");
         if (wsdLLocation != null) {
-            ResourceLoader resourceLoader = loaderContext.getResourceLoader();
-            URL wsdlURL = resourceLoader.getResource(wsdLLocation);
+            ClassLoader classLoader = deploymentContext.getClassLoader();
+            URL wsdlURL = classLoader.getResource(wsdLLocation);
             ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
             try {
-//                
Thread.currentThread().setContextClassLoader(resourceLoader.getClassLoader());
+                // 
Thread.currentThread().setContextClassLoader(resourceLoader.getClassLoader());
                 InputStream xsdInputStream = wsdlURL.openStream();
                 try {
-                    AssemblyContext context = registry.getContext();
-                    XSDHelper xsdHelper = 
SDOUtil.createXSDHelper(context.getTypeHelper());
+                    // TODO: How do we get the associated TypeHelper for the 
given DeploymentContext?
+                    TypeHelper typeHelper = TypeHelper.INSTANCE;
+                    XSDHelper xsdHelper = SDOUtil.createXSDHelper(typeHelper);
                     xsdHelper.define(xsdInputStream, null);
                 } finally {
                     xsdInputStream.close();
                 }
             } catch (IOException e) {
-                SidefileLoadException sfe = new 
SidefileLoadException(e.getMessage());
+                LoaderException sfe = new LoaderException(e.getMessage());
                 sfe.setResourceURI(wsdLLocation);
                 throw sfe;
             } finally {
Index: 
sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOObjectFactory.java
===================================================================
--- sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOObjectFactory.java  
(revision 412487)
+++ sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOObjectFactory.java  
(working copy)
@@ -1,13 +1,14 @@
 package org.apache.tuscany.databinding.sdo;
 
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+
 import commonj.sdo.DataObject;
 import commonj.sdo.helper.CopyHelper;
-import org.apache.tuscany.core.builder.ObjectFactory;
-import org.apache.tuscany.core.injection.ObjectCreationException;
 
 /**
  * Creates new instances of an SDO
- *
+ * 
  * @version $Rev$ $Date$
  */
 public class SDOObjectFactory implements ObjectFactory<DataObject> {
@@ -26,4 +27,3 @@
     }
 
 }
-
Index: 
sdo/src/test/java/org/apache/tuscany/databinding/sdo/ImportSDOLoaderTestCase.java
===================================================================
--- 
sdo/src/test/java/org/apache/tuscany/databinding/sdo/ImportSDOLoaderTestCase.java
   (revision 412487)
+++ 
sdo/src/test/java/org/apache/tuscany/databinding/sdo/ImportSDOLoaderTestCase.java
   (working copy)
@@ -19,7 +19,7 @@
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
-import org.apache.tuscany.core.config.ConfigurationLoadException;
+import org.apache.tuscany.spi.loader.LoaderException;
 
 /**
  * @version $Rev$ $Date$
@@ -27,17 +27,17 @@
 public class ImportSDOLoaderTestCase extends LoaderTestSupport {
     private ImportSDOLoader loader;
 
-    public void testMinimal() throws XMLStreamException, 
ConfigurationLoadException {
+    public void testMinimal() throws XMLStreamException, LoaderException {
         String xml = "<import.sdo xmlns='http://www.osoa.org/xmlns/sca/0.9'/>";
         XMLStreamReader reader = getReader(xml);
         assertNull(loader.load(reader, null));
     }
 
-    public void testFactory() throws XMLStreamException, 
ConfigurationLoadException {
+    public void testFactory() throws XMLStreamException, LoaderException {
         String xml = "<import.sdo xmlns='http://www.osoa.org/xmlns/sca/0.9' 
factory='org.apache.tuscany.databinding.sdo.ImportSDOLoaderTestCase$MockFactory'/>";
         XMLStreamReader reader = getReader(xml);
         assertFalse(inited);
-        assertNull(loader.load(reader, loaderContext));
+        assertNull(loader.load(reader, deploymentContext));
         assertTrue(inited);
     }
 
Index: 
sdo/src/test/java/org/apache/tuscany/databinding/sdo/LoaderTestSupport.java
===================================================================
--- sdo/src/test/java/org/apache/tuscany/databinding/sdo/LoaderTestSupport.java 
(revision 412487)
+++ sdo/src/test/java/org/apache/tuscany/databinding/sdo/LoaderTestSupport.java 
(working copy)
@@ -17,36 +17,29 @@
 package org.apache.tuscany.databinding.sdo;
 
 import java.io.StringReader;
+
+import javax.xml.namespace.QName;
 import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamException;
-import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
 
 import junit.framework.TestCase;
-import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory;
-import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl;
-import org.apache.tuscany.core.loader.LoaderContext;
-import org.apache.tuscany.core.loader.assembly.*;
-import org.apache.tuscany.core.loader.impl.StAXLoaderRegistryImpl;
-import org.apache.tuscany.common.resource.ResourceLoader;
-import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
-import org.apache.tuscany.model.assembly.AssemblyContext;
-import org.apache.tuscany.model.assembly.impl.AssemblyContextImpl;
 
+import org.apache.tuscany.core.component.scope.ModuleScopeContainer;
+import org.apache.tuscany.core.loader.LoaderRegistryImpl;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+
 /**
  * Base class for loader tests with common fixture elements.
  *
  * @version $Rev$ $Date$
  */
 public abstract class LoaderTestSupport extends TestCase {
-    protected SystemAssemblyFactory assemblyFactory;
-    protected ResourceLoader resourceLoader;
-    protected LoaderContext loaderContext;
-    protected AssemblyContext modelContext;
-    protected XMLInputFactory xmlFactory;
-    protected StAXLoaderRegistryImpl registry;
+    protected DeploymentContext deploymentContext;
+    protected LoaderRegistryImpl registry;
 
-    protected static final StAXLoaderRegistryImpl.Monitor NULL_MONITOR = new 
StAXLoaderRegistryImpl.Monitor() {
+    protected static final LoaderRegistryImpl.Monitor NULL_MONITOR = new 
LoaderRegistryImpl.Monitor() {
         public void registeringLoader(QName xmlType) {
         }
 
@@ -59,24 +52,16 @@
 
     protected void setUp() throws Exception {
         super.setUp();
-        assemblyFactory = new SystemAssemblyFactoryImpl();
-        resourceLoader = new ResourceLoaderImpl(getClass().getClassLoader());
-        loaderContext = new LoaderContext(resourceLoader);
-        modelContext = new AssemblyContextImpl(assemblyFactory, null, 
resourceLoader);
-        xmlFactory = XMLInputFactory.newInstance();
-        registry = new StAXLoaderRegistryImpl();
-        
registry.setMonitor(org.apache.tuscany.databinding.sdo.LoaderTestSupport.NULL_MONITOR);
+        ScopeContainer moduleScope = new ModuleScopeContainer();
+        deploymentContext = new DeploymentContext(getClass().getClassLoader(), 
XMLInputFactory.newInstance(), moduleScope);
+        registry = new LoaderRegistryImpl();
+        registry.setMonitor(NULL_MONITOR);
     }
 
     protected XMLStreamReader getReader(String xml) throws XMLStreamException {
-        XMLStreamReader reader = xmlFactory.createXMLStreamReader(new 
StringReader(xml));
+        XMLStreamReader reader = 
deploymentContext.getXmlFactory().createXMLStreamReader(new StringReader(xml));
         reader.next();
         return reader;
     }
 
-    protected void registerLoader(AbstractLoader<?> loader) {
-        loader.setFactory(assemblyFactory);
-        loader.setRegistry(registry);
-        loader.start();
-    }
 }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to