/** * We consider a bundle to be a candidate for objects if it imports at least * one of the packages of our interfaces * * @param bundle * @return true if the bundle is improting. */ private boolean isImportingUs(Bundle bundle) { BundleWiring wiring = bundle.adapt(BundleWiring.class); List<BundleWire> imports = wiring.getRequiredWires(PACKAGE_NAMESPACE); for (BundleWire importWire : imports) { if (packageCapabilities.contains(importWire.getCapability())) { return true; } } return false; }
private static Map<BundleCapability, List<BundleWire>> aggregateCapabilities( Pattern namespace, List<BundleWire> wires) { // Aggregate matching capabilities. Map<BundleCapability, List<BundleWire>> map = new HashMap<>(); for (BundleWire wire : wires) { if (matchNamespace(namespace, wire.getCapability().getNamespace())) { map.computeIfAbsent(wire.getCapability(), k -> new ArrayList<>()).add(wire); } } return map; }
private static Map<BundleCapability, List<BundleWire>> aggregateCapabilities( Pattern namespace, List<BundleWire> wires) { // Aggregate matching capabilities. Map<BundleCapability, List<BundleWire>> map = new HashMap<>(); for (BundleWire wire : wires) { if (matchNamespace(namespace, wire.getCapability().getNamespace())) { map.computeIfAbsent(wire.getCapability(), k -> new ArrayList<>()).add(wire); } } return map; }
/** * We consider a bundle to be a candidate for objects if it imports at least * one of the packages of our interfaces * * @param bundle * @return true if the bundle is improting. */ private boolean isImportingUs(Bundle bundle) { BundleWiring wiring = bundle.adapt(BundleWiring.class); List<BundleWire> imports = wiring.getRequiredWires(PACKAGE_NAMESPACE); for (BundleWire importWire : imports) { if (packageCapabilities.contains(importWire.getCapability())) { return true; } } return false; }
private void updateContext(Bundle currentContext, String className) { Bundle contextToSet = (currentContext == null) ? bundle : currentContext; int idx = className.lastIndexOf('.'); String packageName = (idx == -1) ? "" : className.substring(0, idx); BundleWiring wiring = contextToSet.adapt(BundleWiring.class); for (BundleWire wire : wiring.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE)) { if (wire.getCapability().getAttributes().get(BundleRevision.PACKAGE_NAMESPACE).equals(packageName)) { contextToSet = wire.getProviderWiring().getBundle(); break; } } currentLoadingBundle.get().push(contextToSet); }
/** * We consider a bundle to be a candidate for objects if it imports at least * one of the packages of our interfaces * * @param bundle * @return true if the bundle is improting. */ private boolean isImportingUs(Bundle bundle) { BundleWiring wiring = bundle.adapt(BundleWiring.class); List<BundleWire> imports = wiring.getRequiredWires(PACKAGE_NAMESPACE); for (BundleWire importWire : imports) { if (packageCapabilities.contains(importWire.getCapability())) { return true; } } return false; }
/** * We consider a bundle to be a candidate for objects if it imports at least * one of the packages of our interfaces * * @param bundle * @return true if the bundle is improting. */ private boolean isImportingUs(Bundle bundle) { BundleWiring wiring = bundle.adapt(BundleWiring.class); List<BundleWire> imports = wiring.getRequiredWires(PACKAGE_NAMESPACE); for (BundleWire importWire : imports) { if (packageCapabilities.contains(importWire.getCapability())) { return true; } } return false; }
public Bundle[] getRequiringBundles() { Set<Bundle> set = new HashSet<Bundle>(); for (BundleWire wire : m_bundle.adapt(BundleWiring.class).getProvidedWires(null)) { if (BundleNamespace.BUNDLE_NAMESPACE.equals(wire.getCapability().getNamespace())) { set.add(wire.getRequirer().getBundle()); } } return set.toArray(new Bundle[set.size()]); }
public Bundle[] getRequiringBundles() { Set<Bundle> set = new HashSet<Bundle>(); for (BundleWire wire : m_bundle.adapt(BundleWiring.class).getProvidedWires(null)) { if (BundleNamespace.BUNDLE_NAMESPACE.equals(wire.getCapability().getNamespace())) { set.add(wire.getRequirer().getBundle()); } } return set.toArray(new Bundle[set.size()]); }
public Bundle[] getImportingBundles() { // Create set for storing importing bundles. Set<Bundle> result = new HashSet<Bundle>(); // Get all importers and requirers for all revisions of the bundle. // The spec says that require-bundle should be returned with importers. for (BundleWire wire : m_export.getRevision().getWiring().getProvidedWires(null)) { if (wire.getCapability() == m_export || BundleNamespace.BUNDLE_NAMESPACE.equals(wire.getCapability().getNamespace())) { result.add( wire.getRequirer().getBundle() ); } } // Return the results. return result.toArray(new Bundle[result.size()]); }
public Bundle[] getImportingBundles() { // Create set for storing importing bundles. Set<Bundle> result = new HashSet<Bundle>(); // Get all importers and requirers for all revisions of the bundle. // The spec says that require-bundle should be returned with importers. for (BundleWire wire : m_export.getRevision().getWiring().getProvidedWires(null)) { if (wire.getCapability() == m_export || BundleNamespace.BUNDLE_NAMESPACE.equals(wire.getCapability().getNamespace())) { result.add( wire.getRequirer().getBundle() ); } } // Return the results. return result.toArray(new Bundle[result.size()]); }
BundleWires(Bundle bundle) { this.bundleId = bundle.getBundleId(); for (BundleWire wire : bundle.adapt(BundleWiring.class).getRequiredWires(null)) { String requirementId = getRequirementId(wire.getRequirement()); String capabilityId = getCapabilityId(wire.getCapability()); this.wiring.put(requirementId, capabilityId); } }
private boolean incompatibleExtender(Bundle bundle) { List<BundleWire> requiredWires = bundle.adapt(BundleWiring.class) .getRequiredWires(OSGI_EXTENDER_NS); for(BundleWire bw : requiredWires) { BundleCapability capability = bw.getCapability(); if(EntityManagerFactoryBuilder.JPA_CAPABILITY_NAME.equals( capability.getAttributes().get(OSGI_EXTENDER_NS))) { // If the persistence bundle requires a different revision for the // JPA extender then we are incompatible, otherwise we are return !capability.getRevision().equals(wiring.getRevision()); } } // If there is no requirement then we must assume that it's safe return false; }
public Map<String, Bundle> getWiredBundles(Bundle bundle) { // the set of bundles from which the bundle imports packages Map<String, Bundle> exporters = new HashMap<>(); for (BundleRevision revision : bundle.adapt(BundleRevisions.class).getRevisions()) { BundleWiring wiring = revision.getWiring(); if (wiring != null) { List<BundleWire> wires = wiring.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE); if (wires != null) { for (BundleWire wire : wires) { if (wire.getProviderWiring().getBundle().getBundleId() != 0) { exporters.put(wire.getCapability().getAttributes().get(BundleRevision.PACKAGE_NAMESPACE).toString(), wire.getProviderWiring().getBundle()); } } } } } return exporters; }
private BundleWireDTO getBundleWireDTO(BundleWire wire) { if (wire == null) { return null; } BundleWireDTO dto = new BundleWireDTO(); dto.capability = getCapabilityRefDTO(wire.getCapability()); dto.requirement = getRequirementRefDTO(wire.getRequirement()); dto.provider = getResourceId(wire.getProvider()); dto.requirer = getResourceId(wire.getRequirer()); dto.providerWiring = getWiringId(wire.getProviderWiring()); dto.requirerWiring = getWiringId(wire.getRequirerWiring()); return dto; }
private BundleWireDTO getBundleWireDTO(BundleWire wire) { if (wire == null) { return null; } BundleWireDTO dto = new BundleWireDTO(); dto.capability = getCapabilityRefDTO(wire.getCapability()); dto.requirement = getRequirementRefDTO(wire.getRequirement()); dto.provider = getResourceId(wire.getProvider()); dto.requirer = getResourceId(wire.getRequirer()); dto.providerWiring = getWiringId(wire.getProviderWiring()); dto.requirerWiring = getWiringId(wire.getRequirerWiring()); return dto; }
private BundleWireDTO getBundleWireDTO(BundleWire wire) { if (wire == null) { return null; } BundleWireDTO dto = new BundleWireDTO(); dto.capability = getCapabilityRefDTO(wire.getCapability()); dto.requirement = getRequirementRefDTO(wire.getRequirement()); dto.provider = getResourceId(wire.getProvider()); dto.requirer = getResourceId(wire.getRequirer()); dto.providerWiring = getWiringId(wire.getProviderWiring()); dto.requirerWiring = getWiringId(wire.getRequirerWiring()); return dto; }
private BundleWireDTO getBundleWireDTO(BundleWire wire) { if (wire == null) { return null; } BundleWireDTO dto = new BundleWireDTO(); dto.capability = getCapabilityRefDTO(wire.getCapability()); dto.requirement = getRequirementRefDTO(wire.getRequirement()); dto.provider = getResourceId(wire.getProvider()); dto.requirer = getResourceId(wire.getRequirer()); dto.providerWiring = getWiringId(wire.getProviderWiring()); dto.requirerWiring = getWiringId(wire.getRequirerWiring()); return dto; }
private BundleWireDTO getBundleWireDTO(BundleWire wire) { if (wire == null) { return null; } BundleWireDTO dto = new BundleWireDTO(); dto.capability = getCapabilityRefDTO(wire.getCapability()); dto.requirement = getRequirementRefDTO(wire.getRequirement()); dto.provider = getResourceId(wire.getProvider()); dto.requirer = getResourceId(wire.getRequirer()); dto.providerWiring = getWiringId(wire.getProviderWiring()); dto.requirerWiring = getWiringId(wire.getRequirerWiring()); return dto; }
private BundleWireDTO getBundleWireDTO(BundleWire wire) { if (wire == null) { return null; } BundleWireDTO dto = new BundleWireDTO(); dto.capability = getCapabilityRefDTO(wire.getCapability()); dto.requirement = getRequirementRefDTO(wire.getRequirement()); dto.provider = getResourceId(wire.getProvider()); dto.requirer = getResourceId(wire.getRequirer()); dto.providerWiring = getWiringId(wire.getProviderWiring()); dto.requirerWiring = getWiringId(wire.getRequirerWiring()); return dto; }