1 11 12 package org.eclipse.osgi.framework.internal.protocol.bundleresource; 13 14 import java.io.FileNotFoundException ; 15 import java.io.IOException ; 16 import java.net.URL ; 17 import java.util.Enumeration ; 18 import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry; 19 import org.eclipse.osgi.baseadaptor.loader.BaseClassLoader; 20 import org.eclipse.osgi.baseadaptor.loader.ClasspathManager; 21 import org.eclipse.osgi.framework.internal.core.AbstractBundle; 22 import org.eclipse.osgi.framework.internal.core.BundleResourceHandler; 23 24 27 28 public class Handler extends BundleResourceHandler { 29 30 33 public Handler() { 34 super(); 35 } 36 37 public Handler(BundleEntry bundleEntry) { 38 super(bundleEntry); 39 } 40 41 protected BundleEntry findBundleEntry(URL url, AbstractBundle bundle) throws IOException { 42 BaseClassLoader classloader = getBundleClassLoader(bundle); 43 if (classloader == null) 44 throw new FileNotFoundException (url.getPath()); 45 ClasspathManager cpManager = classloader.getClasspathManager(); 46 int index = url.getPort(); 47 BundleEntry entry = null; 48 if (index == 0) { 49 entry = cpManager.findLocalEntry(url.getPath()); 50 } else { 51 Enumeration entries = cpManager.findLocalEntries(url.getPath()); 52 if (entries != null) 53 for (int i = 0; entries.hasMoreElements() && i <= index; i++) 54 entry = (BundleEntry) entries.nextElement(); 55 } 56 if (entry == null) 57 throw new FileNotFoundException (url.getPath()); 58 return entry; 59 } 60 61 } 62 | Popular Tags |