axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject svn commit: r689069 - in /webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2: datasource/jaxb/JAXBCustomBuilder.java jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java
Date Tue, 26 Aug 2008 13:23:47 GMT
Author: scheu
Date: Tue Aug 26 06:23:47 2008
New Revision: 689069

URL: http://svn.apache.org/viewvc?rev=689069&view=rev
Log:
Quick Fix
The Doc/Lit Bare marshaller unmarshals raw parameters (not a wrapper bean).
Thus it may have to unmarshal generic types (i.e. xml defined with an any) into
java.lang.Object parameters.  In such cases, it is best to disable the "early unmarshalling".

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBCustomBuilder.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBCustomBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBCustomBuilder.java?rev=689069&r1=689068&r2=689069&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBCustomBuilder.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBCustomBuilder.java
Tue Aug 26 06:23:47 2008
@@ -80,8 +80,14 @@
             OMNamespace ns = factory.createOMNamespace(namespace, reader.getPrefix());
             
             Object jaxb = jdsContext.unmarshal(reader);
+            if (log.isDebugEnabled()) {
+                log.debug("Successfully unmarshalled jaxb object " + jaxb);
+            }
             
             OMDataSource ds = new JAXBDataSource(jaxb, jdsContext);
+            if (log.isDebugEnabled()) {
+                log.debug("The JAXBDataSource is " + ds);
+            }
             OMSourcedElement omse = factory.createOMElement(ds, localPart, ns);
             
             parent.addChild(omse);

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java?rev=689069&r1=689068&r2=689069&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java
Tue Aug 26 06:23:47 2008
@@ -20,6 +20,7 @@
 package org.apache.axis2.jaxws.marshaller.impl.alt;
 
 import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.core.MessageContext;
 import org.apache.axis2.jaxws.description.AttachmentDescription;
 import org.apache.axis2.jaxws.description.AttachmentType;
 import org.apache.axis2.jaxws.description.EndpointDescription;
@@ -83,9 +84,11 @@
 
             // Remember this unmarshal information so that we can speed up processing
             // the next time.
-            MethodMarshallerUtils.registerUnmarshalInfo(message.getMessageContext(),
-                                                        packages,
-                                                        marshalDesc.getPackagesKey());
+            if (shouldRegisterUnmarshalInfo(operationDesc, message.getMessageContext()))
{
+                MethodMarshallerUtils.registerUnmarshalInfo(message.getMessageContext(),
+                                                            packages,
+                                                            marshalDesc.getPackagesKey());
+            }
 
             // Get the return value.
             Class returnType = operationDesc.getResultActualType();
@@ -170,9 +173,11 @@
 
             // Remember this unmarshal information so that we can speed up processing
             // the next time.
-            MethodMarshallerUtils.registerUnmarshalInfo(message.getMessageContext(),
-                                                        packages,
-                                                        marshalDesc.getPackagesKey());
+            if (shouldRegisterUnmarshalInfo(operationDesc, message.getMessageContext()))
{
+                MethodMarshallerUtils.registerUnmarshalInfo(message.getMessageContext(),
+                                                            packages,
+                                                            marshalDesc.getPackagesKey());
+            }
 
             // Unmarshal the ParamValues from the message
             List<PDElement> pvList = MethodMarshallerUtils.getPDElements(pds,
@@ -412,4 +417,33 @@
         }
     }
 
+    /**
+     * Registering UnmarshalInfo will cause JAXB unmarshalling to occur
+     * during StAXOMBuilder processing the next time an xml message is targered
+     * at this wsdl operation.  In some cases we want to disable this early unmarshalling.
+     * 
+     * @param OperationDescription
+     * @param MessageContext
+     * @return true or false
+     */
+    private static boolean shouldRegisterUnmarshalInfo(OperationDescription opDesc, 
+                                                       MessageContext mc) {
+        
+        ParameterDescription[] pds = opDesc.getParameterDescriptions();
+        
+        // If one or more operations have a generic type of Object, then
+        // avoid early unmarshalling
+        for (int i=0; i<pds.length; i++) {
+            ParameterDescription pd = pds[i];
+            if (pd.getParameterActualType() == null ||
+                pd.getParameterActualType().isAssignableFrom(Object.class)) {
+                return false;
+            }          
+        }
+        if (opDesc.getResultActualType() == null ||
+                opDesc.getResultActualType().isAssignableFrom(Object.class)) {
+            return false;
+        }
+        return true;
+    }
 }



Mime
View raw message