1 12 package org.eclipse.equinox.internal.jsp.jasper; 13 14 import java.io.IOException ; 15 import java.net.URL ; 16 import java.util.Enumeration ; 17 18 import org.osgi.framework.Bundle; 19 20 21 24 public class BundleProxyClassLoader extends ClassLoader { 25 private Bundle bundle; 26 private ClassLoader parent; 27 28 public BundleProxyClassLoader(Bundle bundle) { 29 this.bundle = bundle; 30 } 31 32 public BundleProxyClassLoader(Bundle bundle, ClassLoader parent) { 33 super(parent); 34 this.parent = parent; 35 this.bundle = bundle; 36 } 37 38 public Enumeration findResources(String name) throws IOException { 39 return bundle.getResources(name); 40 } 41 42 public URL findResource(String name) { 43 return bundle.getResource(name); 44 } 45 46 public Class findClass(String name) throws ClassNotFoundException { 47 return bundle.loadClass(name); 48 } 49 50 public URL getResource(String name) { 51 return (parent == null) ? findResource(name) : super.getResource(name); 52 } 53 54 protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { 55 Class clazz = (parent == null) ? findClass(name) : super.loadClass(name, false); 56 if (resolve) 57 super.resolveClass(clazz); 58 59 return clazz; 60 } 61 } 62 | Popular Tags |