tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r810694 - in /tuscany/branches/sca-java-1.5.1/modules: binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/ databinding-jaxb/ databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/
Date Wed, 02 Sep 2009 20:23:08 GMT
Author: rfeng
Date: Wed Sep  2 20:23:08 2009
New Revision: 810694

URL: http://svn.apache.org/viewvc?rev=810694&view=rev
Log:
Fix for TUSCANY-3238

Modified:
    tuscany/branches/sca-java-1.5.1/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java
    tuscany/branches/sca-java-1.5.1/modules/databinding-jaxb/pom.xml
    tuscany/branches/sca-java-1.5.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java

Modified: tuscany/branches/sca-java-1.5.1/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.5.1/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java?rev=810694&r1=810693&r2=810694&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.5.1/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java
(original)
+++ tuscany/branches/sca-java-1.5.1/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java
Wed Sep  2 20:23:08 2009
@@ -43,6 +43,7 @@
 import javax.wsdl.WSDLException;
 import javax.wsdl.extensions.schema.Schema;
 import javax.wsdl.factory.WSDLFactory;
+import javax.xml.bind.annotation.XmlSeeAlso;
 import javax.xml.namespace.QName;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
@@ -55,6 +56,7 @@
 import org.apache.tuscany.sca.interfacedef.DataType;
 import org.apache.tuscany.sca.interfacedef.Interface;
 import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
 import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
 import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
 import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
@@ -246,8 +248,38 @@
                 addDataType(dataTypes, dt4, helpers);
             }
         }
+        // Adding classes referenced by @XmlSeeAlso in the java interface
+        if (intf instanceof JavaInterface) {
+            JavaInterface javaInterface = (JavaInterface)intf;
+            Class<?>[] seeAlso = getSeeAlso(javaInterface.getJavaClass());
+            if (seeAlso != null) {
+                for (Class<?> cls : seeAlso) {
+                    DataType dt = new DataTypeImpl<XMLType>(JAXBDataBinding.NAME, cls,
XMLType.UNKNOWN);
+                    addDataType(dataTypes, dt, helpers);
+                }
+            }
+            seeAlso = getSeeAlso(javaInterface.getCallbackClass());
+            if (seeAlso != null) {
+                for (Class<?> cls : seeAlso) {
+                    DataType dt = new DataTypeImpl<XMLType>(JAXBDataBinding.NAME, cls,
XMLType.UNKNOWN);
+                    addDataType(dataTypes, dt, helpers);
+                }
+            }
+        }
         return dataTypes;
     }
+    
+    private static Class<?>[] getSeeAlso(Class<?> interfaze) {
+        if (interfaze == null) {
+            return null;
+        }
+        XmlSeeAlso seeAlso = interfaze.getAnnotation(XmlSeeAlso.class);
+        if (seeAlso == null) {
+            return null;
+        } else {
+            return seeAlso.value();
+        }
+    }
 
 
     public Definition generate(Interface interfaze, WSDLDefinition wsdlDefinition) throws
WSDLException {

Modified: tuscany/branches/sca-java-1.5.1/modules/databinding-jaxb/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.5.1/modules/databinding-jaxb/pom.xml?rev=810694&r1=810693&r2=810694&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.5.1/modules/databinding-jaxb/pom.xml (original)
+++ tuscany/branches/sca-java-1.5.1/modules/databinding-jaxb/pom.xml Wed Sep  2 20:23:08 2009
@@ -39,13 +39,11 @@
             <artifactId>tuscany-databinding</artifactId>
             <version>1.5.1-SNAPSHOT</version>
         </dependency>
-        <!-- 
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-interface-java-xml</artifactId>
+            <artifactId>tuscany-interface-java</artifactId>
             <version>1.5.1-SNAPSHOT</version>
         </dependency>
-         -->
         <dependency>
             <groupId>javax.xml.bind</groupId>
             <artifactId>jaxb-api</artifactId>

Modified: tuscany/branches/sca-java-1.5.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.5.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java?rev=810694&r1=810693&r2=810694&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.5.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java
(original)
+++ tuscany/branches/sca-java-1.5.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java
Wed Sep  2 20:23:08 2009
@@ -37,6 +37,7 @@
 import javax.xml.bind.annotation.XmlEnum;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlSchema;
+import javax.xml.bind.annotation.XmlSeeAlso;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.namespace.QName;
 
@@ -47,6 +48,8 @@
 import org.apache.tuscany.sca.interfacedef.DataType;
 import org.apache.tuscany.sca.interfacedef.Interface;
 import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
 import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
 import org.apache.tuscany.sca.interfacedef.util.XMLType;
 
@@ -98,6 +101,18 @@
         return createJAXBContext(dataType);
 
     }
+    
+    private static Class<?>[] getSeeAlso(Class<?> interfaze) {
+        if (interfaze == null) {
+            return null;
+        }
+        XmlSeeAlso seeAlso = interfaze.getAnnotation(XmlSeeAlso.class);
+        if (seeAlso == null) {
+            return null;
+        } else {
+            return seeAlso.value();
+        }
+    }
 
     public static JAXBContext createJAXBContext(DataType dataType) throws JAXBException {
         return createJAXBContext(findClasses(dataType));
@@ -298,6 +313,23 @@
     private static List<DataType> getDataTypes(Operation op, boolean useWrapper) {
         List<DataType> dataTypes = new ArrayList<DataType>();
         getDataTypes(dataTypes, op, useWrapper);
+        // Adding classes referenced by @XmlSeeAlso in the java interface
+        Interface interface1 = op.getInterface();
+        if (interface1 instanceof JavaInterface) {
+            JavaInterface javaInterface = (JavaInterface)interface1;
+            Class<?>[] seeAlso = getSeeAlso(javaInterface.getJavaClass());
+            if (seeAlso != null) {
+                for (Class<?> cls : seeAlso) {
+                    dataTypes.add(new DataTypeImpl<XMLType>(JAXBDataBinding.NAME, cls,
XMLType.UNKNOWN));
+                }
+            }
+            seeAlso = getSeeAlso(javaInterface.getCallbackClass());
+            if (seeAlso != null) {
+                for (Class<?> cls : seeAlso) {
+                    dataTypes.add(new DataTypeImpl<XMLType>(JAXBDataBinding.NAME, cls,
XMLType.UNKNOWN));
+                }
+            }
+        }
         return dataTypes;
     }
 



Mime
View raw message