Commit in servicemix/base/src on MAIN
main/java/org/servicemix/jbi/framework/InstallationClassLoader.java+1-81.5 -> 1.6
                                      /ParentFirstClassLoader.java+10-101.3 -> 1.4
test/java/org/servicemix/jbi/framework/ClassLoaderTest.java+46added 1.1
+57-18
1 added + 2 modified, total 3 files
Fix SM-48 : ParentFirst and SelfFirst jbi class loaders behave the same way

servicemix/base/src/main/java/org/servicemix/jbi/framework
InstallationClassLoader.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- InstallationClassLoader.java	28 Jul 2005 08:06:20 -0000	1.5
+++ InstallationClassLoader.java	20 Sep 2005 10:06:00 -0000	1.6
@@ -27,7 +27,7 @@
 /**
  * Base class for the custom class loaders
  * 
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
  */
 public abstract class InstallationClassLoader extends URLClassLoader {
     /**
@@ -83,13 +83,6 @@
             }
             catch (ClassNotFoundException cnfe) {
             }
-        }
-        if (result == null && parentLoader != null){
-            try {
-            result = parentLoader.loadClass(name);
-            }catch(ClassNotFoundException e){
-            }
-            
         }
         if (result == null) {
             result = super.findClass(name);

servicemix/base/src/main/java/org/servicemix/jbi/framework
ParentFirstClassLoader.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- ParentFirstClassLoader.java	18 Jul 2005 09:51:59 -0000	1.3
+++ ParentFirstClassLoader.java	20 Sep 2005 10:06:00 -0000	1.4
@@ -27,7 +27,7 @@
 /**
  * Loadsfrom parent class loader first
  * 
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
  */
 public class ParentFirstClassLoader extends InstallationClassLoader {
     private static final Log log = LogFactory.getLog(ParentFirstClassLoader.class);
@@ -62,18 +62,18 @@
         catch (ClassNotFoundException e) {
         }
         if (result == null) {
-            try {
-                result = findClass(name);
-                if (result != null && resolve) {
-                    resolveClass(result);
-                }
-            }
-            catch (ClassNotFoundException e) {
-            }
+        	try {
+        		result = parentLoader.loadClass(name);
+        		if (result != null && resolve) {
+        			resolveClass(result);
+        		}
+        	}
+        	catch (ClassNotFoundException e) {
+        	}
         }
         if (result == null) {
             try {
-                result = parentLoader.loadClass(name);
+                result = findClass(name);
                 if (result != null && resolve) {
                     resolveClass(result);
                 }

servicemix/base/src/test/java/org/servicemix/jbi/framework
ClassLoaderTest.java added at 1.1
diff -N ClassLoaderTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ClassLoaderTest.java	20 Sep 2005 10:06:00 -0000	1.1
@@ -0,0 +1,46 @@
+/** 
+ * 
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); 
+ * you may not use this file except in compliance with the License. 
+ * You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ * 
+ **/
+package org.servicemix.jbi.framework;
+
+import java.net.URLClassLoader;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class ClassLoaderTest extends TestCase {
+
+	public static class TestClass {
+	}
+	
+	public void testParentFirstClassLoader() throws Exception {
+		URLClassLoader pcl = (URLClassLoader) getClass().getClassLoader();
+		ClassLoader clsLoader = new ParentFirstClassLoader(pcl.getURLs(), pcl);
+		Class  clazz = clsLoader.loadClass(TestClass.class.getName());
+		assertSame(TestClass.class, clazz);
+	}
+	
+	public void testSelfFirstClassLoader() throws Exception {
+		URLClassLoader pcl = (URLClassLoader) getClass().getClassLoader();
+		ClassLoader clsLoader = new SelfFirstClassLoader(pcl.getURLs(), pcl);
+		Class  clazz = clsLoader.loadClass(TestClass.class.getName());
+		assertNotSame(TestClass.class, clazz);
+	}
+	
+}
CVSspam 0.2.8



Reply via email to