axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r464450 - in /webservices/axis2/branches/java/1_1/modules/jaxbri/src/org/apache/axis2/jaxbri: CodeGenerationUtility.java template/JaxbRIDatabindingTemplate.xsl
Date Mon, 16 Oct 2006 11:35:19 GMT
Author: dims
Date: Mon Oct 16 04:35:18 2006
New Revision: 464450

URL: http://svn.apache.org/viewvc?view=rev&rev=464450
Log:
Fix for AXIS2-1389 - JaxbRIDatabindingTemplate.xsl hard-codes edu.indiana.extreme.www.wsdl.benchmark1.EchoVoid
at line 116

Modified:
    webservices/axis2/branches/java/1_1/modules/jaxbri/src/org/apache/axis2/jaxbri/CodeGenerationUtility.java
    webservices/axis2/branches/java/1_1/modules/jaxbri/src/org/apache/axis2/jaxbri/template/JaxbRIDatabindingTemplate.xsl

Modified: webservices/axis2/branches/java/1_1/modules/jaxbri/src/org/apache/axis2/jaxbri/CodeGenerationUtility.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/jaxbri/src/org/apache/axis2/jaxbri/CodeGenerationUtility.java?view=diff&rev=464450&r1=464449&r2=464450
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/jaxbri/src/org/apache/axis2/jaxbri/CodeGenerationUtility.java
(original)
+++ webservices/axis2/branches/java/1_1/modules/jaxbri/src/org/apache/axis2/jaxbri/CodeGenerationUtility.java
Mon Oct 16 04:35:18 2006
@@ -23,6 +23,7 @@
 import com.sun.tools.xjc.api.SchemaCompiler;
 import com.sun.tools.xjc.api.XJC;
 import org.apache.axis2.util.URLProcessor;
+import org.apache.axis2.util.SchemaUtil;
 import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
 import org.apache.axis2.wsdl.databinding.DefaultTypeMapper;
 import org.apache.axis2.wsdl.databinding.JavaTypeMapper;
@@ -86,12 +87,13 @@
             	
                 SchemaCompiler sc = XJC.createSchemaCompiler();
                 XmlSchema schema = (XmlSchema) schemas.get(i);
+
                 String pkg = null;
                 if(nsMap != null) {
                     pkg = (String) nsMap.get(schema.getTargetNamespace());
                 }
-                if(pkg == null) {
-                    pkg = URLProcessor.makePackageName(schema.getTargetNamespace());
+                if (pkg == null) {
+                    pkg = extractNamespace(schema);
                 }
                 sc.setDefaultPackageName(pkg);
 
@@ -125,6 +127,24 @@
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
+    }
+
+    private static String extractNamespace(XmlSchema schema) {
+        String pkg;
+        pkg = schema.getTargetNamespace();
+        if (pkg == null) {
+            XmlSchema[] schemas2 = SchemaUtil.getAllSchemas(schema);
+            for (int j = 0; schemas2 != null && j < schemas2.length; j++) {
+                pkg = schemas2[j].getTargetNamespace();
+                if (pkg != null)
+                    break;
+            }
+        }
+        if (pkg == null) {
+            pkg = URLProcessor.DEFAULT_PACKAGE;
+        }
+        pkg = URLProcessor.makePackageName(pkg);
+        return pkg;
     }
 
     private static String getSchemaAsString(XmlSchema schema) {

Modified: webservices/axis2/branches/java/1_1/modules/jaxbri/src/org/apache/axis2/jaxbri/template/JaxbRIDatabindingTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/jaxbri/src/org/apache/axis2/jaxbri/template/JaxbRIDatabindingTemplate.xsl?view=diff&rev=464450&r1=464449&r2=464450
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/jaxbri/src/org/apache/axis2/jaxbri/template/JaxbRIDatabindingTemplate.xsl
(original)
+++ webservices/axis2/branches/java/1_1/modules/jaxbri/src/org/apache/axis2/jaxbri/template/JaxbRIDatabindingTemplate.xsl
Mon Oct 16 04:35:18 2006
@@ -24,7 +24,7 @@
                         javax.xml.bind.Marshaller marshaller = context.createMarshaller();
                         marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
           
         
-                        JaxbRIDataSource source = new JaxbRIDataSource(param, marshaller);
+                        JaxbRIDataSource source = new JaxbRIDataSource(<xsl:value-of select="@type"/>.class,
param, marshaller);
                         javax.xml.namespace.QName elementName = context.createJAXBIntrospector().getElementName(param);
                         org.apache.axiom.om.OMNamespace namespace = factory.createOMNamespace(elementName.getNamespaceURI(),
null);
                         return factory.createOMElement(source, elementName.getNamespaceURI(),
namespace);
@@ -72,6 +72,11 @@
             private final Object outObject;
 
             /**
+             * Bound class for output.
+             */
+            private final Class outClazz;
+
+            /**
              * Marshaller.
              */
             private final javax.xml.bind.Marshaller marshaller;
@@ -82,7 +87,8 @@
              * @param obj
              * @param marshaller
              */
-            public JaxbRIDataSource(Object obj, javax.xml.bind.Marshaller marshaller) {
+            public JaxbRIDataSource(Class clazz, Object obj, javax.xml.bind.Marshaller marshaller)
{
+                this.outClazz = clazz;
                 this.outObject = obj;
                 this.marshaller = marshaller;
             }
@@ -113,7 +119,7 @@
 
             public javax.xml.stream.XMLStreamReader getReader() throws javax.xml.stream.XMLStreamException
{
                 try {
-                    javax.xml.bind.JAXBContext context = javax.xml.bind.JAXBContext.newInstance(edu.indiana.extreme.www.wsdl.benchmark1.EchoVoid.class);
+                    javax.xml.bind.JAXBContext context = javax.xml.bind.JAXBContext.newInstance(outClazz);
                     org.apache.axiom.om.impl.builder.SAXOMBuilder builder = new org.apache.axiom.om.impl.builder.SAXOMBuilder();
                     javax.xml.bind.Marshaller marshaller = context.createMarshaller();
                     marshaller.marshal(outObject, builder);



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


Mime
View raw message