cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r604316 - in /incubator/cxf/branches/2.0.x-fixes: ./ rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
Date Fri, 14 Dec 2007 22:25:37 GMT
Author: dkulp
Date: Fri Dec 14 14:25:34 2007
New Revision: 604316

URL: http://svn.apache.org/viewvc?rev=604316&view=rev
Log:
Merged revisions 604312 via svnmerge from 
https://svn.apache.org/repos/asf/incubator/cxf/trunk

........
  r604312 | dkulp | 2007-12-14 17:11:42 -0500 (Fri, 14 Dec 2007) | 2 lines
  
  [CXF-1278] Move the checks for ObjectFactory objects from the ContextInitializer to the
same place the checks for jaxb.index is done
........

Modified:
    incubator/cxf/branches/2.0.x-fixes/   (props changed)
    incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
    incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java

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

Modified: incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java?rev=604316&r1=604315&r2=604316&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
Fri Dec 14 14:25:34 2007
@@ -28,7 +28,6 @@
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.util.Collection;
-import java.util.HashSet;
 import java.util.Set;
 
 import javax.xml.bind.annotation.XmlAccessType;
@@ -36,7 +35,6 @@
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlTransient;
 
-import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.service.ServiceModelVisitor;
 import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.service.model.ServiceInfo;
@@ -47,12 +45,10 @@
 class JAXBContextInitializer extends ServiceModelVisitor {
 
     private Set<Class<?>> classes;
-    private Set<String> packages;
 
     public JAXBContextInitializer(ServiceInfo serviceInfo, Set<Class<?>> classes)
{
         super(serviceInfo);
         this.classes = classes;
-        this.packages = new HashSet<String>();
     }
 
     @Override
@@ -167,20 +163,6 @@
                 }
                 classes.add(cls);
                 walkReferences(cls);
-
-                String pname = PackageUtils.getPackageName(cls);
-                if (!packages.contains(pname)) {
-                    packages.add(pname);
-                    String name = pname + ".ObjectFactory";
-                    try {
-                        Class ocls = Class.forName(name, false, cls.getClassLoader());
-                        if (!classes.contains(ocls)) {
-                            classes.add(ocls);
-                        }
-                    } catch (ClassNotFoundException ex) {
-                        // cannot add factory, just add the class
-                    }
-                }
             }
         }
     }

Modified: incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java?rev=604316&r1=604315&r2=604316&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
Fri Dec 14 14:25:34 2007
@@ -335,32 +335,24 @@
             }
         }
         
-        for (Class<?> clz : classes) {
-            if (clz.getName().endsWith("ObjectFactory")) {
-                //kind of a hack, but ObjectFactories may be created with empty namespaces
-                defaultNs = null;
-            }
-        }
-        
-        Map<String, Object> map = new HashMap<String, Object>();
-        if (defaultNs != null) {
-            map.put("com.sun.xml.bind.defaultNamespaceRemap", defaultNs);
-        }
-        
-        if (contextProperties != null) {
-            //add any specified context properties into the properties map
-            map.putAll(contextProperties);
-        }
-        
         //try and read any jaxb.index files that are with the other classes.  This should

         //allow loading of extra classes (such as subclasses for inheritance reasons) 
-        //that are in the same package.
+        //that are in the same package.  Also check for ObjectFactory classes
         Map<String, InputStream> packages = new HashMap<String, InputStream>();
         Map<String, ClassLoader> packageLoaders = new HashMap<String, ClassLoader>();
+        Set<Class<?>> objectFactories = new HashSet<Class<?>>();
         for (Class<?> jcls : classes) {
-            if (!packages.containsKey(PackageUtils.getPackageName(jcls))) {
-                packages.put(PackageUtils.getPackageName(jcls), jcls.getResourceAsStream("jaxb.index"));
-                packageLoaders.put(PackageUtils.getPackageName(jcls), jcls.getClassLoader());
+            String pkgName = PackageUtils.getPackageName(jcls); 
+            if (!packages.containsKey(pkgName)) {
+                packages.put(pkgName, jcls.getResourceAsStream("jaxb.index"));
+                packageLoaders.put(pkgName, jcls.getClassLoader());
+                try {
+                    Class<?> ofactory = Class.forName(pkgName + "." + "ObjectFactory",
+                                                 false, jcls.getClassLoader());
+                    objectFactories.add(ofactory);
+                } catch (ClassNotFoundException e) {
+                    //ignore
+                }
             }
         }
         for (Map.Entry<String, InputStream> entry : packages.entrySet()) {
@@ -401,9 +393,26 @@
                 }
             }
         }
-        
+        classes.addAll(objectFactories);
         addWsAddressingTypes(classes);
 
+        for (Class<?> clz : classes) {
+            if (clz.getName().endsWith("ObjectFactory")) {
+                //kind of a hack, but ObjectFactories may be created with empty namespaces
+                defaultNs = null;
+            }
+        }
+        
+        Map<String, Object> map = new HashMap<String, Object>();
+        if (defaultNs != null) {
+            map.put("com.sun.xml.bind.defaultNamespaceRemap", defaultNs);
+        }
+        
+        if (contextProperties != null) {
+            //add any specified context properties into the properties map
+            map.putAll(contextProperties);
+        }        
+        
         synchronized (JAXBCONTEXT_CACHE) {
             if (!JAXBCONTEXT_CACHE.containsKey(classes)) {
                 JAXBContext ctx = JAXBContext.newInstance(classes.toArray(new Class[classes.size()]),
map);



Mime
View raw message