You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/02/24 03:16:40 UTC

svn commit: r511191 - in /incubator/tuscany/branches/sca-java-integration/sca: extensions/axis2/databinding/src/main/java/org/apache/tuscany/databinding/axiom/ kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/ kernel/core/src/main/jav...

Author: rfeng
Date: Fri Feb 23 18:16:38 2007
New Revision: 511191

URL: http://svn.apache.org/viewvc?view=rev&rev=511191
Log:
[sca-integration-branch] Fix aliases for databindings and use XMLType for properties, also activate more databindings 

Added:
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/CommonGroupDataBinding.java   (with props)
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Group2GroupTransformer.java   (with props)
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/GroupDataBinding.java   (with props)
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAXDataBinding.java   (with props)
Modified:
    incubator/tuscany/branches/sca-java-integration/sca/extensions/axis2/databinding/src/main/java/org/apache/tuscany/databinding/axiom/AxiomDataBinding.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingInteceptor.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImpl.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/TransformerRegistryImpl.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/javabeans/JavaBeansDataBinding.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/javabeans/XML2JavaBeanTransformer.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMDataBinding.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStringDataBinding.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyObjectFactoryImpl.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/resources/org/apache/tuscany/core/databinding.scdl
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImplTestCase.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/javabeans/DOMNode2JavaBeanTransformerTestCase.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtension.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtension.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DataType.java
    incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBDataBinding.java
    incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDODataBinding.java

Modified: incubator/tuscany/branches/sca-java-integration/sca/extensions/axis2/databinding/src/main/java/org/apache/tuscany/databinding/axiom/AxiomDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/extensions/axis2/databinding/src/main/java/org/apache/tuscany/databinding/axiom/AxiomDataBinding.java?view=diff&rev=511191&r1=511190&r2=511191
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/extensions/axis2/databinding/src/main/java/org/apache/tuscany/databinding/axiom/AxiomDataBinding.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/extensions/axis2/databinding/src/main/java/org/apache/tuscany/databinding/axiom/AxiomDataBinding.java Fri Feb 23 18:16:38 2007
@@ -33,9 +33,10 @@
 public class AxiomDataBinding extends DataBindingExtension {
     
     public static final String NAME = OMElement.class.getName();
+    public static final String[] ALIASES = new String[] {"axiom"};
 
     public AxiomDataBinding() {
-        super(OMElement.class);
+        super(NAME, ALIASES, OMElement.class);
     }
 
     /**

Added: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/CommonGroupDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/CommonGroupDataBinding.java?view=auto&rev=511191
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/CommonGroupDataBinding.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/CommonGroupDataBinding.java Fri Feb 23 18:16:38 2007
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.core.databinding.impl;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+
+/**
+ * A Group DataBinding
+ * 
+ * @version $Rev$ $Date$
+ */
+public class CommonGroupDataBinding extends GroupDataBinding {
+    public CommonGroupDataBinding() {
+        super(new Class[] {InputStream.class, OutputStream.class, Reader.class, Writer.class, Source.class,
+                           Result.class, InputSource.class, ContentHandler.class, XMLStreamReader.class,
+                           XMLStreamWriter.class, XMLEventReader.class, XMLEventWriter.class});
+    }
+}

Propchange: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/CommonGroupDataBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/CommonGroupDataBinding.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingInteceptor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingInteceptor.java?view=diff&rev=511191&r1=511190&r2=511191
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingInteceptor.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingInteceptor.java Fri Feb 23 18:16:38 2007
@@ -165,6 +165,7 @@
     }
 
     private DataType getFaultType(DataType exceptionType) {
+        // FIXME: We cannot assume the exception will have a databinding set
         DataBinding targetDataBinding =
             mediator.getDataBindingRegistry().getDataBinding(exceptionType.getDataBinding());
         if (targetDataBinding == null) {

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImpl.java?view=diff&rev=511191&r1=511190&r2=511191
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImpl.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImpl.java Fri Feb 23 18:16:38 2007
@@ -33,7 +33,7 @@
 
 /**
  * The default implementation of a data binding registry
- *
+ * 
  * @version $Rev$ $Date$
  */
 @EagerInit
@@ -72,32 +72,42 @@
         }
         return dataBinding;
     }
