diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/implementation-java/src')
-rw-r--r-- | sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java | 34 |
1 files changed, 32 insertions, 2 deletions
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)) { |