Author: jim.ma
Date: 2014-04-08 07:20:31 -0400 (Tue, 08 Apr 2014)
New Revision: 18571
Modified:
thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
Log:
[JBPAPP-10973]:@XmlJavaTypeAdapter ignored at package-info.java level when using
Generics;backport CXF-4537
Modified:
thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java 2014-04-08
10:30:51 UTC (rev 18570)
+++
thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java 2014-04-08
11:20:31 UTC (rev 18571)
@@ -31,6 +31,7 @@
import java.lang.reflect.TypeVariable;
import java.lang.reflect.WildcardType;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -54,7 +55,6 @@
import org.apache.cxf.service.model.OperationInfo;
import org.apache.cxf.service.model.ServiceInfo;
import org.apache.cxf.service.model.UnwrappedOperationInfo;
-
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
@@ -67,6 +67,7 @@
private Set<Class<?>> classes;
private Collection<Object> typeReferences;
private Map<String, Object> unmarshallerProperties;
+ private Set<Class<?>> globalAdapters = new
HashSet<Class<?>>();
public JAXBContextInitializer(ServiceInfo serviceInfo,
Set<Class<?>> classes,
@@ -220,7 +221,20 @@
addType(t);
}
}
-
+ 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()) {
+ Type t = Utils.getTypeFromXmlAdapter(a);
+ if (t != null) {
+ addType(t);
+ }
+ }
+ }
+ }
}
private void addType(Type cls) {
@@ -228,6 +242,9 @@
}
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 {
Show replies by date