Map<ModuleRevision, ModuleWiring> clonedWirings = new HashMap<ModuleRevision, ModuleWiring>(); for (Map.Entry<ModuleRevision, ModuleWiring> entry : wirings.entrySet()) { ModuleWiring wiring = new ModuleWiring(entry.getKey(), entry.getValue().getModuleCapabilities(null), entry.getValue().getModuleRequirements(null), entry.getValue().getProvidedModuleWires(null), entry.getValue().getRequiredModuleWires(null), entry.getValue().getSubstitutedNames()); clonedWirings.put(entry.getKey(), wiring);
@Override public List<Capability> getResourceCapabilities(String namespace) { return InternalUtils.asListCapability(getCapabilities(namespace)); }
private URL findResource(String resource) { ModuleWiring searchWiring = generation.getRevision().getWiring(); if (searchWiring != null) { if ((generation.getRevision().getTypes() & BundleRevision.TYPE_FRAGMENT) != 0) { List<ModuleWire> hostWires = searchWiring.getRequiredModuleWires(HostNamespace.HOST_NAMESPACE); searchWiring = null; Long lowestHost = Long.MAX_VALUE; if (hostWires != null) { // search for the host with the highest ID for (ModuleWire hostWire : hostWires) { Long hostID = hostWire.getProvider().getRevisions().getModule().getId(); if (hostID.compareTo(lowestHost) <= 0) { lowestHost = hostID; searchWiring = hostWire.getProviderWiring(); } } } } } if (searchWiring != null) { int lastSlash = resource.lastIndexOf('/'); String path = lastSlash > 0 ? resource.substring(0, lastSlash) : "/"; //$NON-NLS-1$ String fileName = lastSlash != -1 ? resource.substring(lastSlash + 1) : resource; List<URL> result = searchWiring.findEntries(path, fileName, 0); return (result == null || result.isEmpty()) ? null : result.get(0); } // search the raw bundle file for the generation return generation.getEntry(resource); }
private boolean isFragmentInUse() { // A fragment is considered in use if it has any required host wires if ((BundleRevision.TYPE_FRAGMENT & revision.getTypes()) != 0) { List<ModuleWire> hostWires = getRequiredModuleWires(HostNamespace.HOST_NAMESPACE); // hostWires may be null if the fragment wiring is no longer valid return hostWires == null ? false : !hostWires.isEmpty(); } return false; }
if (wiring.isDynamicPackageMiss(dynamicPkgName)) { if (dynamicReqs.isEmpty()) { wiring.addDynamicPackageMiss(dynamicPkgName); return null; if (wiring != null) { wiring.addDynamicPackageMiss(dynamicPkgName);
/** * Returns the same result as {@link #getCapabilities(String)} except * uses type ModuleCapability. * @param namespace the namespace * @return the capabilities * @see #getCapabilities(String) */ public List<ModuleCapability> getModuleCapabilities(String namespace) { return getModuleCapabilities(namespace, capabilities); }
private static BundleLoader getBundleLoader(Bundle bundle) { ModuleRevision producer = ((EquinoxBundle) bundle).getModule().getCurrentRevision(); ModuleWiring producerWiring = producer.getWiring(); return producerWiring == null ? null : (BundleLoader) producerWiring.getModuleLoader(); } }
@Override public ModuleLoader createModuleLoader(ModuleWiring wiring) { if (wiring.getBundle().getBundleId() == 0) { ClassLoader cl = EquinoxContainer.class.getClassLoader(); cl = cl == null ? BOOT_CLASSLOADER : cl; return new SystemBundleLoader(wiring, container, cl); } if ((wiring.getRevision().getTypes() & BundleRevision.TYPE_FRAGMENT) != 0) { return new FragmentLoader(); } return new BundleLoader(wiring, container, moduleClassLoaderParent); }
private BundleLoader getProviderLoader(ModuleWire wire) { ModuleWiring provider = wire.getProviderWiring(); if (provider == null) { if (firstUseOfInvalidLoader.getAndSet(true)) { // publish a framework event once per loader, include an exception to show the stack String message = "Invalid class loader from a refreshed bundle is being used: " + toString(); //$NON-NLS-1$ container.getEventPublisher().publishFrameworkEvent(FrameworkEvent.ERROR, wiring.getBundle(), new IllegalStateException(message)); } return null; } return (BundleLoader) provider.getModuleLoader(); }
private boolean hasResourcePermission() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { try { sm.checkPermission(new AdminPermission(getBundle(), AdminPermission.RESOURCE)); } catch (SecurityException e) { return false; } } return true; }
protected BundleEntry findBundleEntry(URL url, Module module) throws IOException { ModuleRevision current = module.getCurrentRevision(); ModuleWiring wiring = current == null ? null : current.getWiring(); ModuleClassLoader classloader = (ModuleClassLoader) (current == null ? null : wiring.getClassLoader()); if (classloader == null) throw new FileNotFoundException(url.getPath()); BundleEntry entry = classloader.getClasspathManager().findLocalEntry(url.getPath(), url.getPort()); if (entry == null) { // this isn't strictly needed but is kept to maintain compatibility entry = classloader.getClasspathManager().findLocalEntry(url.getPath()); } if (entry == null) { throw new FileNotFoundException(url.getPath()); } return entry; }
wiring.addDynamicImports(builder); } catch (BundleException e) { throw new RuntimeException(e);
return new ModuleWiring(revision, capabilities, requirements, providedWires, requiredWires, substituted);
private URL findResource(String resource) { ModuleWiring searchWiring = generation.getRevision().getWiring(); if (searchWiring != null) { if ((generation.getRevision().getTypes() & BundleRevision.TYPE_FRAGMENT) != 0) { List<ModuleWire> hostWires = searchWiring.getRequiredModuleWires(HostNamespace.HOST_NAMESPACE); searchWiring = null; Long lowestHost = Long.MAX_VALUE; if (hostWires != null) { // search for the host with the highest ID for (ModuleWire hostWire : hostWires) { Long hostID = hostWire.getProvider().getRevisions().getModule().getId(); if (hostID.compareTo(lowestHost) <= 0) { lowestHost = hostID; searchWiring = hostWire.getProviderWiring(); } } } } } if (searchWiring != null) { int lastSlash = resource.lastIndexOf('/'); String path = lastSlash > 0 ? resource.substring(0, lastSlash) : "/"; //$NON-NLS-1$ String fileName = lastSlash != -1 ? resource.substring(lastSlash + 1) : resource; List<URL> result = searchWiring.findEntries(path, fileName, 0); return (result == null || result.isEmpty()) ? null : result.get(0); } // search the raw bundle file for the generation return generation.getEntry(resource); }
private boolean isFragmentInUse() { // A fragment is considered in use if it has any required host wires if ((BundleRevision.TYPE_FRAGMENT & revision.getTypes()) != 0) { List<ModuleWire> hostWires = getRequiredModuleWires(HostNamespace.HOST_NAMESPACE); // hostWires may be null if the fragment wiring is no longer valid return hostWires == null ? false : !hostWires.isEmpty(); } return false; }
if (wiring.isDynamicPackageMiss(dynamicPkgName)) { if (dynamicReqs.isEmpty()) { wiring.addDynamicPackageMiss(dynamicPkgName); return null; if (wiring != null) { wiring.addDynamicPackageMiss(dynamicPkgName);
/** * Returns the same result as {@link #getCapabilities(String)} except * uses type ModuleCapability. * @param namespace the namespace * @return the capabilities * @see #getCapabilities(String) */ public List<ModuleCapability> getModuleCapabilities(String namespace) { return getModuleCapabilities(namespace, capabilities); }
private static BundleLoader getBundleLoader(Bundle bundle) { ModuleRevision producer = ((EquinoxBundle) bundle).getModule().getCurrentRevision(); ModuleWiring producerWiring = producer.getWiring(); return producerWiring == null ? null : (BundleLoader) producerWiring.getModuleLoader(); } }
@Override public ModuleLoader createModuleLoader(ModuleWiring wiring) { if (wiring.getBundle().getBundleId() == 0) { ClassLoader cl = EquinoxContainer.class.getClassLoader(); cl = cl == null ? BOOT_CLASSLOADER : cl; return new SystemBundleLoader(wiring, container, cl); } if ((wiring.getRevision().getTypes() & BundleRevision.TYPE_FRAGMENT) != 0) { return new FragmentLoader(); } return new BundleLoader(wiring, container, moduleClassLoaderParent); }