diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2010-01-27 04:29:29 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2010-01-27 04:29:29 +0000 |
commit | c2dfd0917dbb0793b7934ccc298e03187e6e3418 (patch) | |
tree | 9fabf3e20881b995680c4710e74c95d94a8866b8 /sca-java-2.x/trunk/modules/implementation-java | |
parent | c0861fc5defc398b57b04bc595143c51ff2b5e17 (diff) |
Fix for TUSCANY-3409
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@903541 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
4 files changed, 60 insertions, 28 deletions
diff --git a/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java b/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java index 01c3b148f8..606984659d 100644 --- a/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java +++ b/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java @@ -65,18 +65,6 @@ public class JavaPropertyValueObjectFactory implements PropertyValueFactory { this.mediator = mediator; } - /** - * Introspect the property - * @param javaElement - * @return - */ - private DataType<?> introspect(JavaElementImpl javaElement) { - DataType<XMLType> dt = - new DataTypeImpl<XMLType>(null, javaElement.getType(), javaElement.getGenericType(), XMLType.UNKNOWN); - mediator.getDataBindings().introspectType(dt, null); - return dt; - } - public ObjectFactory createValueFactory(Property property, Object propertyValue, JavaElementImpl javaElement) { Document doc = (Document)propertyValue; List<Node> nodes = getValues(doc); @@ -131,24 +119,28 @@ public class JavaPropertyValueObjectFactory implements PropertyValueFactory { sourceDataType = new DataTypeImpl<XMLType>(DOMDataBinding.NAME, Node.class, new XMLType(null, this.property.getXSDType())); - TypeInfo typeInfo = null; - if (this.property.getXSDType() != null) { - if (simpleTypeMapper.isSimpleXSDType(this.property.getXSDType())) { - typeInfo = new TypeInfo(property.getXSDType(), true, null); + + targetDataType = property.getDataType(); + if (targetDataType == null) { + TypeInfo typeInfo = null; + if (this.property.getXSDType() != null) { + if (simpleTypeMapper.isSimpleXSDType(this.property.getXSDType())) { + typeInfo = new TypeInfo(property.getXSDType(), true, null); + } else { + typeInfo = new TypeInfo(property.getXSDType(), false, null); + } } else { typeInfo = new TypeInfo(property.getXSDType(), false, null); } - } else { - typeInfo = new TypeInfo(property.getXSDType(), false, null); - } - XMLType xmlType = new XMLType(typeInfo); - String dataBinding = null; // (String)property.getExtensions().get(DataBinding.class.getName()); - if (dataBinding != null) { - targetDataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType); - } else { - targetDataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType); - mediator.getDataBindings().introspectType(targetDataType, null); + XMLType xmlType = new XMLType(typeInfo); + String dataBinding = null; // (String)property.getExtensions().get(DataBinding.class.getName()); + if (dataBinding != null) { + targetDataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType); + } else { + targetDataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType); + mediator.getDataBindings().introspectType(targetDataType, null); + } } } } diff --git a/sca-java-2.x/trunk/modules/implementation-java/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/implementation-java/META-INF/MANIFEST.MF index 44f27a2c5f..2e78c254e4 100644 --- a/sca-java-2.x/trunk/modules/implementation-java/META-INF/MANIFEST.MF +++ b/sca-java-2.x/trunk/modules/implementation-java/META-INF/MANIFEST.MF @@ -27,11 +27,15 @@ Import-Package: javax.jws, org.apache.tuscany.sca.contribution.processor;version="2.0.0",
org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.impl;version="2.0.0",
+ org.apache.tuscany.sca.databinding.util;version="2.0.0",
org.apache.tuscany.sca.definitions;version="2.0.0";resolution:=optional,
org.apache.tuscany.sca.extensibility;version="2.0.0",
org.apache.tuscany.sca.implementation.java;version="2.0.0",
org.apache.tuscany.sca.implementation.java.introspect;version="2.0.0",
org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0",
org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
org.apache.tuscany.sca.interfacedef.java.impl;version="2.0.0";resolution:=optional,
org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
diff --git a/sca-java-2.x/trunk/modules/implementation-java/pom.xml b/sca-java-2.x/trunk/modules/implementation-java/pom.xml index 16b19b16ae..f6aaf07ca0 100644 --- a/sca-java-2.x/trunk/modules/implementation-java/pom.xml +++ b/sca-java-2.x/trunk/modules/implementation-java/pom.xml @@ -40,6 +40,12 @@ <artifactId>tuscany-interface-java</artifactId> <version>2.0-SNAPSHOT</version> </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-databinding</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> <dependency> <groupId>org.apache.tuscany.sca</groupId> diff --git a/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java b/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java index b951e17fd2..13c677ac1d 100644 --- a/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java +++ b/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java @@ -29,13 +29,18 @@ import java.util.Map; import org.apache.tuscany.sca.assembly.Property; import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.UtilityExtensionPoint; +import org.apache.tuscany.sca.databinding.Mediator; import org.apache.tuscany.sca.implementation.java.IntrospectionException; import org.apache.tuscany.sca.implementation.java.JavaElementImpl; import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaParameterImpl; import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor; import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper; +import org.apache.tuscany.sca.interfacedef.DataType; +import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl; import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper; +import org.apache.tuscany.sca.interfacedef.util.XMLType; /** * Base class for ImplementationProcessors that handle annotations that add @@ -45,10 +50,26 @@ import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper; */ public abstract class AbstractPropertyProcessor<A extends Annotation> extends BaseJavaClassVisitor { private final Class<A> annotationClass; + private Mediator mediator; protected AbstractPropertyProcessor(ExtensionPointRegistry registry, Class<A> annotationClass) { super(registry); this.annotationClass = annotationClass; + UtilityExtensionPoint utilityExtensionPoint = registry.getExtensionPoint(UtilityExtensionPoint.class); + this.mediator = utilityExtensionPoint.getUtility(Mediator.class); + } + + /** + * Introspect the property + * @param javaElement + * @return + */ + private DataType<?> introspect(Property property, JavaElementImpl javaElement) { + XMLType xmlType = new XMLType(property.getXSDElement(), property.getXSDType()); + DataType<XMLType> dt = + new DataTypeImpl<XMLType>(null, javaElement.getType(), javaElement.getGenericType(), xmlType); + mediator.getDataBindings().introspectType(dt, null); + return dt; } private static boolean removeProperty(JavaElementImpl prop, JavaImplementation type) { @@ -208,8 +229,17 @@ public abstract class AbstractPropertyProcessor<A extends Annotation> extends Ba Property property = assemblyFactory.createProperty(); property.setName(name); - Class<?> baseType = JavaIntrospectionHelper.getBaseType(element.getType(), element.getGenericType()); - property.setXSDType(JavaXMLMapper.getXMLType(baseType)); + + DataType dt = introspect(property, element); + property.setDataType(dt); + if(dt.getLogical() instanceof XMLType) { + XMLType xmlType = (XMLType) dt.getLogical(); + property.setXSDType(xmlType.getTypeName()); + property.setXSDElement(xmlType.getElementName()); + } else { + Class<?> baseType = JavaIntrospectionHelper.getBaseType(element.getType(), element.getGenericType()); + property.setXSDType(JavaXMLMapper.getXMLType(baseType)); + } Class<?> javaType = element.getType(); if (javaType.isArray() || Collection.class.isAssignableFrom(javaType)) { |