1 11 12 package org.eclipse.osgi.framework.internal.core; 13 14 import java.io.IOException ; 15 import java.net.URL ; 16 import java.util.*; 17 import org.eclipse.osgi.service.resolver.ExportPackageDescription; 18 import org.osgi.framework.BundleException; 19 20 24 public class SystemBundleLoader extends BundleLoader { 25 public static final String EQUINOX_EE = "x-equinox-ee"; ClassLoader classLoader; 27 private HashSet eePackages; 28 29 34 protected SystemBundleLoader(BundleHost bundle, BundleLoaderProxy proxy) throws BundleException { 35 super(bundle, proxy); 36 ExportPackageDescription[] exports = proxy.getBundleDescription().getSelectedExports(); 37 if (exports != null && exports.length > 0) { 38 eePackages = new HashSet(exports.length); 39 for (int i = 0; i < exports.length; i++) 40 if (((Integer ) exports[i].getDirective(EQUINOX_EE)).intValue() >= 0) 41 eePackages.add(exports[i].getName()); 42 } 43 this.classLoader = getClass().getClassLoader(); 44 } 45 46 49 public Class findClass(String name) throws ClassNotFoundException { 50 return classLoader.loadClass(name); 51 } 52 53 56 public String findLibrary(String name) { 57 return null; 58 } 59 60 63 Class findLocalClass(String name) { 64 Class clazz = null; 65 try { 66 clazz = classLoader.loadClass(name); 67 } catch (ClassNotFoundException e) { 68 } 70 return clazz; 71 } 72 73 76 URL findLocalResource(String name) { 77 return classLoader.getResource(name); 78 } 79 80 83 Enumeration findLocalResources(String name) { 84 try { 85 return classLoader.getResources(name); 86 } catch (IOException e) { 87 return null; 88 } 89 } 90 91 94 public URL findResource(String name) { 95 return classLoader.getResource(name); 96 } 97 98 101 public Enumeration findResources(String name) throws IOException { 102 return classLoader.getResources(name); 103 } 104 105 108 protected void close() { 109 } 111 112 public boolean isEEPackage(String pkgName) { 113 return eePackages.contains(pkgName); 114 } 115 } 116 | Popular Tags |