final void addExportedProvidersFor( String symbolicName, String packageName, ArrayList result, KeyedHashSet visited) { if (!visited.add(bundle)) return; // See if we locally provide the package. PackageSource local = null; if (isExportedPackage(packageName)) local = proxy.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. if (requiredBundles != null) { int size = reexportTable == null ? 0 : reexportTable.length; int reexportIndex = 0; for (int i = 0; i < requiredBundles.length; i++) { if (local != null) { // 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. requiredBundles[i] .getBundleLoader() .addExportedProvidersFor(symbolicName, packageName, result, visited); } else if (reexportIndex < size && reexportTable[reexportIndex] == i) { reexportIndex++; requiredBundles[i] .getBundleLoader() .addExportedProvidersFor(symbolicName, packageName, result, visited); } } } // now add the locally provided package. if (local != null && local.isFriend(symbolicName)) result.add(local); }
/** * Adds a list of DynamicImport-Package manifest elements to the dynamic import tables of this * BundleLoader. Duplicate packages are checked and not added again. * * @param packages the DynamicImport-Package elements to add. */ public final synchronized void addDynamicImportPackage(ManifestElement[] packages) { if (packages == null) return; ArrayList dynamicImports = new ArrayList(packages.length); for (int i = 0; i < packages.length; i++) dynamicImports.add(packages[i].getValue()); if (dynamicImports.size() > 0) addDynamicImportPackage((String[]) dynamicImports.toArray(new String[dynamicImports.size()])); }
/** * Adds a list of DynamicImport-Package manifest elements to the dynamic import tables of this * BundleLoader. Duplicate packages are checked and not added again. This method is not thread * safe. Callers should ensure synchronization when calling this method. * * @param packages the DynamicImport-Package elements to add. */ private void addDynamicImportPackage(String[] packages) { if (packages == null) return; loaderFlags |= FLAG_HASDYNAMICIMPORTS; int size = packages.length; ArrayList stems; if (dynamicImportPackageStems == null) { stems = new ArrayList(size); } else { stems = new ArrayList(size + dynamicImportPackageStems.length); for (int i = 0; i < dynamicImportPackageStems.length; i++) { stems.add(dynamicImportPackageStems[i]); } } ArrayList names; if (dynamicImportPackages == null) { names = new ArrayList(size); } else { names = new ArrayList(size + dynamicImportPackages.length); for (int i = 0; i < dynamicImportPackages.length; i++) { names.add(dynamicImportPackages[i]); } } for (int i = 0; i < size; i++) { String name = packages[i]; if (isDynamicallyImported(name)) continue; if (name.equals("*")) { /* shortcut */ //$NON-NLS-1$ loaderFlags |= FLAG_HASDYNAMICEIMPORTALL; return; } if (name.endsWith(".*")) // $NON-NLS-1$ stems.add(name.substring(0, name.length() - 1)); else names.add(name); } size = stems.size(); if (size > 0) dynamicImportPackageStems = (String[]) stems.toArray(new String[size]); size = names.size(); if (size > 0) dynamicImportPackages = (String[]) names.toArray(new String[size]); }
private void addDynamicImportPackage(ImportPackageSpecification[] packages) { if (packages == null) return; ArrayList dynamicImports = new ArrayList(packages.length); for (int i = 0; i < packages.length; i++) if (ImportPackageSpecification.RESOLUTION_DYNAMIC.equals( packages[i].getDirective(Constants.RESOLUTION_DIRECTIVE))) dynamicImports.add(packages[i].getName()); if (dynamicImports.size() > 0) addDynamicImportPackage((String[]) dynamicImports.toArray(new String[dynamicImports.size()])); }
private static PackageSource createMultiSource(String packageName, PackageSource[] sources) { if (sources.length == 1) return sources[0]; ArrayList sourceList = new ArrayList(sources.length); for (int i = 0; i < sources.length; i++) { SingleSourcePackage[] innerSources = sources[i].getSuppliers(); for (int j = 0; j < innerSources.length; j++) if (!sourceList.contains(innerSources[j])) sourceList.add(innerSources[j]); } return new MultiSourcePackage( packageName, (SingleSourcePackage[]) sourceList.toArray(new SingleSourcePackage[sourceList.size()])); }