Author: dkulp
Date: Thu Sep  1 16:42:30 2011
New Revision: 1164152

URL: http://svn.apache.org/viewvc?rev=1164152&view=rev
Log:
Merged revisions 1164145 via svnmerge from 
https://svn.us.apache.org/repos/asf/cxf/branches/2.4.x-fixes

................
  r1164145 | dkulp | 2011-09-01 12:36:05 -0400 (Thu, 01 Sep 2011) | 9 lines
  
  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.3.x-fixes/   (props changed)
    
cxf/branches/2.3.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java

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

Modified: 
cxf/branches/2.3.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
URL: 
http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java?rev=1164152&r1=1164151&r2=1164152&view=diff
==============================================================================
--- 
cxf/branches/2.3.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
 (original)
+++ 
cxf/branches/2.3.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
 Thu Sep  1 16:42:30 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);


Reply via email to