cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1393137 - /cxf/branches/2.5.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
Date Tue, 02 Oct 2012 19:44:51 GMT
Author: dkulp
Date: Tue Oct  2 19:44:50 2012
New Revision: 1393137

URL: http://svn.apache.org/viewvc?rev=1393137&view=rev
Log:
Merged revisions 1393107 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes

........
  r1393107 | dkulp | 2012-10-02 15:09:23 -0400 (Tue, 02 Oct 2012) | 10 lines

  Merged revisions 1393093 via  git cherry-pick from
  https://svn.apache.org/repos/asf/cxf/trunk

  ........
    r1393093 | dkulp | 2012-10-02 14:50:12 -0400 (Tue, 02 Oct 2012) | 2 lines

    [CXF-4537] Examine the package level adapters as well

  ........

........

Modified:
    cxf/branches/2.5.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java

Modified: cxf/branches/2.5.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java?rev=1393137&r1=1393136&r2=1393137&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
Tue Oct  2 19:44:50 2012
@@ -30,6 +30,7 @@ import java.lang.reflect.Type;
 import java.lang.reflect.TypeVariable;
 import java.lang.reflect.WildcardType;
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.Set;
 
 import javax.xml.bind.annotation.XmlAccessType;
@@ -41,6 +42,7 @@ import javax.xml.bind.annotation.XmlTran
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
@@ -60,6 +62,7 @@ class JAXBContextInitializer extends Ser
 
     private Set<Class<?>> classes;
     private Collection<Object> typeReferences;
+    private Set<Class<?>> globalAdapters = new HashSet<Class<?>>();
 
     public JAXBContextInitializer(ServiceInfo serviceInfo,
                                   Set<Class<?>> classes,
@@ -205,7 +208,17 @@ class JAXBContextInitializer extends Ser
         if (xjta != null) {
             inspectTypeAdapter(xjta.value());
         }
-        
+        if (clazz.getPackage() != null) {
+            XmlJavaTypeAdapters adapt = clazz.getPackage().getAnnotation(XmlJavaTypeAdapters.class);
+            if (adapt != null) {
+                for (XmlJavaTypeAdapter a: adapt.value()) {
+                    globalAdapters.add(a.type());
+                }
+                for (XmlJavaTypeAdapter a: adapt.value()) {
+                    inspectTypeAdapter(a.value());
+                }
+            }
+        }
     }
 
     private void addType(Type cls) {
@@ -213,6 +226,9 @@ class JAXBContextInitializer extends Ser
     }
     private void addType(Type cls, boolean allowArray) {
         if (cls instanceof Class) {
+            if (globalAdapters.contains(cls)) {
+                return;
+            }
             if (((Class<?>)cls).isArray() && !allowArray) {
                 addClass(((Class<?>)cls).getComponentType());
             } else {
@@ -452,4 +468,4 @@ class JAXBContextInitializer extends Ser
         }
         return false;
     }
-}
\ No newline at end of file
+}



Mime
View raw message