static public void closeBundleLoader(BundleLoaderProxy proxy) { if (proxy == null) return; // First close the BundleLoader BundleLoader loader = proxy.getBasicBundleLoader(); if (loader != null) loader.close(); proxy.setStale(); // if proxy is not null then make sure to unset user object // associated with the proxy in the state BundleDescription description = proxy.getBundleDescription(); // must set it back to the bundle object; not null // need to make sure the user object is a BundleReference description.setUserObject(proxy.getBundleData()); } }
public synchronized BundleLoaderProxy getLoaderProxy() { if (proxy != null) return proxy; BundleDescription bundleDescription = getBundleDescription(); if (bundleDescription == null) return null; proxy = new BundleLoaderProxy(this, bundleDescription); // Note that BundleLoaderProxy is a BundleReference // this is necessary to ensure the resolver can continue // to provide BundleRevision objects to resolver hooks. bundleDescription.setUserObject(proxy); return proxy; }
public Bundle[] getRequiringBundles() { if (isStale()) return null; // This is VERY slow; but never gets called in regular execution. BundleDescription[] dependents = description.getDependents(); if (dependents == null || dependents.length == 0) return new Bundle[0]; List<Bundle> result = new ArrayList<Bundle>(dependents.length); for (int i = 0; i < dependents.length; i++) addRequirers(dependents[i], result); return result.toArray(new org.osgi.framework.Bundle[result.size()]); }
public org.osgi.framework.Bundle getExportingBundle() { if (supplier.isStale()) return null; return supplier.getBundleHost(); }
public Class<?> loadClass(String name) throws ClassNotFoundException { return supplier.getBundleLoader().findLocalClass(name); }
private void checkClassLoader() { BundleLoaderProxy proxy = getLoaderProxy(); if (proxy != null && proxy.inUse() && proxy.getBundleLoader() != null) { BundleClassLoader loader = proxy.getBundleLoader().createClassLoader(); loader.getResource("dummy"); //$NON-NLS-1$ } }
public Bundle[] getImportingBundles() { if (supplier.isStale()) return null; AbstractBundle bundle = (AbstractBundle) getExportingBundle(); if (bundle == null) return null; AbstractBundle[] bundles = bundle.framework.getAllBundles(); List<Bundle> importers = new ArrayList<Bundle>(10); PackageSource supplierSource = supplier.createPackageSource(exportedPackage, false); for (int i = 0; i < bundles.length; i++) { if (!(bundles[i] instanceof BundleHost)) continue; BundleLoader loader = ((BundleHost) bundles[i]).getBundleLoader(); if (loader == null || loader.getBundle() == supplier.getBundle()) continue; // do not include include the exporter of the package PackageSource importerSource = loader.getPackageSource(getName()); if (supplierSource != null && supplierSource.hasCommonSource(importerSource)) importers.add(bundles[i]); } return importers.toArray(new Bundle[importers.size()]); }
BundleLoader requiredLoader = requiredBundles[i].getBundleLoader(); requiredLoader.addExportedProvidersFor(proxy.getSymbolicName(), pkgName, result, visited);
public BundleWiring getBundleWiring() { return loader.getLoaderProxy().getBundleDescription().getWiring(); }
private synchronized boolean isLazyTriggerSet() { if (proxy == null) return false; BundleLoader loader = proxy.getBasicBundleLoader(); return loader != null ? loader.isLazyTriggerSet() : false; }
final PackageSource createExportPackageSource(ExportPackageDescription export, KeyedHashSet visited) { BundleLoaderProxy exportProxy = getLoaderProxy(export.getExporter()); if (exportProxy == null) // TODO log error!! return null; PackageSource requiredSource = exportProxy.getBundleLoader().findRequiredSource(export.getName(), visited); PackageSource exportSource = exportProxy.createPackageSource(export, false); if (requiredSource == null) return exportSource; return createMultiSource(export.getName(), new PackageSource[] {requiredSource, exportSource}); }
private void initializeExports(ExportPackageDescription[] exports, Collection<String> exportNames) { for (int i = 0; i < exports.length; i++) { if (proxy.forceSourceCreation(exports[i])) { if (!exportNames.contains(exports[i].getName())) { // must force filtered and reexport sources to be created early // to prevent lazy normal package source creation. // We only do this for the first export of a package name. proxy.createPackageSource(exports[i], true); } } exportNames.add(exports[i].getName()); } }
void addRequirers(BundleDescription dependent, List<Bundle> result) { if (dependent.getHost() != null) // don't look in fragments. return; BundleLoaderProxy dependentProxy = getBundleLoader().getLoaderProxy(dependent); if (dependentProxy == null) return; // bundle must have been uninstalled if (result.contains(dependentProxy.bundle)) return; // prevent endless recusion BundleLoader dependentLoader = dependentProxy.getBundleLoader(); BundleLoaderProxy[] requiredBundles = dependentLoader.requiredBundles; int[] reexportTable = dependentLoader.reexportTable; return; for (int j = 0; j < dependents.length; j++) dependentProxy.addRequirers(dependents[j], result);
local = proxy.getPackageSource(packageName); else if (isSubstitutedExport(packageName)) { result.add(findImportedSource(packageName, visited)); requiredBundles[i].getBundleLoader().addExportedProvidersFor(symbolicName, packageName, result, visited); } else if (reexportIndex < size && reexportTable[reexportIndex] == i) { reexportIndex++; requiredBundles[i].getBundleLoader().addExportedProvidersFor(symbolicName, packageName, result, visited);
private void cleanRemovalPendings(State systemState, BundleDescription[] removalPendings) { if (removalPendings.length == 0) return; systemState.resolve(removalPendings); for (int i = 0; i < removalPendings.length; i++) { Object userObject = removalPendings[i].getUserObject(); if (userObject instanceof BundleLoaderProxy) { BundleLoader.closeBundleLoader((BundleLoaderProxy) userObject); try { ((BundleLoaderProxy) userObject).getBundleData().close(); } catch (IOException e) { // ignore } } else if (userObject instanceof BundleData) { try { ((BundleData) userObject).close(); } catch (IOException e) { // ignore } } } }
AbstractBundle getBundle() { return supplier.getBundleHost(); }
public RegisteredPolicy(BundleLoader requester) { super(requester); //Filter the dependents; if (allDependents == null) return; for (Iterator<BundleDescription> iter = allDependents.iterator(); iter.hasNext();) { BundleLoaderProxy proxy = buddyRequester.getLoaderProxy(iter.next()); if (proxy == null) iter.remove(); try { String[] allContributions = ManifestElement.getArrayFromList(((AbstractBundle) proxy.getBundle()).getBundleData().getManifest().get(Constants.REGISTERED_POLICY)); if (allContributions == null) { iter.remove(); continue; } boolean contributes = false; for (int j = 0; j < allContributions.length && contributes == false; j++) { if (allContributions[j].equals(buddyRequester.getBundle().getSymbolicName())) contributes = true; } if (!contributes) iter.remove(); } catch (BundleException e) { iter.remove(); } } //After the filtering, if nothing is left then null out the variable for optimization if (allDependents.size() == 0) allDependents = null; }
public Enumeration<URL> getResources(String name) { return supplier.getBundleLoader().findLocalResources(name); }
private void checkClassLoader() { BundleLoaderProxy proxy = getLoaderProxy(); if (proxy != null && proxy.inUse() && proxy.getBundleLoader() != null) { BundleClassLoader loader = proxy.getBundleLoader().createClassLoader(); loader.getResource("dummy"); //$NON-NLS-1$ } }
public Bundle[] getImportingBundles() { if (supplier.isStale()) return null; AbstractBundle bundle = (AbstractBundle) getExportingBundle(); if (bundle == null) return null; AbstractBundle[] bundles = bundle.framework.getAllBundles(); List<Bundle> importers = new ArrayList<Bundle>(10); PackageSource supplierSource = supplier.createPackageSource(exportedPackage, false); for (int i = 0; i < bundles.length; i++) { if (!(bundles[i] instanceof BundleHost)) continue; BundleLoader loader = ((BundleHost) bundles[i]).getBundleLoader(); if (loader == null || loader.getBundle() == supplier.getBundle()) continue; // do not include include the exporter of the package PackageSource importerSource = loader.getPackageSource(getName()); if (supplierSource != null && supplierSource.hasCommonSource(importerSource)) importers.add(bundles[i]); } return importers.toArray(new Bundle[importers.size()]); }