cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1164145 - in /cxf/branches/2.4.x-fixes: ./ rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
Date Thu, 01 Sep 2011 16:36:05 GMT
Author: dkulp
Date: Thu Sep  1 16:36:05 2011
New Revision: 1164145

URL: http://svn.apache.org/viewvc?rev=1164145&view=rev
Log:
Merged revisions 1164141 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1164141 | dkulp | 2011-09-01 12:33:15 -0400 (Thu, 01 Sep 2011) | 1 line
  
  [CXF-2779] Us getDeclaredField so we can get the private fields
........

Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.4.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java?rev=1164145&r1=1164144&r2=1164145&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
Thu Sep  1 16:36:05 2011
@@ -49,6 +49,7 @@ import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
 import javax.xml.bind.attachment.AttachmentMarshaller;
 import javax.xml.bind.attachment.AttachmentUnmarshaller;
@@ -356,16 +357,18 @@ public final class JAXBEncoderDecoder {
             } else {
                 LOG.warning("Schema associated with " + namespace + " is null");
             }
-            
             for (Field f : cls.getDeclaredFields()) {
                 if (JAXBContextInitializer.isFieldAccepted(f, accessType)) {
-                    QName fname = new QName(namespace, f.getName());
-                    f.setAccessible(true);
-                    if (JAXBSchemaInitializer.isArray(f.getGenericType())) {
-                        writeArrayObject(marshaller, writer, fname, f.get(elValue));    
                   
-                    } else {
-                        writeObject(marshaller, writer, new JAXBElement(fname, String.class,

-                                                                        f.get(elValue)));
+                    XmlAttribute at = f.getAnnotation(XmlAttribute.class);
+                    if (at == null) {
+                        QName fname = new QName(namespace, f.getName());
+                        f.setAccessible(true);
+                        if (JAXBSchemaInitializer.isArray(f.getGenericType())) {
+                            writeArrayObject(marshaller, writer, fname, f.get(elValue));
+                        } else {
+                            writeObject(marshaller, writer, new JAXBElement(fname, String.class,

+                                                                            f.get(elValue)));
+                        }
                     }
                 }
             }
@@ -462,7 +465,12 @@ public final class JAXBEncoderDecoder {
             while (reader.getEventType() == XMLStreamReader.START_ELEMENT) {
                 QName q = reader.getName();
                 try {
-                    Field f = cls.getField(q.getLocalPart());
+                    Field f =  null;
+                    try {
+                        f = cls.getDeclaredField(q.getLocalPart());
+                    } catch (NoSuchFieldException nsf) {
+                        f = cls.getField(q.getLocalPart());
+                    }
                     Type type = f.getGenericType();
                     if (JAXBContextInitializer.isFieldAccepted(f, accessType)) {
                         f.setAccessible(true);



Mime
View raw message