cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r959990 - /cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
Date Fri, 02 Jul 2010 14:05:39 GMT
Author: ema
Date: Fri Jul  2 14:05:39 2010
New Revision: 959990

URL: http://svn.apache.org/viewvc?rev=959990&view=rev
Log:
[CXF-2868]:Use JAXB Bridge to unmarshallwhen the field of partTypeClass is javax.xml.datatype.XMLGregorianCalendar

Modified:
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java?rev=959990&r1=959989&r2=959990&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
(original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
Fri Jul  2 14:05:39 2010
@@ -20,6 +20,7 @@
 package org.apache.cxf.jaxb.io;
 
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
 import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -28,6 +29,7 @@ import javax.xml.bind.JAXBException;
 import javax.xml.bind.PropertyException;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.bind.ValidationEventHandler;
+import javax.xml.datatype.XMLGregorianCalendar;
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.common.i18n.Message;
@@ -108,23 +110,43 @@ public class DataReaderImpl<T> extends J
             honorJaxbAnnotation = (Boolean)part.getProperty("honor.jaxb.annotations");
         }
         Annotation[] anns = null;
+       
         if (honorJaxbAnnotation) {
             anns = getJAXBAnnotation(part);
             if (anns.length > 0) {
-                //RpcLit will use the JAXB Bridge to unmarshall part message when it is 
-                //annotated with @XmlList,@XmlAttachmentRef,@XmlJavaTypeAdapter
-                //TODO:Cache the JAXBRIContext
+                // RpcLit will use the JAXB Bridge to unmarshall part message when it is
+                // annotated with @XmlList,@XmlAttachmentRef,@XmlJavaTypeAdapter
+                // TODO:Cache the JAXBRIContext
                 QName qname = new QName(null, part.getConcreteName().getLocalPart());
-    
-                return JAXBEncoderDecoder.unmarshalWithBridge(qname,
-                                                              part.getTypeClass(),
+
+                return JAXBEncoderDecoder.unmarshalWithBridge(qname, 
+                                                              part.getTypeClass(), 
                                                               anns, 
-                                                              databinding.getContextClasses(),
+                                                              databinding.getContextClasses(),

+                                                              reader, 
+                                                              getAttachmentUnmarshaller());
+            }
+        }
+        //The jaxb class contains XMLGregorianCalendar field also needs JAXB Bridge
+        if (part != null && part.getTypeClass() != null) {
+            boolean useJAXBBridge = false;
+            for (Field field : part.getTypeClass().getDeclaredFields()) {
+                if (field.getType().equals(XMLGregorianCalendar.class)) {
+                    useJAXBBridge = true;
+                    break;
+                }
+            }
+            if (useJAXBBridge) {
+                return JAXBEncoderDecoder.unmarshalWithBridge(part.getConcreteName(), 
+                                                              part.getTypeClass(),
+                                                              part.getTypeClass().getAnnotations(),
+                                                              databinding.getContextClasses(),

                                                               reader,
                                                               getAttachmentUnmarshaller());
             }
         }
         
+        
         return JAXBEncoderDecoder.unmarshall(createUnmarshaller(), reader, part, 
                                              unwrapJAXBElement);
     }



Mime
View raw message