From c2dfd0917dbb0793b7934ccc298e03187e6e3418 Mon Sep 17 00:00:00 2001 From: rfeng Date: Wed, 27 Jan 2010 04:29:29 +0000 Subject: Fix for TUSCANY-3409 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@903541 13f79535-47bb-0310-9956-ffa450edef68 --- .../itest/scdl/ValidateDependenciesTestCase.java | 12 +++--- .../tuscany/sca/assembly/AbstractProperty.java | 15 +++++++- .../sca/assembly/impl/AbstractPropertyImpl.java | 22 ++++++++--- .../sca/builder/impl/ComponentBuilderImpl.java | 8 ++-- .../injection/JavaPropertyValueObjectFactory.java | 44 +++++++++------------- .../implementation-java/META-INF/MANIFEST.MF | 4 ++ .../trunk/modules/implementation-java/pom.xml | 6 +++ .../introspect/impl/AbstractPropertyProcessor.java | 34 ++++++++++++++++- .../policy-transaction/META-INF/MANIFEST.MF | 2 + .../trunk/modules/policy-transaction/pom.xml | 4 +- 10 files changed, 103 insertions(+), 48 deletions(-) (limited to 'sca-java-2.x/trunk') diff --git a/sca-java-2.x/trunk/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java b/sca-java-2.x/trunk/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java index 44695e5dde..d821d62f28 100644 --- a/sca-java-2.x/trunk/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java +++ b/sca-java-2.x/trunk/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java @@ -33,27 +33,25 @@ import org.junit.Test; * Current required jars are: * geronimo-stax-api_1.0_spec-1.0.1.jar * jsr181-api-1.0-MR1.jar - * junit-4.5.jar + * junit-4.8.1.jar * tuscany-assembly-2.0-SNAPSHOT.jar * tuscany-assembly-xml-2.0-SNAPSHOT.jar * tuscany-assembly-xsd-2.0-SNAPSHOT.jar * tuscany-binding-jms-2.0-SNAPSHOT.jar * tuscany-binding-jsonp-2.0-SNAPSHOT.jar * tuscany-binding-rmi-2.0-SNAPSHOT.jar - * tuscany-binding-ws-2.0-SNAPSHOT.jar + * tuscany-builder-2.0-SNAPSHOT.jar * tuscany-common-java-2.0-SNAPSHOT.jar * tuscany-common-xml-2.0-SNAPSHOT.jar * tuscany-contribution-2.0-SNAPSHOT.jar + * tuscany-databinding-2.0-SNAPSHOT.jar + * tuscany-deployment-2.0-SNAPSHOT.jar * tuscany-extensibility-2.0-SNAPSHOT.jar - * tuscany-implementation-bpel-2.0-SNAPSHOT.jar * tuscany-implementation-java-2.0-SNAPSHOT.jar * tuscany-interface-java-2.0-SNAPSHOT.jar - * tuscany-interface-wsdl-2.0-SNAPSHOT.jar * tuscany-monitor-2.0-SNAPSHOT.jar * tuscany-sca-api-2.0-SNAPSHOT.jar - * tuscany-scdl-2.0-SNAPSHOT.jar * tuscany-xsd-2.0-SNAPSHOT.jar - * wsdl4j-1.6.2.jar * wstx-asl-3.2.4.jar * XmlSchema-1.4.2.jar * @@ -68,6 +66,6 @@ public class ValidateDependenciesTestCase { Assert.assertTrue(dependenciesDir.exists()); File[] dependencyFiles = dependenciesDir.listFiles(); - Assert.assertEquals(20, dependencyFiles.length); + Assert.assertEquals(23, dependencyFiles.length); } } diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java index fcad39d8cb..6d2f665c0a 100644 --- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java +++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java @@ -20,6 +20,8 @@ package org.apache.tuscany.sca.assembly; import javax.xml.namespace.QName; +import org.apache.tuscany.sca.interfacedef.DataType; + /** * A property allows for the configuration of an implementation with externally * set data values. An implementation can have zero or more properties. Each @@ -118,5 +120,16 @@ public interface AbstractProperty extends Base, Extensible { * @param element the element defining the type of this property */ void setXSDElement(QName element); - + + /** + * Get the data type for this property + * @return The data type + */ + DataType getDataType(); + + /** + * Set the data type + * @param dataType The data type + */ + void setDataType(DataType dataType); } diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java index 49995f5ab8..a7c033d479 100644 --- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java +++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java @@ -22,6 +22,7 @@ package org.apache.tuscany.sca.assembly.impl; import javax.xml.namespace.QName; import org.apache.tuscany.sca.assembly.AbstractProperty; +import org.apache.tuscany.sca.interfacedef.DataType; /** * Represents an abstract property. @@ -29,12 +30,13 @@ import org.apache.tuscany.sca.assembly.AbstractProperty; * @version $Rev$ $Date$ */ public class AbstractPropertyImpl extends ExtensibleImpl implements AbstractProperty { - private Object value; - private String name; - private QName xsdType; - private QName xsdElement; - private boolean many; - private boolean mustSupply; + protected Object value; + protected String name; + protected QName xsdType; + protected QName xsdElement; + protected boolean many; + protected boolean mustSupply; + protected DataType dataType; /** * Constructs a new abstract property. @@ -90,4 +92,12 @@ public class AbstractPropertyImpl extends ExtensibleImpl implements AbstractProp this.xsdType = type; } + public DataType getDataType() { + return dataType; + } + + public void setDataType(DataType dataType) { + this.dataType = dataType; + } + } diff --git a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java index df8c16c6b3..45e41d29ef 100644 --- a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java +++ b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java @@ -630,8 +630,8 @@ public class ComponentBuilderImpl { "PropertXSDElementsDontMatch", component.getName(), componentProperty.getName(), - componentProperty.getXSDElement().toString(), - componentTypeProperty.getXSDElement().toString()); + componentProperty.getXSDElement(), + componentTypeProperty.getXSDElement()); } if ( componentProperty.getXSDType() != null && @@ -642,8 +642,8 @@ public class ComponentBuilderImpl { "PropertXSDTypesDontMatch", component.getName(), componentProperty.getName(), - componentProperty.getXSDType().toString(), - componentTypeProperty.getXSDType().toString()); + componentProperty.getXSDType(), + componentTypeProperty.getXSDType()); } } } 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 dt = - new DataTypeImpl(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 nodes = getValues(doc); @@ -131,24 +119,28 @@ public class JavaPropertyValueObjectFactory implements PropertyValueFactory { sourceDataType = new DataTypeImpl(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(dataBinding, javaType, xmlType); - } else { - targetDataType = new DataTypeImpl(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(dataBinding, javaType, xmlType); + } else { + targetDataType = new DataTypeImpl(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 @@ tuscany-interface-java 2.0-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-databinding + 2.0-SNAPSHOT + org.apache.tuscany.sca 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 extends BaseJavaClassVisitor { private final Class annotationClass; + private Mediator mediator; protected AbstractPropertyProcessor(ExtensionPointRegistry registry, Class 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 dt = + new DataTypeImpl(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 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)) { diff --git a/sca-java-2.x/trunk/modules/policy-transaction/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/policy-transaction/META-INF/MANIFEST.MF index cb6c831909..c71bf60b22 100644 --- a/sca-java-2.x/trunk/modules/policy-transaction/META-INF/MANIFEST.MF +++ b/sca-java-2.x/trunk/modules/policy-transaction/META-INF/MANIFEST.MF @@ -8,6 +8,8 @@ Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt Bundle-Description: Apache Tuscany Security Policy Model Import-Package: javax.security.auth.callback, javax.security.auth.login, + javax.transaction;version="1.1.0", + javax.transaction.xa;version="1.1.0", javax.xml.namespace, javax.xml.stream, org.apache.tuscany.sca.assembly;version="2.0.0", diff --git a/sca-java-2.x/trunk/modules/policy-transaction/pom.xml b/sca-java-2.x/trunk/modules/policy-transaction/pom.xml index 98297e42dd..f45c74ad84 100644 --- a/sca-java-2.x/trunk/modules/policy-transaction/pom.xml +++ b/sca-java-2.x/trunk/modules/policy-transaction/pom.xml @@ -44,13 +44,13 @@ org.apache.geronimo.components geronimo-transaction - 2.1.1 + 2.1.3 org.apache.geronimo.components geronimo-connector - 2.1.1 + 2.1.3 -- cgit v1.2.3