cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r691488 - /cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
Date Wed, 03 Sep 2008 03:20:37 GMT
Author: dkulp
Date: Tue Sep  2 20:20:37 2008
New Revision: 691488

URL: http://svn.apache.org/viewvc?rev=691488&view=rev
Log:
[CXF-1624] Check the ObjectFactory to see if the defaultNs can be set or not.

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

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java?rev=691488&r1=691487&r2=691488&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java (original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java Tue
Sep  2 20:20:37 2008
@@ -25,6 +25,7 @@
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.lang.ref.WeakReference;
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -44,6 +45,7 @@
 import javax.xml.bind.Marshaller;
 import javax.xml.bind.SchemaOutputResolver;
 import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.XmlElementDecl;
 import javax.xml.stream.XMLEventReader;
 import javax.xml.stream.XMLEventWriter;
 import javax.xml.stream.XMLStreamReader;
@@ -501,7 +503,8 @@
         addWsAddressingTypes(classes);
 
         for (Class<?> clz : classes) {
-            if (clz.getName().endsWith("ObjectFactory")) {
+            if (clz.getName().endsWith("ObjectFactory")
+                && checkObjectFactoryNamespaces(clz)) {
                 // kind of a hack, but ObjectFactories may be created with empty
                 // namespaces
                 defaultNs = null;
@@ -533,6 +536,19 @@
         return cachedContextAndSchemas;
     }
 
+    private boolean checkObjectFactoryNamespaces(Class<?> clz) {
+        for (Method meth : clz.getMethods()) {
+            XmlElementDecl decl = meth.getAnnotation(XmlElementDecl.class);
+            if (decl != null 
+                && XmlElementDecl.GLOBAL.class.equals(decl.scope())
+                && StringUtils.isEmpty(decl.namespace())) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
     private void addToObjectFactoryCache(Package objectFactoryPkg, Class<?> ofactory)
{
         if (objectFactoryPkg == null) {
             return;



Mime
View raw message