cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1393093 - /cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
Date Tue, 02 Oct 2012 18:50:12 GMT
Author: dkulp
Date: Tue Oct  2 18:50:12 2012
New Revision: 1393093

URL: http://svn.apache.org/viewvc?rev=1393093&view=rev
Log:
[CXF-4537] Examine the package level adapters as well

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

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java?rev=1393093&r1=1393092&r2=1393093&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
(original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
Tue Oct  2 18:50:12 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 org.apache.cxf.common.classloader.JAXBClassLoaderUtils;
 import org.apache.cxf.common.jaxb.JAXBUtils;
@@ -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,
@@ -185,7 +188,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) {
@@ -193,6 +206,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 {



Mime
View raw message