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 sc...@apache.org on 2007/04/12 22:40:41 UTC

svn commit: r528224 - in /webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt: DocLitBareMinimalMethodMarshaller.java DocLitWrappedPlusMethodMarshaller.java MethodMarshallerUtils.java RPCLitMethodMarshaller.java

Author: scheu
Date: Thu Apr 12 13:40:40 2007
New Revision: 528224

URL: http://svn.apache.org/viewvc?view=rev&rev=528224
Log:
AXIS2-2520
Contributor:Rich Scheuerle
Upgrade the "by type" marshalling/unmarshalling to include all classes that don't have @XmlRootElement

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMinimalMethodMarshaller.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedPlusMethodMarshaller.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMinimalMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMinimalMethodMarshaller.java?view=diff&rev=528224&r1=528223&r2=528224
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMinimalMethodMarshaller.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMinimalMethodMarshaller.java Thu Apr 12 13:40:40 2007
@@ -88,7 +88,7 @@
             if (returnType != void.class) {
                 // Use "byJavaType" unmarshalling if necessary
                 Class byJavaType = null;
-                if (MethodMarshallerUtils.isJAXBBasicType(returnType)) {
+                if (MethodMarshallerUtils.isNotJAXBRootElement(returnType, marshalDesc)) {
                     byJavaType = returnType;
                 }
                 // If the webresult is in the header, we need the name of the header so that we can find it.
@@ -118,7 +118,7 @@
             for (int i = 0; i < pds.length; i++) {
                 ParameterDescription pd = pds[i];
                 Class type = pd.getParameterActualType();
-                if (MethodMarshallerUtils.isJAXBBasicType(type)) {
+                if (MethodMarshallerUtils.isNotJAXBRootElement(type, marshalDesc)) {
                     javaTypes[i] = type;
                 }
             }
@@ -171,7 +171,7 @@
                 ParameterDescription pd = pds[i];
                 Class type = pd.getParameterActualType();
                 // If it is a JAXB basic type or it has no annotations
-                if (MethodMarshallerUtils.isJAXBBasicType(type)) {
+                if (MethodMarshallerUtils.isNotJAXBRootElement(type, marshalDesc)) {
                     javaTypes[i] = type;
                 } else {
                     Annotation annos[] = type.getAnnotations();
@@ -244,7 +244,7 @@
 
                 // Use byJavaType marshalling if necessary
                 Class byJavaType = null;
-                if (MethodMarshallerUtils.isJAXBBasicType(returnType)) {
+                if (MethodMarshallerUtils.isNotJAXBRootElement(returnType, marshalDesc)) {
                     byJavaType = returnType;
                 }
 
@@ -274,7 +274,7 @@
             for (PDElement pde : pdeList) {
                 ParameterDescription pd = pde.getParam();
                 Class type = pd.getParameterActualType();
-                if (MethodMarshallerUtils.isJAXBBasicType(type)) {
+                if (MethodMarshallerUtils.isNotJAXBRootElement(type, marshalDesc)) {
                     pde.setByJavaTypeClass(type);
                 }
             }
@@ -334,7 +334,7 @@
             for (PDElement pde : pdeList) {
                 ParameterDescription pd = pde.getParam();
                 Class type = pd.getParameterActualType();
-                if (MethodMarshallerUtils.isJAXBBasicType(type)) {
+                if (MethodMarshallerUtils.isNotJAXBRootElement(type, marshalDesc)) {
                     pde.setByJavaTypeClass(type);
                 }
             }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedPlusMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedPlusMethodMarshaller.java?view=diff&rev=528224&r1=528223&r2=528224
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedPlusMethodMarshaller.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedPlusMethodMarshaller.java Thu Apr 12 13:40:40 2007
@@ -220,7 +220,7 @@
                     if (blkContext.getConstructionType() != JAXBUtils.CONSTRUCTION_TYPE
                             .BY_CONTEXT_PATH) {
                         Class actualType = pd.getParameterActualType();
-                        if (MethodMarshallerUtils.isJAXBBasicType(actualType)) {
+                        if (MethodMarshallerUtils.isNotJAXBRootElement(actualType, marshalDesc)) {
                             blkContext.setProcessType(actualType);
                         }
                     }
@@ -372,7 +372,7 @@
                     if (blkContext.getConstructionType() != JAXBUtils.CONSTRUCTION_TYPE
                             .BY_CONTEXT_PATH) {
                         Class actualType = pd.getParameterActualType();
-                        if (MethodMarshallerUtils.isJAXBBasicType(actualType)) {
+                        if (MethodMarshallerUtils.isNotJAXBRootElement(actualType, marshalDesc)) {
                             blkContext.setProcessType(actualType);
                         } else {
                             Annotation annos[] = actualType.getAnnotations();
@@ -504,7 +504,7 @@
                     }
 
                     Class byJavaType =
-                            MethodMarshallerUtils.isJAXBBasicType(returnType) ? returnType : null;
+                            MethodMarshallerUtils.isNotJAXBRootElement(returnType, marshalDesc) ? returnType : null;
 
                     MethodMarshallerUtils.toMessage(returnElement, returnType,
                                                     marshalDesc, m,
@@ -543,7 +543,7 @@
                 // Use "by java type" marshalling if necessary
                 for (PDElement pde : headerPDEList) {
                     Class actualType = pde.getParam().getParameterActualType();
-                    if (MethodMarshallerUtils.isJAXBBasicType(actualType)) {
+                    if (MethodMarshallerUtils.isNotJAXBRootElement(actualType, marshalDesc)) {
                         pde.setByJavaTypeClass(actualType);
                     }
                 }
@@ -658,7 +658,7 @@
                 // Use "by java type" marshalling if necessary
                 for (PDElement pde : headerPDEList) {
                     Class actualType = pde.getParam().getParameterActualType();
-                    if (MethodMarshallerUtils.isJAXBBasicType(actualType)) {
+                    if (MethodMarshallerUtils.isNotJAXBRootElement(actualType, marshalDesc)) {
                         pde.setByJavaTypeClass(actualType);
                     }
                 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java?view=diff&rev=528224&r1=528223&r2=528224
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java Thu Apr 12 13:40:40 2007
@@ -37,6 +37,7 @@
 import org.apache.axis2.jaxws.message.factory.JAXBBlockFactory;
 import org.apache.axis2.jaxws.message.util.XMLFaultUtils;
 import org.apache.axis2.jaxws.registry.FactoryRegistry;
+import org.apache.axis2.jaxws.runtime.description.marshal.AnnotationDesc;
 import org.apache.axis2.jaxws.runtime.description.marshal.FaultBeanDesc;
 import org.apache.axis2.jaxws.runtime.description.marshal.MarshalServiceRuntimeDescription;
 import org.apache.axis2.jaxws.runtime.description.marshal.MarshalServiceRuntimeDescriptionFactory;
@@ -597,7 +598,7 @@
                 if (faultBeanObject == t ||
                         (context.getConstructionType() != JAXBUtils.CONSTRUCTION_TYPE
                                 .BY_CONTEXT_PATH &&
-                                isJAXBBasicType(faultBeanObject.getClass()))) {
+                                isNotJAXBRootElement(faultBeanObject.getClass(), marshalDesc))) {
                     context.setProcessType(faultBeanObject.getClass());
                 }
 
@@ -816,7 +817,7 @@
 
             // Use "by java type" marshalling if necessary
             if (blockContext.getConstructionType() != JAXBUtils.CONSTRUCTION_TYPE.BY_CONTEXT_PATH &&
-                    isJAXBBasicType(faultBeanFormalClass)) {
+                    isNotJAXBRootElement(faultBeanFormalClass, marshalDesc)) {
                 blockContext.setProcessType(faultBeanFormalClass);
             }
 
@@ -1063,11 +1064,11 @@
      * This probably should be available from the ParameterDescription
      *
      * @param cls
+     * @param marshalDesc
      * @return true if primitive, wrapper, java.lang.String. Calendar (or GregorianCalendar),
      *         BigInteger etc or anything other java type that is mapped by the basic schema types
      */
-    static boolean isJAXBBasicType(Class cls) {
-        // TODO : Others ?  Look at default JAXBContext
+    static boolean isNotJAXBRootElement(Class cls, MarshalServiceRuntimeDescription marshalDesc) {
         if (cls == String.class ||
                 cls.isPrimitive() ||
                 cls == Calendar.class ||
@@ -1079,9 +1080,12 @@
 
             return true;
         }
-        return false;
-
-
+        AnnotationDesc aDesc = marshalDesc.getAnnotationDesc(cls);
+        if (aDesc != null) {
+            // XmlRootElementName returns null if @XmlRootElement is not specified
+            return (aDesc.getXmlRootElementName() == null);
+        }
+        return true;  
     }
     
     /**

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java?view=diff&rev=528224&r1=528223&r2=528224
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java Thu Apr 12 13:40:40 2007
@@ -131,7 +131,7 @@
                 ParameterDescription pd = pde.getParam();
                 Class type = pd.getParameterActualType();
                 if (!pd.isHeader() ||
-                        MethodMarshallerUtils.isJAXBBasicType(type)) {
+                        MethodMarshallerUtils.isNotJAXBRootElement(type, marshalDesc)) {
                     pde.setByJavaTypeClass(type);
                 }
             }
@@ -188,7 +188,7 @@
                 ParameterDescription pd = pds[i];
                 Class type = pd.getParameterActualType();
                 if (!pd.isHeader() ||
-                        MethodMarshallerUtils.isJAXBBasicType(type)) {
+                        MethodMarshallerUtils.isNotJAXBRootElement(type, marshalDesc)) {
                     javaTypes[i] = type;
                 }
             }
@@ -316,7 +316,7 @@
                 // Use marshalling by java type if necessary
                 Class byJavaType = null;
                 if (!operationDesc.isResultHeader() ||
-                        MethodMarshallerUtils.isJAXBBasicType(returnType)) {
+                        MethodMarshallerUtils.isNotJAXBRootElement(returnType, marshalDesc)) {
                     byJavaType = returnType;
                 }
                 MethodMarshallerUtils.toMessage(returnElement,
@@ -342,7 +342,7 @@
                 ParameterDescription pd = pde.getParam();
                 Class type = pd.getParameterActualType();
                 if (!pd.isHeader() ||
-                        MethodMarshallerUtils.isJAXBBasicType(type)) {
+                        MethodMarshallerUtils.isNotJAXBRootElement(type, marshalDesc)) {
                     pde.setByJavaTypeClass(type);
                 }
             }
@@ -403,7 +403,7 @@
                 // Use "byJavaType" unmarshalling if necessary
                 Class byJavaType = null;
                 if (!operationDesc.isResultHeader() ||
-                        MethodMarshallerUtils.isJAXBBasicType(returnType)) {
+                        MethodMarshallerUtils.isNotJAXBRootElement(returnType, marshalDesc)) {
                     byJavaType = returnType;
                 }
                 if (operationDesc.isResultHeader()) {
@@ -434,7 +434,7 @@
                 ParameterDescription pd = pds[i];
                 Class type = pd.getParameterActualType();
                 if (!pd.isHeader() ||
-                        MethodMarshallerUtils.isJAXBBasicType(type)) {
+                        MethodMarshallerUtils.isNotJAXBRootElement(type, marshalDesc)) {
                     javaTypes[i] = type;
                 }
             }



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