1 21 24 package org.lobobrowser.util; 25 26 import java.util.*; 27 30 public abstract class MultiplexClassLoader extends BaseClassLoader { 31 private static final BaseClassLoader[] EMPTY_CLASS_LOADERS = new BaseClassLoader[0]; 32 private final BaseClassLoader[] parentLoaders; 33 36 public MultiplexClassLoader(Collection classLoaders) { 37 super(null); 38 this.parentLoaders = (BaseClassLoader[]) classLoaders.toArray(EMPTY_CLASS_LOADERS); 39 } 40 41 44 public synchronized Class loadClass(String name, boolean resolve) 45 throws ClassNotFoundException { 46 Class c = findLoadedClass(name); 48 if (c == null) { 49 try { 50 int len = this.parentLoaders.length; 51 if(len == 0) { 52 c = findSystemClass(name); 53 } 54 else { 55 for(int i = 0; i < len; i++) { 56 BaseClassLoader parent = this.parentLoaders[i]; 57 try { 58 c = parent.loadClass(name, false); 59 if(c != null) { 60 return c; 61 } 62 } catch(ClassNotFoundException cnfe) { 63 } 65 } 66 } 67 } catch (ClassNotFoundException e) { 68 c = findClass(name); 71 } 72 if(c == null) { 73 c = findClass(name); 74 } 75 } 76 if (resolve) { 77 resolveClass(c); 78 } 79 return c; 80 } 81 } 82 | Popular Tags |