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(); }
final void addProvidedPackageNames(String packageName, List<String> result, boolean subPackages, Collection<BundleLoader> visited) { if (visited.contains(this)) return; visited.add(this); for (String exported : exportedPackages) { if (exported.equals(packageName) || (subPackages && isSubPackage(packageName, exported))) { if (!result.contains(exported)) result.add(exported); } } for (String substituted : wiring.getSubstitutedNames()) { if (substituted.equals(packageName) || (subPackages && isSubPackage(packageName, substituted))) { if (!result.contains(substituted)) result.add(substituted); } } for (ModuleWire bundleWire : requiredBundleWires) { if (BundleNamespace.VISIBILITY_REEXPORT.equals(bundleWire.getRequirement().getDirectives().get(BundleNamespace.REQUIREMENT_VISIBILITY_DIRECTIVE))) { BundleLoader loader = (BundleLoader) bundleWire.getProviderWiring().getModuleLoader(); if (loader != null) { loader.addProvidedPackageNames(packageName, result, subPackages, visited); } } } }
final void addProvidedPackageNames(String packageName, List<String> result, boolean subPackages, Collection<BundleLoader> visited) { if (visited.contains(this)) return; visited.add(this); for (String exported : exportedPackages) { if (exported.equals(packageName) || (subPackages && isSubPackage(packageName, exported))) { if (!result.contains(exported)) result.add(exported); } } for (String substituted : wiring.getSubstitutedNames()) { if (substituted.equals(packageName) || (subPackages && isSubPackage(packageName, substituted))) { if (!result.contains(substituted)) result.add(substituted); } } for (ModuleWire bundleWire : requiredBundleWires) { if (BundleNamespace.VISIBILITY_REEXPORT.equals(bundleWire.getRequirement().getDirectives().get(BundleNamespace.REQUIREMENT_VISIBILITY_DIRECTIVE))) { BundleLoader loader = (BundleLoader) bundleWire.getProviderWiring().getModuleLoader(); if (loader != null) { loader.addProvidedPackageNames(packageName, result, subPackages, visited); } } } }
final void addProvidedPackageNames(String packageName, List<String> result, boolean subPackages, Collection<BundleLoader> visited) { if (visited.contains(this)) return; visited.add(this); for (String exported : exportedPackages) { if (exported.equals(packageName) || (subPackages && isSubPackage(packageName, exported))) { if (!result.contains(exported)) result.add(exported); } } for (String substituted : wiring.getSubstitutedNames()) { if (substituted.equals(packageName) || (subPackages && isSubPackage(packageName, substituted))) { if (!result.contains(substituted)) result.add(substituted); } } for (ModuleWire bundleWire : requiredBundleWires) { if (BundleNamespace.VISIBILITY_REEXPORT.equals(bundleWire.getRequirement().getDirectives().get(BundleNamespace.REQUIREMENT_VISIBILITY_DIRECTIVE))) { BundleLoader loader = (BundleLoader) bundleWire.getProviderWiring().getModuleLoader(); if (loader != null) { loader.addProvidedPackageNames(packageName, result, subPackages, visited); } } } }
final void addProvidedPackageNames(String packageName, List<String> result, boolean subPackages, Collection<BundleLoader> visited) { if (visited.contains(this)) return; visited.add(this); for (String exported : exportedPackages) { if (exported.equals(packageName) || (subPackages && isSubPackage(packageName, exported))) { if (!result.contains(exported)) result.add(exported); } } for (String substituted : wiring.getSubstitutedNames()) { if (substituted.equals(packageName) || (subPackages && isSubPackage(packageName, substituted))) { if (!result.contains(substituted)) result.add(substituted); } } for (ModuleWire bundleWire : requiredBundleWires) { if (BundleNamespace.VISIBILITY_REEXPORT.equals(bundleWire.getRequirement().getDirectives().get(BundleNamespace.REQUIREMENT_VISIBILITY_DIRECTIVE))) { BundleLoader loader = (BundleLoader) bundleWire.getProviderWiring().getModuleLoader(); if (loader != null) { loader.addProvidedPackageNames(packageName, result, subPackages, visited); } } } }
final void addProvidedPackageNames(String packageName, List<String> result, boolean subPackages, Collection<BundleLoader> visited) { if (visited.contains(this)) return; visited.add(this); synchronized (exportedPackages) { for (String exported : exportedPackages) { if (exported.equals(packageName) || (subPackages && isSubPackage(packageName, exported))) { if (!result.contains(exported)) result.add(exported); } } } for (String substituted : wiring.getSubstitutedNames()) { if (substituted.equals(packageName) || (subPackages && isSubPackage(packageName, substituted))) { if (!result.contains(substituted)) result.add(substituted); } } for (ModuleWire bundleWire : requiredBundleWires) { if (BundleNamespace.VISIBILITY_REEXPORT.equals(bundleWire.getRequirement().getDirectives().get(BundleNamespace.REQUIREMENT_VISIBILITY_DIRECTIVE))) { BundleLoader loader = (BundleLoader) bundleWire.getProviderWiring().getModuleLoader(); if (loader != null) { loader.addProvidedPackageNames(packageName, result, subPackages, visited); } } } }
final void addExportedProvidersFor(String packageName, List<PackageSource> result, Collection<BundleLoader> visited) { if (visited.contains(this)) return; visited.add(this); // See if we locally provide the package. PackageSource local = null; if (isExportedPackage(packageName)) local = exportSources.getPackageSource(packageName); else if (isSubstitutedExport(packageName)) { result.add(findImportedSource(packageName, visited)); return; // should not continue to required bundles in this case } // Must search required bundles that are exported first. for (ModuleWire bundleWire : requiredBundleWires) { if (local != null || BundleNamespace.VISIBILITY_REEXPORT.equals(bundleWire.getRequirement().getDirectives().get(BundleNamespace.REQUIREMENT_VISIBILITY_DIRECTIVE))) { // always add required bundles first if we locally provide the package // This allows a bundle to provide a package from a required bundle without // re-exporting the whole required bundle. BundleLoader loader = (BundleLoader) bundleWire.getProviderWiring().getModuleLoader(); if (loader != null) { loader.addExportedProvidersFor(packageName, result, visited); } } } // now add the locally provided package. if (local != null) result.add(local); }
final void addExportedProvidersFor(String packageName, List<PackageSource> result, Collection<BundleLoader> visited) { if (visited.contains(this)) return; visited.add(this); // See if we locally provide the package. PackageSource local = null; if (isExportedPackage(packageName)) local = exportSources.getPackageSource(packageName); else if (isSubstitutedExport(packageName)) { result.add(findImportedSource(packageName, visited)); return; // should not continue to required bundles in this case } // Must search required bundles that are exported first. for (ModuleWire bundleWire : requiredBundleWires) { if (local != null || BundleNamespace.VISIBILITY_REEXPORT.equals(bundleWire.getRequirement().getDirectives().get(BundleNamespace.REQUIREMENT_VISIBILITY_DIRECTIVE))) { // always add required bundles first if we locally provide the package // This allows a bundle to provide a package from a required bundle without // re-exporting the whole required bundle. BundleLoader loader = (BundleLoader) bundleWire.getProviderWiring().getModuleLoader(); if (loader != null) { loader.addExportedProvidersFor(packageName, result, visited); } } } // now add the locally provided package. if (local != null) result.add(local); }
final void addExportedProvidersFor(String packageName, List<PackageSource> result, Collection<BundleLoader> visited) { if (visited.contains(this)) return; visited.add(this); // See if we locally provide the package. PackageSource local = null; if (isExportedPackage(packageName)) local = exportSources.getPackageSource(packageName); else if (isSubstitutedExport(packageName)) { result.add(findImportedSource(packageName, visited)); return; // should not continue to required bundles in this case } // Must search required bundles that are exported first. for (ModuleWire bundleWire : requiredBundleWires) { if (local != null || BundleNamespace.VISIBILITY_REEXPORT.equals(bundleWire.getRequirement().getDirectives().get(BundleNamespace.REQUIREMENT_VISIBILITY_DIRECTIVE))) { // always add required bundles first if we locally provide the package // This allows a bundle to provide a package from a required bundle without // re-exporting the whole required bundle. BundleLoader loader = (BundleLoader) bundleWire.getProviderWiring().getModuleLoader(); if (loader != null) { loader.addExportedProvidersFor(packageName, result, visited); } } } // now add the locally provided package. if (local != null) result.add(local); }
final void addExportedProvidersFor(String packageName, List<PackageSource> result, Collection<BundleLoader> visited) { if (visited.contains(this)) return; visited.add(this); // See if we locally provide the package. PackageSource local = null; if (isExportedPackage(packageName)) local = exportSources.getPackageSource(packageName); else if (isSubstitutedExport(packageName)) { result.add(findImportedSource(packageName, visited)); return; // should not continue to required bundles in this case } // Must search required bundles that are exported first. for (ModuleWire bundleWire : requiredBundleWires) { if (local != null || BundleNamespace.VISIBILITY_REEXPORT.equals(bundleWire.getRequirement().getDirectives().get(BundleNamespace.REQUIREMENT_VISIBILITY_DIRECTIVE))) { // always add required bundles first if we locally provide the package // This allows a bundle to provide a package from a required bundle without // re-exporting the whole required bundle. BundleLoader loader = (BundleLoader) bundleWire.getProviderWiring().getModuleLoader(); if (loader != null) { loader.addExportedProvidersFor(packageName, result, visited); } } } // now add the locally provided package. if (local != null) result.add(local); }
final void addExportedProvidersFor(String packageName, List<PackageSource> result, Collection<BundleLoader> visited) { if (visited.contains(this)) return; visited.add(this); // See if we locally provide the package. PackageSource local = null; if (isExportedPackage(packageName)) local = exportSources.getPackageSource(packageName); else if (isSubstitutedExport(packageName)) { result.add(findImportedSource(packageName, visited)); return; // should not continue to required bundles in this case } // Must search required bundles that are exported first. for (ModuleWire bundleWire : requiredBundleWires) { if (local != null || BundleNamespace.VISIBILITY_REEXPORT.equals(bundleWire.getRequirement().getDirectives().get(BundleNamespace.REQUIREMENT_VISIBILITY_DIRECTIVE))) { // always add required bundles first if we locally provide the package // This allows a bundle to provide a package from a required bundle without // re-exporting the whole required bundle. BundleLoader loader = (BundleLoader) bundleWire.getProviderWiring().getModuleLoader(); if (loader != null) { loader.addExportedProvidersFor(packageName, result, visited); } } } // now add the locally provided package. if (local != null) result.add(local); }
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 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 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 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); }
final PackageSource createExportPackageSource(ModuleWire importWire, Collection<BundleLoader> visited) { String name = (String) importWire.getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE); BundleLoader providerLoader = (BundleLoader) importWire.getProviderWiring().getModuleLoader(); if (providerLoader == null) { return createMultiSource(name, new PackageSource[0]); } PackageSource requiredSource = providerLoader.findRequiredSource(name, visited); PackageSource exportSource = providerLoader.exportSources.createPackageSource(importWire.getCapability(), false); if (requiredSource == null) return exportSource; return createMultiSource(name, new PackageSource[] {requiredSource, exportSource}); }
final PackageSource createExportPackageSource(ModuleWire importWire, Collection<BundleLoader> visited) { String name = (String) importWire.getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE); BundleLoader providerLoader = (BundleLoader) importWire.getProviderWiring().getModuleLoader(); if (providerLoader == null) { return createMultiSource(name, new PackageSource[0]); } PackageSource requiredSource = providerLoader.findRequiredSource(name, visited); PackageSource exportSource = providerLoader.exportSources.createPackageSource(importWire.getCapability(), false); if (requiredSource == null) return exportSource; return createMultiSource(name, new PackageSource[] {requiredSource, exportSource}); }
final PackageSource createExportPackageSource(ModuleWire importWire, Collection<BundleLoader> visited) { String name = (String) importWire.getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE); BundleLoader providerLoader = (BundleLoader) importWire.getProviderWiring().getModuleLoader(); if (providerLoader == null) { return createMultiSource(name, new PackageSource[0]); } PackageSource requiredSource = providerLoader.findRequiredSource(name, visited); PackageSource exportSource = providerLoader.exportSources.createPackageSource(importWire.getCapability(), false); if (requiredSource == null) return exportSource; return createMultiSource(name, new PackageSource[] {requiredSource, exportSource}); }
final PackageSource createExportPackageSource(ModuleWire importWire, Collection<BundleLoader> visited) { String name = (String) importWire.getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE); BundleLoader providerLoader = (BundleLoader) importWire.getProviderWiring().getModuleLoader(); if (providerLoader == null) { return createMultiSource(name, new PackageSource[0]); } PackageSource requiredSource = providerLoader.findRequiredSource(name, visited); PackageSource exportSource = providerLoader.exportSources.createPackageSource(importWire.getCapability(), false); if (requiredSource == null) return exportSource; return createMultiSource(name, new PackageSource[] {requiredSource, exportSource}); }
final PackageSource createExportPackageSource(ModuleWire importWire, Collection<BundleLoader> visited) { String name = (String) importWire.getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE); BundleLoader providerLoader = (BundleLoader) importWire.getProviderWiring().getModuleLoader(); if (providerLoader == null) { return createMultiSource(name, new PackageSource[0]); } PackageSource requiredSource = providerLoader.findRequiredSource(name, visited); PackageSource exportSource = providerLoader.exportSources.createPackageSource(importWire.getCapability(), false); if (requiredSource == null) return exportSource; return createMultiSource(name, new PackageSource[] {requiredSource, exportSource}); }