private static Object getUserProperty( BundleDescription desc, String name ) { if ( desc == null ) { return null; } Object userObject = desc.getUserObject(); if ( userObject instanceof Map ) { return ( (Map) userObject ).get( name ); } return null; }
@Override public void filterResolvable(Collection<BundleRevision> candidates) { for (Iterator<BundleRevision> iCandidates = candidates.iterator(); iCandidates.hasNext();) { BundleDescription candDesc = (BundleDescription) iCandidates.next(); ModuleRevision candRevision = (ModuleRevision) candDesc.getUserObject(); if (candRevision.getWiring() == null) { iCandidates.remove(); } } }
@Override public void filterResolvable(Collection<BundleRevision> candidates) { for (Iterator<BundleRevision> iCandidates = candidates.iterator(); iCandidates.hasNext();) { BundleDescription candDesc = (BundleDescription) iCandidates.next(); ModuleRevision candRevision = (ModuleRevision) candDesc.getUserObject(); if (candRevision.getWiring() == null) { iCandidates.remove(); } } }
private static void setUserProperty( BundleDescription desc, String name, Object value ) { Object userObject = desc.getUserObject(); if ( userObject != null && !( userObject instanceof Map ) ) { throw new IllegalStateException( "Unexpected user object " + desc.toString() ); } Map props = (Map) userObject; if ( props == null ) { props = new HashMap(); desc.setUserObject( props ); } props.put( name, value ); }
public Collection<Bundle> getDependencyClosure(Collection<Bundle> bundles) { Collection<BundleDescription> descriptions = getDescriptionClosure(bundles); Set<Bundle> result = new HashSet<Bundle>(); for (BundleDescription description : descriptions) { Object userObject = description.getUserObject(); if (userObject instanceof BundleReference) { Bundle bundle = ((BundleReference) userObject).getBundle(); if (bundle != null) result.add(bundle); } } return result; }
public Collection<Bundle> getDependencyClosure(Collection<Bundle> bundles) { Collection<BundleDescription> descriptions = getDescriptionClosure(bundles); Set<Bundle> result = new HashSet<Bundle>(); for (BundleDescription description : descriptions) { Object userObject = description.getUserObject(); if (userObject instanceof BundleReference) { Bundle bundle = ((BundleReference) userObject).getBundle(); if (bundle != null) result.add(bundle); } } return result; }
private boolean isInUse(BundleDescription bundle) { Object userObject = bundle.getUserObject(); if (userObject instanceof BundleLoaderProxy) return ((BundleLoaderProxy) userObject).inUse(); return bundle.getDependents().length > 0; }
private boolean isInUse(BundleDescription bundle) { Object userObject = bundle.getUserObject(); if (userObject instanceof BundleLoaderProxy) return ((BundleLoaderProxy) userObject).inUse(); return bundle.getDependents().length > 0; }
public Collection<Bundle> getRemovalPendingBundles() { // TODO need to consolidate our removal pending tracking. // We currently have three places this is kept (PackageAdminImpl, StateImpl and ResolverImpl) // Using the state's because it has easy access to the uninstalled Bundle objects BundleDescription[] removals = framework.adaptor.getState().getRemovalPending(); Set<Bundle> result = new HashSet<Bundle>(); for (int i = 0; i < removals.length; i++) { Object ref = removals[i].getUserObject(); if (ref instanceof BundleReference) result.add(((BundleReference) ref).getBundle()); } return result; }
public Collection<Bundle> getRemovalPendingBundles() { // TODO need to consolidate our removal pending tracking. // We currently have three places this is kept (PackageAdminImpl, StateImpl and ResolverImpl) // Using the state's because it has easy access to the uninstalled Bundle objects BundleDescription[] removals = framework.adaptor.getState().getRemovalPending(); Set<Bundle> result = new HashSet<Bundle>(); for (int i = 0; i < removals.length; i++) { Object ref = removals[i].getUserObject(); if (ref instanceof BundleReference) result.add(((BundleReference) ref).getBundle()); } return result; }
private static boolean isDir(BundleDescription bundle, IPublisherInfo info) { Collection<IBundleShapeAdvice> advice = info.getAdvice(null, true, bundle.getSymbolicName(), PublisherHelper.fromOSGiVersion(bundle.getVersion()), IBundleShapeAdvice.class); // if the advice has a shape, use it if (advice != null && !advice.isEmpty()) { // we know there is some advice but if there is more than one, take the first. String shape = advice.iterator().next().getShape(); if (shape != null) return shape.equals(IBundleShapeAdvice.DIR); } // otherwise go with whatever we figured out from the manifest or the shape on disk @SuppressWarnings("unchecked") Map<String, String> manifest = (Map<String, String>) bundle.getUserObject(); String format = manifest.get(BUNDLE_SHAPE); return DIR.equals(format); }
protected void createShapeAdvice(BundleDescription bundle) { @SuppressWarnings("unchecked") Dictionary<String, String> manifest = (Dictionary<String, String>) bundle.getUserObject(); String shape = manifest.get(BUNDLE_SHAPE); if (shape == null) { if (unpack != null) { shape = Boolean.valueOf(unpack).booleanValue() ? IBundleShapeAdvice.DIR : IBundleShapeAdvice.JAR; } else { shape = Utils.guessUnpack(bundle, Utils.getBundleClasspath(manifest)) ? IBundleShapeAdvice.DIR : IBundleShapeAdvice.JAR; } } BundleShapeAdvice advice = new BundleShapeAdvice(bundle.getSymbolicName(), PublisherHelper.fromOSGiVersion(bundle.getVersion()), shape); info.addAdvice(advice); }
public final BundleLoaderProxy getLoaderProxy(BundleDescription source) { Object userObject = source.getUserObject(); if (!(userObject instanceof BundleLoaderProxy)) { // may need to force the proxy to be created long exportingID = source.getBundleId(); BundleHost exportingBundle = (BundleHost) bundle.getFramework().getBundle(exportingID); if (exportingBundle == null) return null; userObject = exportingBundle.getLoaderProxy(); } return (BundleLoaderProxy) userObject; }
protected void createShapeAdvice(BundleDescription bundle) { @SuppressWarnings("unchecked") Dictionary<String, String> manifest = (Dictionary<String, String>) bundle.getUserObject(); String shape = manifest.get(BUNDLE_SHAPE); if (shape == null) { if (unpack != null) { shape = Boolean.valueOf(unpack).booleanValue() ? IBundleShapeAdvice.DIR : IBundleShapeAdvice.JAR; } else { shape = Utils.guessUnpack(bundle, Utils.getBundleClasspath(manifest)) ? IBundleShapeAdvice.DIR : IBundleShapeAdvice.JAR; } } BundleShapeAdvice advice = new BundleShapeAdvice(bundle.getSymbolicName(), PublisherHelper.fromOSGiVersion(bundle.getVersion()), shape); info.addAdvice(advice); }
public final BundleLoaderProxy getLoaderProxy(BundleDescription source) { Object userObject = source.getUserObject(); if (!(userObject instanceof BundleLoaderProxy)) { // may need to force the proxy to be created long exportingID = source.getBundleId(); BundleHost exportingBundle = (BundleHost) bundle.getFramework().getBundle(exportingID); if (exportingBundle == null) return null; userObject = exportingBundle.getLoaderProxy(); } return (BundleLoaderProxy) userObject; }
protected void createShapeAdvice(BundleDescription bundle) { @SuppressWarnings("unchecked") Dictionary<String, String> manifest = (Dictionary<String, String>) bundle.getUserObject(); String shape = manifest.get(BUNDLE_SHAPE); if (shape == null) { if (unpack != null) { shape = Boolean.parseBoolean(unpack) ? IBundleShapeAdvice.DIR : IBundleShapeAdvice.JAR; } else { shape = Utils.guessUnpack(bundle, Utils.getBundleClasspath(manifest)) ? IBundleShapeAdvice.DIR : IBundleShapeAdvice.JAR; } } BundleShapeAdvice advice = new BundleShapeAdvice(bundle.getSymbolicName(), PublisherHelper.fromOSGiVersion(bundle.getVersion()), shape); info.addAdvice(advice); }
@Override boolean basicAddBundle(BundleDescription description) { if (framework != null && description.getUserObject() == null) { // We always set the user object to a BundleReference object; // This allows the resolver to implement BundleRevisions for // the resolver hooks. AbstractBundle bundle = framework.getBundle(description.getBundleId()); description.setUserObject(bundle != null ? bundle.getBundleData() : null); } return super.basicAddBundle(description); }
@Override boolean basicAddBundle(BundleDescription description) { if (framework != null && description.getUserObject() == null) { // We always set the user object to a BundleReference object; // This allows the resolver to implement BundleRevisions for // the resolver hooks. AbstractBundle bundle = framework.getBundle(description.getBundleId()); description.setUserObject(bundle != null ? bundle.getBundleData() : null); } return super.basicAddBundle(description); }
private ExportedPackageImpl createExportedPackage(ExportPackageDescription description) { BundleDescription exporter = description.getExporter(); if (exporter == null || exporter.getHost() != null) return null; Object userObject = exporter.getUserObject(); if (!(userObject instanceof BundleLoaderProxy)) { BundleHost bundle = (BundleHost) framework.getBundle(exporter.getBundleId()); if (bundle == null) return null; userObject = bundle.getLoaderProxy(); } return new ExportedPackageImpl(description, (BundleLoaderProxy) userObject); }
private ExportedPackageImpl createExportedPackage(ExportPackageDescription description) { BundleDescription exporter = description.getExporter(); if (exporter == null || exporter.getHost() != null) return null; Object userObject = exporter.getUserObject(); if (!(userObject instanceof BundleLoaderProxy)) { BundleHost bundle = (BundleHost) framework.getBundle(exporter.getBundleId()); if (bundle == null) return null; userObject = bundle.getLoaderProxy(); } return new ExportedPackageImpl(description, (BundleLoaderProxy) userObject); }