-    
+
     private Set<DataBinding> getDataBindings() {
         return new HashSet<DataBinding>(bindings.values());
     }
 
     public boolean introspectType(DataType dataType, Annotation[] annotations) {
         for (DataBinding binding : getDataBindings()) {
-            //don't introspect for JavaBeansDatabinding as all javatypes will anyways match to its basetype 
-            //which is java.lang.Object.  Default to this only if no databinding results
+            // don't introspect for JavaBeansDatabinding as all javatypes will
+            // anyways match to its basetype
+            // which is java.lang.Object. Default to this only if no databinding
+            // results
             if (!binding.getName().equals(JavaBeansDataBinding.NAME)) {
                 if (binding.introspect(dataType, annotations)) {
                     return true;
                 }
             }
         }
-        if (dataType.getDataBinding() == null) {
-            dataType.setDataBinding(JavaBeansDataBinding.NAME);
+        // FIXME: Should we honor the databinding from operation/interface
+        // level?
+        Object physical = dataType.getPhysical();
+        if (physical instanceof Class) {
+            if (physical == Object.class || Throwable.class.isAssignableFrom((Class)physical)) {
+                return false;
+            }
         }
+        dataType.setDataBinding(JavaBeansDataBinding.NAME);
         return false;
     }
 
     public DataType introspectType(Object value) {
         DataType dataType = null;
         for (DataBinding binding : getDataBindings()) {
-            //don't introspect for JavaBeansDatabinding as all javatypes will anyways match to its basetype 
-            //which is java.lang.Object.  Default to this only if no databinding results
+            // don't introspect for JavaBeansDatabinding as all javatypes will
+            // anyways match to its basetype
+            // which is java.lang.Object. Default to this only if no databinding
+            // results
             if (!binding.getName().equals(JavaBeansDataBinding.NAME)) {
                 dataType = binding.introspect(value);
             }

Added: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Group2GroupTransformer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Group2GroupTransformer.java?view=auto&rev=511191
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Group2GroupTransformer.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Group2GroupTransformer.java Fri Feb 23 18:16:38 2007
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.core.databinding.impl;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.databinding.Mediator;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.apache.tuscany.spi.model.DataType;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This is a special transformer to transform the output from one IDL to the
+ * other one
+ */
+@Service(Transformer.class)
+public class Group2GroupTransformer extends TransformerExtension<Object, Object> implements
+    PullTransformer<Object, Object> {
+
+    protected Mediator mediator;
+
+    /**
+     * @param wrapperHandler
+     */
+    public Group2GroupTransformer() {
+        super();
+    }
+
+    /**
+     * @param mediator the mediator to set
+     */
+    @Autowire
+    public void setMediator(Mediator mediator) {
+        this.mediator = mediator;
+    }
+
+    @Override
+    public String getSourceDataBinding() {
+        return GroupDataBinding.NAME;
+    }
+
+    @Override
+    public String getTargetDataBinding() {
+        return GroupDataBinding.NAME;
+    }
+
+    /**
+     * @see org.apache.tuscany.spi.databinding.extension.TransformerExtension#getSourceType()
+     */
+    @Override
+    protected Class getSourceType() {
+        return Object.class;
+    }
+
+    /**
+     * @see org.apache.tuscany.spi.databinding.extension.TransformerExtension#getTargetType()
+     */
+    @Override
+    protected Class getTargetType() {
+        return Object.class;
+    }
+
+    /**
+     * @see org.apache.tuscany.spi.databinding.Transformer#getWeight()
+     */
+    public int getWeight() {
+        return 10;
+    }
+
+    @SuppressWarnings("unchecked")
+    public Object transform(Object source, TransformationContext context) {
+        DataType<DataType> sourceType = context.getSourceDataType();
+        DataType<DataType> targetType = context.getTargetDataType();
+
+        return mediator.mediate(source, sourceType.getLogical(), targetType.getLogical(), context.getMetadata());
+    }
+
+}

Propchange: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Group2GroupTransformer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Group2GroupTransformer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/GroupDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/GroupDataBinding.java?view=auto&rev=511191
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/GroupDataBinding.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/GroupDataBinding.java Fri Feb 23 18:16:38 2007
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.core.databinding.impl;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+import org.apache.tuscany.spi.databinding.extension.DataBindingExtension;
+import org.apache.tuscany.spi.model.DataType;
+
+/**
+ * A DataBinding for the StAX
+ * 
+ * @version $Rev$ $Date$
+ */
+public abstract class GroupDataBinding extends DataBindingExtension {
+    public static final String NAME = "databinding:group";
+
+    protected Class[] types;
+
+    public GroupDataBinding(Class[] types) {
+        super(NAME, null, GroupDataBinding.class);
+        this.types = types;
+    }
+
+    @SuppressWarnings("unchecked")
+    public boolean introspect(DataType type, Annotation[] annotations) {
+        if (types == null) {
+            return false;
+        }
+        Type physical = type.getPhysical();
+        if (physical instanceof ParameterizedType) {
+            physical = ((ParameterizedType)physical).getRawType();
+        }
+        if (!(physical instanceof Class)) {
+            return false;
+        }
+        Class cls = (Class)physical;
+        for (Class<?> c : types) {
+            if (c.isAssignableFrom(cls)) {
+                type.setDataBinding(NAME);
+                DataType realType = null;
+                try {
+                    realType = (DataType)type.clone();
+                } catch (CloneNotSupportedException e) {
+                    // Never happen
+                    assert false;
+                }
+                realType.setDataBinding(c.getName());
+                type.setLogical(realType);
+            }
+        }
+        return false;
+    }
+
+}

Propchange: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/GroupDataBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/GroupDataBinding.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/TransformerRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/TransformerRegistryImpl.java?view=diff&rev=511191&r1=511190&r2=511191
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/TransformerRegistryImpl.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/TransformerRegistryImpl.java Fri Feb 23 18:16:38 2007
@@ -23,6 +23,9 @@
 
 import org.osoa.sca.annotations.EagerInit;
 
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.databinding.DataBinding;
+import org.apache.tuscany.spi.databinding.DataBindingRegistry;
 import org.apache.tuscany.spi.databinding.Transformer;
 import org.apache.tuscany.spi.databinding.TransformerRegistry;
 
@@ -31,7 +34,8 @@
  */
 @EagerInit
 public class TransformerRegistryImpl implements TransformerRegistry {
-
+    private DataBindingRegistry dataBindingRegistry;
+    
     private final DirectedGraph<Object, Transformer> graph = new DirectedGraph<Object, Transformer>();
 
     public void registerTransformer(String sourceType, String resultType, int weight, Transformer transformer) {
@@ -55,8 +59,10 @@
     }
 
     public List<Transformer> getTransformerChain(String sourceType, String resultType) {
+        String source = normalize(sourceType);
+        String result = normalize(resultType);
         List<Transformer> transformers = new ArrayList<Transformer>();
-        DirectedGraph<Object, Transformer>.Path path = graph.getShortestPath(sourceType, resultType);
+        DirectedGraph<Object, Transformer>.Path path = graph.getShortestPath(source, result);
         if (path == null) {
             return null;
         }
@@ -68,6 +74,28 @@
 
     public String toString() {
         return graph.toString();
+    }
+
+    /**
+     * @param dataBindingRegistry the dataBindingRegistry to set
+     */
+    @Autowire
+    public void setDataBindingRegistry(DataBindingRegistry dataBindingRegistry) {
+        this.dataBindingRegistry = dataBindingRegistry;
+    }
+    
+    /**
+     * Normalize the id to a name of a data binding as databindings may have aliases
+     * @param id
+     * @return
+     */
+    private String normalize(String id) {
+        if (dataBindingRegistry != null) {
+            DataBinding dataBinding = dataBindingRegistry.getDataBinding(id);
+            return dataBinding == null ? id : dataBinding.getName();
+        } else {
+            return id;
+        }
     }
 
 }

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/javabeans/JavaBeansDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/javabeans/JavaBeansDataBinding.java?view=diff&rev=511191&r1=511190&r2=511191
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/javabeans/JavaBeansDataBinding.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/javabeans/JavaBeansDataBinding.java Fri Feb 23 18:16:38 2007
@@ -36,6 +36,6 @@
     public static final String NAME = Object.class.getName();
 
     public JavaBeansDataBinding() {
-        super(Object.class);
+        super(NAME, Object.class);
     }
 }

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/javabeans/XML2JavaBeanTransformer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/javabeans/XML2JavaBeanTransformer.java?view=diff&rev=511191&r1=511190&r2=511191
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/javabeans/XML2JavaBeanTransformer.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/javabeans/XML2JavaBeanTransformer.java Fri Feb 23 18:16:38 2007
@@ -27,6 +27,8 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.xml.namespace.QName;
+
 import org.apache.tuscany.spi.databinding.PullTransformer;
 import org.apache.tuscany.spi.databinding.TransformationContext;
 import org.apache.tuscany.spi.databinding.Transformer;
@@ -34,6 +36,7 @@
 import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
 import org.apache.tuscany.spi.idl.ElementInfo;
 import org.apache.tuscany.spi.idl.TypeInfo;
+import org.apache.tuscany.spi.idl.XMLType;
 import org.osoa.sca.annotations.Service;
 
 /**
@@ -57,23 +60,15 @@
     }
     
     public Object transform(T source, TransformationContext context) {
-        TypeInfo xmlType =
-                (TypeInfo) context.getSourceDataType().getMetadata(TypeInfo.class.getName());
-        if (xmlType == null) {
-            ElementInfo element =
-                    (ElementInfo) context.getSourceDataType()
-                                         .getMetadata(ElementInfo.class.getName());
-            xmlType = (TypeInfo) element.getType();
-        }
-
-        return toJavaObject(xmlType, getRootElement(source), context);
+        XMLType xmlType = (XMLType) context.getSourceDataType().getLogical();
+        return toJavaObject(xmlType.getTypeName(), getRootElement(source), context);
     }
 
-    public Object toJavaObject(TypeInfo xmlType, T xmlElement, TransformationContext context) {
-        if (xmlType.isSimpleType()) {
-            return mapper.toJavaObject(xmlType.getQName(), getText(xmlElement), context);
+    public Object toJavaObject(QName xmlType, T xmlElement, TransformationContext context) {
+        if (SimpleTypeMapperExtension.isSimpleXSDType(xmlType)) {
+            return mapper.toJavaObject(xmlType, getText(xmlElement), context);
         } else {
-            Class<?> javaType = (Class<?>) context.getTargetDataType().getLogical();
+            Class<?> javaType = (Class<?>)context.getTargetDataType().getPhysical();
             return createJavaObject(xmlElement, javaType, context);
         }
     }

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMDataBinding.java?view=diff&rev=511191&r1=511190&r2=511191
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMDataBinding.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMDataBinding.java Fri Feb 23 18:16:38 2007
@@ -31,9 +31,10 @@
  */
 public class DOMDataBinding extends DataBindingExtension {
     public static final String NAME = Node.class.getName();
+    public static final String[] ALIASES = new String[] {"dom"};
 
     public DOMDataBinding() {
-        super(Node.class);
+        super(NAME, ALIASES, Node.class);
     }
 
     @Override
@@ -44,13 +45,8 @@
     public Object copy(Object source) {
         if (Node.class.isAssignableFrom(source.getClass())) {
             Node nodeSource = (Node) source;
-            Node2String strTransformer = new Node2String();
-            String stringCopy = strTransformer.transform(nodeSource, null);
-
-            String2Node nodeTransformer = new String2Node();
-            return nodeTransformer.transform(stringCopy, null);
+            return nodeSource.cloneNode(true);
         }
-
         return super.copy(source);
     }
 }

Added: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAXDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAXDataBinding.java?view=auto&rev=511191
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAXDataBinding.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAXDataBinding.java Fri Feb 23 18:16:38 2007
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.core.databinding.xml;
+
+import java.lang.annotation.Annotation;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.databinding.extension.DataBindingExtension;
+import org.apache.tuscany.spi.idl.XMLType;
+import org.apache.tuscany.spi.model.DataType;
+
+/**
+ * A DataBinding for the StAX
+ * 
+ * @version $Rev$ $Date$
+ */
+public class StAXDataBinding extends DataBindingExtension {
+    public static final String NAME = XMLStreamReader.class.getName();
+    public static final String[] ALIASES = new String[] {"stax"};
+
+    public StAXDataBinding() {
+        super(NAME, ALIASES, XMLStreamReader.class);
+    }
+
+    public boolean introspect(DataType type, Annotation[] annotations) {
+        if (super.introspect(type, annotations)) {
+            type.setLogical(XMLType.UNKNOWN);
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+}

Propchange: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAXDataBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAXDataBinding.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStringDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStringDataBinding.java?view=diff&rev=511191&r1=511190&r2=511191
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStringDataBinding.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStringDataBinding.java Fri Feb 23 18:16:38 2007
@@ -19,15 +19,33 @@
 
 package org.apache.tuscany.core.databinding.xml;
 
+import java.lang.annotation.Annotation;
+
 import org.apache.tuscany.spi.databinding.extension.DataBindingExtension;
+import org.apache.tuscany.spi.idl.XMLType;
+import org.apache.tuscany.spi.model.DataType;
 
 /**
  * A DataBinding for the XML string
+ * 
+ * @version $Rev$ $Date$
  */
 public class XMLStringDataBinding extends DataBindingExtension {
     public static final String NAME = String.class.getName();
-    
+    public static final String[] ALIASES = new String[] {"xml.string"};
+
     public XMLStringDataBinding() {
-        super(NAME, String.class);
+        super(NAME, ALIASES, String.class);
+    }
+
+    @Override
+    public boolean introspect(DataType type, Annotation[] annotations) {
+        if (registry.getDataBinding(type.getDataBinding()) == this) {
+            type.setDataBinding(getName());
+            type.setLogical(XMLType.UNKNOWN);
+            return true;
+        } else {
+            return false;
+        }
     }
 }

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyObjectFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyObjectFactoryImpl.java?view=diff&rev=511191&r1=511190&r2=511191
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyObjectFactoryImpl.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyObjectFactoryImpl.java Fri Feb 23 18:16:38 2007
@@ -34,6 +34,7 @@
 import org.apache.tuscany.spi.databinding.extension.SimpleTypeMapperExtension;
 import org.apache.tuscany.spi.idl.ElementInfo;
 import org.apache.tuscany.spi.idl.TypeInfo;
+import org.apache.tuscany.spi.idl.XMLType;
 import org.apache.tuscany.spi.loader.LoaderException;
 import org.apache.tuscany.spi.loader.PropertyObjectFactory;
 import org.apache.tuscany.spi.model.DataType;
@@ -53,8 +54,10 @@
     public PropertyObjectFactoryImpl() {
     }
 
-    @Constructor({"registry", "mediator"})
-    public PropertyObjectFactoryImpl(@Autowire DataBindingRegistry registry, @Autowire Mediator mediator) {
+    @Constructor( {"registry", "mediator"})
+    public PropertyObjectFactoryImpl(@Autowire
+    DataBindingRegistry registry, @Autowire
+    Mediator mediator) {
         super();
         this.registry = registry;
         this.mediator = mediator;
@@ -66,28 +69,29 @@
         }
         return new ObjectFactoryImpl<T>(property, value);
     }
-    
-    public <T> ObjectFactory<List<T>> createListObjectFactory(Property<T> property, PropertyValue<T> value) throws LoaderException {
+
+    public <T> ObjectFactory<List<T>> createListObjectFactory(Property<T> property, PropertyValue<T> value)
+        throws LoaderException {
         if (mediator == null) {
             return new SimpleMultivaluedPropertyObjectFactory<T>(property, value.getValue());
         }
         return new ListObjectFactoryImpl<T>(property, value);
     }
 
-    
     public class ObjectFactoryImplBase<P> {
         protected Property<P> property;
         protected PropertyValue<P> propertyValue;
-        protected DataType<QName> sourceDataType;
+        protected DataType<XMLType> sourceDataType;
         protected DataType<?> targetDataType;
 
         public ObjectFactoryImplBase(Property<P> property, PropertyValue<P> propertyValue) {
             this.property = property;
             this.propertyValue = propertyValue;
-            sourceDataType = new DataType<QName>(DOMDataBinding.NAME, Node.class, this.property.getXmlType());
+            sourceDataType =
+                new DataType<XMLType>(DOMDataBinding.NAME, Node.class, new XMLType(null, this.property.getXmlType()));
             TypeInfo typeInfo = null;
             if (this.property.getXmlType() != null) {
-                if (SimpleTypeMapperExtension.isSimpleXSDType(this.property.getXmlType())) { 
+                if (SimpleTypeMapperExtension.isSimpleXSDType(this.property.getXmlType())) {
                     typeInfo = new TypeInfo(property.getXmlType(), true, null);
                 } else {
                     typeInfo = new TypeInfo(property.getXmlType(), false, null);
@@ -95,43 +99,50 @@
             } else {
                 typeInfo = new TypeInfo(property.getXmlType(), false, null);
             }
-            
-            ElementInfo elementInfo = new ElementInfo(null, typeInfo);
-            sourceDataType.setMetadata(ElementInfo.class.getName(), elementInfo);
+
+            XMLType xmlType = new XMLType(typeInfo);
+            /*
+             * ElementInfo elementInfo = new ElementInfo(null, typeInfo);
+             * sourceDataType.setMetadata(ElementInfo.class.getName(),
+             * elementInfo);
+             */
             Class javaType = this.property.getJavaType();
             String dataBinding = (String)property.getExtensions().get(DataBinding.class.getName());
             if (dataBinding != null) {
-                targetDataType = new DataType<Class>(dataBinding, javaType, javaType);
+                targetDataType = new DataType<XMLType>(dataBinding, javaType, xmlType);
             } else {
-                targetDataType = new DataType<Class>(dataBinding, javaType, javaType);
+                targetDataType = new DataType<XMLType>(dataBinding, javaType, xmlType);
                 registry.introspectType(targetDataType, null);
             }
         }
     }
 
     public class ObjectFactoryImpl<P> extends ObjectFactoryImplBase<P> implements ObjectFactory<P> {
-        
+
         public ObjectFactoryImpl(Property<P> property, PropertyValue<P> propertyValue) {
             super(property, propertyValue);
         }
-    
+
         @SuppressWarnings("unchecked")
         public P getInstance() throws ObjectCreationException {
             return (P)mediator.mediate(propertyValue.getValue().get(0), sourceDataType, targetDataType, null);
         }
     }
-        
+
     public class ListObjectFactoryImpl<P> extends ObjectFactoryImplBase<P> implements ObjectFactory<List<P>> {
-        
+
         public ListObjectFactoryImpl(Property<P> property, PropertyValue<P> propertyValue) {
             super(property, propertyValue);
         }
-    
+
         @SuppressWarnings("unchecked")
         public List<P> getInstance() throws ObjectCreationException {
             List<P> instances = new ArrayList<P>();
-            for (int count = 0; count < propertyValue.getValue().size() ; ++count) {
-                instances.add((P)mediator.mediate(propertyValue.getValue().get(count), sourceDataType, targetDataType, null));
+            for (int count = 0; count < propertyValue.getValue().size(); ++count) {
+                instances.add((P)mediator.mediate(propertyValue.getValue().get(count),
+                                                  sourceDataType,
+                                                  targetDataType,
+                                                  null));
             }
             return instances;
         }

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/resources/org/apache/tuscany/core/databinding.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/resources/org/apache/tuscany/core/databinding.scdl?view=diff&rev=511191&r1=511190&r2=511191
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/resources/org/apache/tuscany/core/databinding.scdl (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/resources/org/apache/tuscany/core/databinding.scdl Fri Feb 23 18:16:38 2007
@@ -51,12 +51,25 @@
         <system:implementation.system class="org.apache.tuscany.core.databinding.impl.DataTypeLoader" />
     </component>
 
-    <!-- Simple databindings -->
     <component name="databinding.dom">
-        <system:implementation.system class="org.apache.tuscany.core.databinding.impl.SimpleDataBinding" />
-        <property name="className">org.w3c.dom.Node</property>
-    </component>
+        <system:implementation.system class="org.apache.tuscany.core.databinding.xml.DOMDataBinding" />
+   </component>
     
+    <component name="databinding.xmlString">
+        <system:implementation.system class="org.apache.tuscany.core.databinding.xml.XMLStringDataBinding" />
+   </component>
+       
+    <!-- Group databindings -->
+    <!-- 
+    <component name="databinding.group.common">
+        <system:implementation.system class="org.apache.tuscany.core.databinding.impl.CommonGroupDataBinding" />
+   </component>
+   -->
+
+    <component name="databinding.stax">
+        <system:implementation.system class="org.apache.tuscany.core.databinding.xml.StAXDataBinding" />
+    </component>
+       
     <component name="databinding.javabeans">
         <system:implementation.system class="org.apache.tuscany.core.databinding.javabeans.JavaBeansDataBinding" />
     </component>
@@ -71,9 +84,12 @@
         <system:implementation.system class="org.apache.tuscany.core.databinding.impl.Exception2ExceptionTransformer" />
     </component>
 
-
     <component name="transformer.Output2OutputTransformer">
         <system:implementation.system class="org.apache.tuscany.core.databinding.impl.Output2OutputTransformer" />
+    </component>
+
+    <component name="transformer.Group2GroupTransformer">
+        <system:implementation.system class="org.apache.tuscany.core.databinding.impl.Group2GroupTransformer" />
     </component>
 
     <component name="transformer.InputSource2Node">

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImplTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImplTestCase.java?view=diff&rev=511191&r1=511190&r2=511191
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImplTestCase.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImplTestCase.java Fri Feb 23 18:16:38 2007
@@ -72,22 +72,27 @@
 
         registry.register(db2);
 
+        // Lookup by name
         String name = db1.getName();
         DataBinding db3 = registry.getDataBinding(name);
-        Assert.assertTrue(db1 == db3);
+        assertSame(db1, db3);
 
+        // Look up by alias
+        DataBinding db5 = registry.getDataBinding("db1");
+        assertSame(db1, db5);
+        
         DataType dt = new DataType(ContentHandler.class, null);
         registry.introspectType(dt, null);
-        Assert.assertEquals(dataType1.getLogical(), ContentHandler.class);
-        Assert.assertTrue(dt.getDataBinding().equalsIgnoreCase(name));
+        assertEquals(dataType1.getLogical(), ContentHandler.class);
+        assertTrue(dt.getDataBinding().equalsIgnoreCase("java.lang.Object"));
 
         registry.unregister(name);
         DataBinding db4 = registry.getDataBinding(name);
-        Assert.assertNull(db4);
+        assertNull(db4);
 
         dt = new DataType(null, String.class, null);
         registry.introspectType(dt, null);
-        Assert.assertEquals("java.lang.Object", dt.getDataBinding());
+        assertEquals("java.lang.Object", dt.getDataBinding());
     }
 
 }

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/javabeans/DOMNode2JavaBeanTransformerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/javabeans/DOMNode2JavaBeanTransformerTestCase.java?view=diff&rev=511191&r1=511190&r2=511191
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/javabeans/DOMNode2JavaBeanTransformerTestCase.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/javabeans/DOMNode2JavaBeanTransformerTestCase.java Fri Feb 23 18:16:38 2007
@@ -35,6 +35,7 @@
 import org.apache.tuscany.spi.databinding.extension.DOMHelper;
 import org.apache.tuscany.spi.idl.ElementInfo;
 import org.apache.tuscany.spi.idl.TypeInfo;
+import org.apache.tuscany.spi.idl.XMLType;
 import org.apache.tuscany.spi.model.DataType;
 import org.easymock.EasyMock;
 import org.w3c.dom.Document;
@@ -75,12 +76,12 @@
         TypeInfo typeInfo = new TypeInfo(null, false, null);
 
         TransformationContext context = EasyMock.createMock(TransformationContext.class);
-        DataType<Class> targetDataType = new DataType<Class>(null, SamplePropertyBean.class);
+        DataType<Class> targetDataType = new DataType<Class>(SamplePropertyBean.class, SamplePropertyBean.class);
         EasyMock.expect(context.getTargetDataType()).andReturn(targetDataType).anyTimes();
 
-        DataType<Class> sourceDataType = new DataType<Class>(null, null);
-        ElementInfo eleInfo = new ElementInfo(null, typeInfo);
-        sourceDataType.setMetadata(ElementInfo.class.getName(), eleInfo);
+        DataType<XMLType> sourceDataType = new DataType<XMLType>(null, new XMLType(typeInfo));
+        // ElementInfo eleInfo = new ElementInfo(null, typeInfo);
+        // sourceDataType.setMetadata(ElementInfo.class.getName(), eleInfo);
         EasyMock.expect(context.getSourceDataType()).andReturn(sourceDataType).anyTimes();
         EasyMock.replay(context);
 

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtension.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtension.java?view=diff&rev=511191&r1=511190&r2=511191
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtension.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtension.java Fri Feb 23 18:16:38 2007
@@ -28,6 +28,8 @@
 import java.io.OutputStream;
 import java.io.Serializable;
 import java.lang.annotation.Annotation;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
 
 import org.osoa.sca.annotations.EagerInit;
 import org.osoa.sca.annotations.Init;
@@ -57,6 +59,7 @@
     protected Class<?> baseType;
 
     protected String name;
+    protected String[] aliases; 
 
     /**
      * Create a databinding with the base java type whose name will be used as
@@ -66,7 +69,7 @@
      *            databinding, for example, org.w3c.dom.Node
      */
     protected DataBindingExtension(Class<?> baseType) {
-        this(baseType.getName(), baseType);
+        this(baseType.getName(), null, baseType);
     }
 
     /**
@@ -77,9 +80,22 @@
      *            databinding, for example, org.w3c.dom.Node
      */
     protected DataBindingExtension(String name, Class<?> baseType) {
+        this(name, null, baseType);
+    }
+    
+    /**
+     * Create a databinding with the name and base java type
+     * 
+     * @param name The name of the databinding
+     * @param aliases The aliases of the databinding
+     * @param baseType The base java class or interface representing the
+     *            databinding, for example, org.w3c.dom.Node
+     */
+    protected DataBindingExtension(String name, String[] aliases, Class<?> baseType) {
         this.name = name;
         this.baseType = baseType;
-    }
+        this.aliases = aliases;
+    }    
 
     @Autowire
     public void setDataBindingRegistry(DataBindingRegistry registry) {
@@ -93,7 +109,10 @@
 
     public boolean introspect(DataType type, Annotation[] annotations) {
         assert type != null;
-        Object physical = type.getPhysical();
+        Type physical = type.getPhysical();
+        if (physical instanceof ParameterizedType) {
+            physical = ((ParameterizedType)physical).getRawType();
+        }
         if (physical instanceof Class) {
             Class cls = (Class)physical;
             if (baseType != null && baseType.isAssignableFrom(cls)) {
@@ -104,6 +123,15 @@
         }
         return false;
     }
+    
+    protected static org.apache.tuscany.api.annotation.DataType getDataTypeAnnotation(Annotation[] annotations) {
+        for (Annotation a : annotations) {
+            if (a.annotationType() == org.apache.tuscany.api.annotation.DataType.class) {
+                return (org.apache.tuscany.api.annotation.DataType) a;
+            }
+        }
+        return null;
+    }
 
     public DataType introspect(Object value) {
         if (value == null) {
@@ -193,7 +221,7 @@
     }
 
     public String[] getAliases() {
-        return null;
+        return aliases;
     }
 
 }

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtension.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtension.java?view=diff&rev=511191&r1=511190&r2=511191
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtension.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtension.java Fri Feb 23 18:16:38 2007
@@ -382,6 +382,9 @@
     }
 
     public static boolean isSimpleXSDType(QName typeName) {
+        if (typeName == null) {
+            return false;
+        }
         return typeName.getNamespaceURI().equals(URI_2001_SCHEMA_XSD) 
             && XSD_SIMPLE_TYPES.get(typeName.getLocalPart()) != null;
     }

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DataType.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DataType.java?view=diff&rev=511191&r1=511190&r2=511191
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DataType.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DataType.java Fri Feb 23 18:16:38 2007
@@ -35,7 +35,7 @@
  * @version $Rev$ $Date$
  */
 public class DataType<L> extends ModelObject implements Cloneable {
-    private String dataBinding = Object.class.getName();
+    private String dataBinding;
 
     private final Type physical;
 

Modified: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBDataBinding.java?view=diff&rev=511191&r1=511190&r2=511191
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBDataBinding.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBDataBinding.java Fri Feb 23 18:16:38 2007
@@ -43,10 +43,15 @@
  * JAXB DataBinding
  */
 public class JAXBDataBinding extends DataBindingExtension {
+    public static final String NAME = JAXBElement.class.getName();
+    public static final String[] ALIASES = new String[] {"jaxb"};
+
     public static final String ROOT_NAMESPACE = "http://tuscany.apache.org/xmlns/sca/databinding/jaxb/1.0";
     public static final QName ROOT_ELEMENT = new QName(ROOT_NAMESPACE, "root");
 
-    public static final String NAME = JAXBElement.class.getName();
+    public JAXBDataBinding() {
+        super(NAME, ALIASES, JAXBElement.class);
+    }
 
     @Override
     public boolean introspect(DataType dataType, Annotation[] annotations) {
@@ -129,10 +134,6 @@
             return null;
         }
         return new XMLType(null, new QName(namespace, name));
-    }
-
-    public JAXBDataBinding() {
-        super(NAME, JAXBElement.class);
     }
 
     @SuppressWarnings("unchecked")

Modified: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDODataBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDODataBinding.java?view=diff&rev=511191&r1=511190&r2=511191
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDODataBinding.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDODataBinding.java Fri Feb 23 18:16:38 2007
@@ -43,14 +43,16 @@
  * @version $Reve$ $Date$
  */
 public class SDODataBinding extends DataBindingExtension {
-    public static final String NAME = "commonj.sdo.DataObject";
+    public static final String NAME = DataObject.class.getName();
+    public static final String[] ALIASES = new String[] {"sdo"};
+    
     public static final String ROOT_NAMESPACE = "commonj.sdo";
     public static final QName ROOT_ELEMENT = new QName(ROOT_NAMESPACE, "dataObject");
 
     private WrapperHandler<Object> wrapperHandler;
 
     public SDODataBinding() {
-        super(DataObject.class);
+        super(NAME, ALIASES, DataObject.class);
         wrapperHandler = new SDOWrapperHandler();
     }
 
@@ -65,6 +67,7 @@
         // FIXME: Need a better to test dynamic SDO
         if (DataObject.class.isAssignableFrom(javaType)) {
             // Dynamic SDO
+            dataType.setDataBinding(getName());
             dataType.setLogical(XMLType.UNKNOWN);
             return true;
         }
@@ -80,6 +83,7 @@
         String namespace = type.getURI();
         String name = context.getXSDHelper().getLocalName(type);
         QName xmlType = new QName(namespace, name);
+        dataType.setDataBinding(getName());
         dataType.setLogical(new XMLType(null, xmlType));
         return true;
     }



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