[jboss-cvs] JBossAS SVN: r57129 - branches/JBoss_4_0_4_GA_JBAS-3692/common/src/main/org/jboss/util/loading

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Sep 25 05:48:31 EDT 2006


Author: darran.lofthouse at jboss.com
Date: 2006-09-25 05:48:29 -0400 (Mon, 25 Sep 2006)
New Revision: 57129

Modified:
   branches/JBoss_4_0_4_GA_JBAS-3692/common/src/main/org/jboss/util/loading/DelegatingClassLoader.java
Log:
JBAS-3692 - If parent classloader does not return class attempt to load it with this classloader.


Modified: branches/JBoss_4_0_4_GA_JBAS-3692/common/src/main/org/jboss/util/loading/DelegatingClassLoader.java
===================================================================
--- branches/JBoss_4_0_4_GA_JBAS-3692/common/src/main/org/jboss/util/loading/DelegatingClassLoader.java	2006-09-25 08:23:37 UTC (rev 57128)
+++ branches/JBoss_4_0_4_GA_JBAS-3692/common/src/main/org/jboss/util/loading/DelegatingClassLoader.java	2006-09-25 09:48:29 UTC (rev 57129)
@@ -1,24 +1,24 @@
 /*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.jboss.util.loading;
 
 import java.net.URL;
@@ -36,11 +36,11 @@
  * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
  * @version $Revision$
  */
-public class DelegatingClassLoader
-   extends URLClassLoader
+public class DelegatingClassLoader extends URLClassLoader
 {
    /** The value returned by {@link getURLs}. */
-   public static final URL[] EMPTY_URL_ARRAY = {};
+   public static final URL[] EMPTY_URL_ARRAY =
+   {};
 
    /** Whether to use standard loading */
    protected boolean standard = false;
@@ -78,17 +78,28 @@
     * @return the loaded class
     * @throws ClassNotFoundException when the class could not be found
     */
-   protected Class loadClass(String className, boolean resolve)
-      throws ClassNotFoundException
+   protected Class loadClass(String className, boolean resolve) throws ClassNotFoundException
    {
-      // Revert to standard rules
+      //    Revert to standard rules
       if (standard)
          return super.loadClass(className, resolve);
 
-      // Ask the parent
-      Class clazz = getParent().loadClass(className);
+      //    Ask the parent
+      Class clazz = null;
+      try
+      {
+         clazz = getParent().loadClass(className);
+      }
+      catch (ClassNotFoundException e)
+      {
+         //    Not found in parent,
+         //    maybe it is a proxy registered against this classloader?
+         clazz = findLoadedClass(className);
+         if (clazz == null)
+            throw e;
+      }
 
-      // Link the class
+      //    Link the class
       if (resolve)
          resolveClass(clazz);
 




More information about the jboss-cvs-commits mailing list