1 11 package org.eclipse.osgi.framework.internal.core; 12 13 import java.io.IOException ; 14 import java.net.URL ; 15 import java.util.*; 16 17 import org.eclipse.osgi.service.resolver.BundleDescription; 18 import org.eclipse.osgi.util.ManifestElement; 19 import org.osgi.framework.BundleException; 20 21 26 public class RegisteredPolicy extends DependentPolicy { 27 28 public RegisteredPolicy(BundleLoader requester) { 29 super(requester); 30 31 if (allDependents == null) 33 return; 34 35 for (Iterator iter = allDependents.iterator(); iter.hasNext();) { 36 BundleLoaderProxy proxy = buddyRequester.getLoaderProxy((BundleDescription) iter.next()); 37 if (proxy == null) 38 iter.remove(); 39 40 try { 41 String [] allContributions = ManifestElement.getArrayFromList((String ) ((AbstractBundle) proxy.getBundle()).getBundleData().getManifest().get(Constants.REGISTERED_POLICY)); 42 if (allContributions == null) { 43 iter.remove(); 44 continue; 45 } 46 boolean contributes = false; 47 for (int j = 0; j < allContributions.length && contributes == false; j++) { 48 if (allContributions[j].equals(buddyRequester.bundle.getSymbolicName())) 49 contributes = true; 50 } 51 if (!contributes) 52 iter.remove(); 53 54 } catch (BundleException e) { 55 iter.remove(); 56 } 57 } 58 59 if (allDependents.size() == 0) 61 allDependents = null; 62 } 63 64 public Class loadClass(String name) { 65 if (allDependents == null) 66 return null; 67 68 Class result = null; 69 int size = allDependents.size(); 70 for (int i = 0; i < size && result == null; i++) { 71 try { 72 BundleLoaderProxy proxy = buddyRequester.getLoaderProxy((BundleDescription) allDependents.get(i)); 73 if (proxy == null) 74 continue; 75 result = proxy.getBundleLoader().findClass(name, true); 76 } catch (ClassNotFoundException e) { 77 continue; 79 } 80 } 81 return result; 82 } 83 84 public URL loadResource(String name) { 85 if (allDependents == null) 86 return null; 87 88 URL result = null; 89 int size = allDependents.size(); 90 for (int i = 0; i < size && result == null; i++) { 91 BundleLoaderProxy proxy = buddyRequester.getLoaderProxy((BundleDescription) allDependents.get(i)); 92 if (proxy == null) 93 continue; 94 result = proxy.getBundleLoader().findResource(name, true); 95 } 96 return result; 97 } 98 99 public Enumeration loadResources(String name) { 100 if (allDependents == null) 101 return null; 102 103 Enumeration results = null; 104 int size = allDependents.size(); 105 for (int i = 0; i < size; i++) { 106 try { 107 BundleLoaderProxy proxy = buddyRequester.getLoaderProxy((BundleDescription) allDependents.get(i)); 108 if (proxy == null) 109 continue; 110 results = BundleLoader.compoundEnumerations(results, proxy.getBundleLoader().findResources(name)); 111 } catch (IOException e) { 112 } 114 } 115 return results; 116 } 117 } 118 | Popular Tags |