1 11 package org.eclipse.tomcat.internal; 12 13 import java.net.*; 14 15 import org.eclipse.help.internal.appserver.*; 16 17 21 public class WebAppClassLoader extends URLClassLoader { 22 private ClassLoader pluginLoader; 23 private PluginClassLoaderWrapper tomcatPluginLoader; 24 25 public WebAppClassLoader(ClassLoader pluginLoader) { 26 super(new URL[0]); 27 this.pluginLoader = pluginLoader; 28 this.tomcatPluginLoader = new PluginClassLoaderWrapper( 29 TomcatPlugin.PLUGIN_ID); 30 } 31 32 public Class loadClass(String className) throws ClassNotFoundException { 33 Class c = null; 35 try { 36 c = tomcatPluginLoader.loadClass(className); 37 } catch (ClassNotFoundException e) { 38 c = pluginLoader.loadClass(className); 39 } finally { 40 } 41 return c; 42 } 43 44 public URL getResource(String resName) { 45 URL u = pluginLoader.getResource(resName); 47 if (u == null) 48 return tomcatPluginLoader.getResource(resName); 49 return u; 50 } 51 52 57 public URL[] getURLs() { 58 URL[] pluginLoaderURLs; 59 if (pluginLoader instanceof URLClassLoader) 60 pluginLoaderURLs = ((URLClassLoader) pluginLoader).getURLs(); 61 else 62 pluginLoaderURLs = new URL[0]; 63 64 URL[] tomcatPluginLoaderURLs = tomcatPluginLoader.getURLs(); 65 66 URL[] urls = new URL[pluginLoaderURLs.length 67 + tomcatPluginLoaderURLs.length]; 68 69 System.arraycopy(pluginLoaderURLs, 0, urls, 0, pluginLoaderURLs.length); 70 System.arraycopy(tomcatPluginLoaderURLs, 0, urls, 71 pluginLoaderURLs.length, tomcatPluginLoaderURLs.length); 72 return urls; 73 } 74 } 75 | Popular Tags |