You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2007/06/06 03:51:41 UTC

svn commit: r544705 - /webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/jaxbri/JaxbSchemaGenerator.java

Author: dims
Date: Tue Jun  5 18:51:40 2007
New Revision: 544705

URL: http://svn.apache.org/viewvc?view=rev&rev=544705
Log:
set the jaxbcontext namespace correctly. add the qName/class mapping to the typeTable

Modified:
    webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/jaxbri/JaxbSchemaGenerator.java

Modified: webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/jaxbri/JaxbSchemaGenerator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/jaxbri/JaxbSchemaGenerator.java?view=diff&rev=544705&r1=544704&r2=544705
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/jaxbri/JaxbSchemaGenerator.java (original)
+++ webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/jaxbri/JaxbSchemaGenerator.java Tue Jun  5 18:51:40 2007
@@ -3,6 +3,8 @@
 import org.apache.axis2.description.java2wsdl.DefaultSchemaGenerator;
 import org.apache.axis2.util.Loader;
 import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaObject;
+import org.apache.ws.commons.schema.XmlSchemaType;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -25,6 +27,9 @@
 import java.util.Map;
 import java.util.Set;
 
+import com.sun.xml.bind.v2.runtime.JaxBeanInfo;
+import com.sun.xml.bind.v2.runtime.JAXBContextImpl;
+
 /*
 * Copyright 2004,2005 The Apache Software Foundation.
 *
@@ -59,8 +64,15 @@
             }
         }
 
-        JAXBContext context = createJAXBContext(classes,
-                (isUseWSDLTypesNamespace() ? ((String) pkg2nsmap.get("all")) : null));
+        String jaxbNamespace = null;
+        if(isUseWSDLTypesNamespace()){
+            jaxbNamespace = (String) pkg2nsmap.get("all");
+        }
+        if(jaxbNamespace == null) {
+            jaxbNamespace = this.getSchemaTargetNameSpace();
+        }
+
+        JAXBContextImpl context = (JAXBContextImpl) createJAXBContext(classes, jaxbNamespace);
 
         for (DOMResult r : generateJaxbSchemas(context)) {
             Document d = (Document) r.getNode();
@@ -82,10 +94,27 @@
             }
 
             XmlSchema xmlSchema = xmlSchemaCollection.read(d.getDocumentElement());
+
+            for (Class clazz : classes) {
+                JaxBeanInfo<?> beanInfo = context.getBeanInfo(clazz);
+                QName qName = getTypeName(beanInfo);
+                if(qName != null) {
+                    typeTable.addComplexSchema(clazz.getName(), qName);
+                }
+            }
             schemaMap.put(targetNamespace, xmlSchema);
         }
 
         return super.generateSchema();
+    }
+
+    private QName getTypeName(JaxBeanInfo<?> beanInfo) {
+        Iterator<QName> itr = beanInfo.getTypeNames().iterator();
+        if (!itr.hasNext()) {
+            return null;
+        }
+
+        return itr.next();
     }
 
     private List<Class<?>> processMethods(Method[] declaredMethods) throws Exception {



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