cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1524411 - in /cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/common/util: ProxyClassLoader.java ProxyHelper.java
Date Wed, 18 Sep 2013 13:46:34 GMT
Author: dkulp
Date: Wed Sep 18 13:46:33 2013
New Revision: 1524411

URL: http://svn.apache.org/r1524411
Log:
Make sure we return the EXACT class object for the names classes, check system classloader
AFTER all the others.

Modified:
    cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/common/util/ProxyClassLoader.java
    cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/common/util/ProxyHelper.java

Modified: cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/common/util/ProxyClassLoader.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/common/util/ProxyClassLoader.java?rev=1524411&r1=1524410&r2=1524411&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/common/util/ProxyClassLoader.java
(original)
+++ cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/common/util/ProxyClassLoader.java
Wed Sep 18 13:46:33 2013
@@ -28,16 +28,33 @@ import java.util.Set;
  * service class.    
  */
 public class ProxyClassLoader extends ClassLoader {
-    private Set<ClassLoader> loaders = new HashSet<ClassLoader>();
+    private final Class<?> classes[];
+    private final Set<ClassLoader> loaders = new HashSet<ClassLoader>();
+    private boolean checkSystem;
+
+    public ProxyClassLoader() {
+        classes = null;
+    }
+    public ProxyClassLoader(Class<?>[] cls) {
+        classes = cls;
+    }
 
     public void addLoader(ClassLoader loader) {
         if (loader == null) {
-            loader = getSystemClassLoader();
+            checkSystem = true;
+        } else {
+            loaders.add(loader);
         }
-        loaders.add(loader);
     }
 
     public Class<?> findClass(String name) throws ClassNotFoundException {
+        if (classes != null) {
+            for (Class<?> c : classes) {
+                if (name.equals(c.getName())) {
+                    return c;
+                }
+            }
+        }
         for (ClassLoader loader : loaders) {
             try {
                 return loader.loadClass(name);
@@ -47,6 +64,15 @@ public class ProxyClassLoader extends Cl
                 // Try next
             }
         }
+        if (checkSystem) {
+            try {
+                return getSystemClassLoader().loadClass(name);
+            } catch (ClassNotFoundException cnfe) {
+                // Try next
+            } catch (NoClassDefFoundError cnfe) {
+                // Try next
+            }
+        }
         throw new ClassNotFoundException(name);
     }
     

Modified: cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/common/util/ProxyHelper.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/common/util/ProxyHelper.java?rev=1524411&r1=1524410&r2=1524411&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/common/util/ProxyHelper.java
(original)
+++ cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/common/util/ProxyHelper.java
Wed Sep 18 13:46:33 2013
@@ -58,7 +58,7 @@ public class ProxyHelper {
         if (canSeeAllInterfaces(loader, interfaces)) {
             return loader;
         }
-        ProxyClassLoader combined = new ProxyClassLoader();
+        ProxyClassLoader combined = new ProxyClassLoader(interfaces);
         for (Class<?> currentInterface : interfaces) {
             combined.addLoader(currentInterface.getClassLoader());
         }



Mime
View raw message