Refine search
/** * 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; }
@Override public void start(final BundleContext bundleContext) throws Exception { ProviderUtil.STARTUP_LOCK.lock(); lockingProviderUtil = true; final BundleWiring self = bundleContext.getBundle().adapt(BundleWiring.class); final List<BundleWire> required = self.getRequiredWires(LoggerContextFactory.class.getName()); for (final BundleWire wire : required) { loadProvider(bundleContext, wire.getProviderWiring()); } bundleContext.addBundleListener(this); final Bundle[] bundles = bundleContext.getBundles(); for (final Bundle bundle : bundles) { loadProvider(bundle); } unlockIfReady(); }
if (bundle.getHeaders("").get(ComponentConstants.SERVICE_COMPONENT) == null) BundleContext context = bundle.getBundleContext(); if ( context == null ) BundleWiring wiring = bundle.adapt( BundleWiring.class ); List<BundleWire> extenderWires = wiring.getRequiredWires( ExtenderNamespace.EXTENDER_NAMESPACE ); for ( BundleWire wire : extenderWires ) wire.getCapability().getAttributes().get( ExtenderNamespace.EXTENDER_NAMESPACE ) ) ) if ( !m_bundle.adapt( BundleRevision.class ).equals( wire.getProvider() ) ) bundle, wire.getProvider().getBundle());
private static LinkedHashSet<Bundle> getWiredBundles43(Bundle bundle) { LinkedHashSet<Bundle> wiredBundles = new LinkedHashSet<Bundle>(); BundleWiring wiring = bundle.adapt(BundleWiring.class); if (wiring != null) { List<BundleWire> wires; wires = wiring.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE); for (BundleWire wire : wires) { wiredBundles.add(wire.getProviderWiring().getBundle()); } wires = wiring.getRequiredWires(BundleRevision.BUNDLE_NAMESPACE); for (BundleWire wire : wires) { wiredBundles.add(wire.getProviderWiring().getBundle()); } } return wiredBundles; }
BundleWiring bundleWiring = bundle.adapt(BundleWiring.class); if (bundleWiring == null) { LOG.error("BundleWiring is null for: " + bundle); List<BundleWire> requiredWires = bundleWiring.getRequiredWires(null); for (BundleWire bundleWire : requiredWires) { Bundle exportingBundle = bundleWire.getCapability().getRevision() .getBundle(); if (exportingBundle.getBundleId() == 0) { continue; // system bundle is skipped this one isn't needed while (bundleIterator.hasNext()) { Bundle auxBundle = bundleIterator.next(); if (auxBundle.getState() == Bundle.UNINSTALLED) { bundleIterator.remove();
Bundle bundle; if (wire.getProvider() instanceof BundleRevision) { bundle = ((BundleRevision) wire.getProvider()).getBundle(); } else { bundle = resources.get(wire.getProvider()); Resource r = b != null ? b.adapt(BundleRevision.class) : wire.getRequirer(); newFragments.get(bundle).add(r); resource = bundle.adapt(BundleRevision.class); BundleWiring wiring = bundle.adapt(BundleWiring.class); if (wiring == null) { continue; for (BundleWire wire : wiring.getProvidedWires(null)) { if (HOST_NAMESPACE.equals(wire.getCapability().getNamespace())) { oldFragments.add(wire.getRequirer()); for (BundleWire wire : wiring.getRequiredWires(null)) { BundleRevision rev = wire.getProvider(); Bundle provider = rev.getBundle(); if (toRefresh.containsKey(provider)) {
private List<String> getAllHeaders(String headerName, Bundle bundle) { List<Bundle> bundlesFragments = new ArrayList<Bundle>(); bundlesFragments.add(bundle); BundleRevision rev = bundle.adapt(BundleRevision.class); if (rev != null) { BundleWiring wiring = rev.getWiring(); if (wiring != null) { for (BundleWire wire : wiring.getProvidedWires("osgi.wiring.host")) { bundlesFragments.add(wire.getRequirement().getRevision().getBundle()); } } } List<String> l = new ArrayList<String>(); for (Bundle bf : bundlesFragments) { String header = bf.getHeaders().get(headerName); if (header != null) { l.add(header); } } return l; }
BundleWiring wiring = context.getBundle().adapt(BundleWiring.class); List<BundleWire> required = wiring.getRequiredWires(BundleNamespace.BUNDLE_NAMESPACE); if (required.isEmpty()) { throw new IllegalStateException("No org.apache.felix.scr bundle found!"); //$NON-NLS-1$ scr = required.get(0).getProvider().getBundle(); if (!"org.apache.felix.scr".equals(scr.getSymbolicName())) { //$NON-NLS-1$ throw new IllegalStateException("Required wrong bundle: " + scr); //$NON-NLS-1$ BundleStartLevel equinoxSDstartLevel = context.getBundle().adapt(BundleStartLevel.class); BundleStartLevel scrStartLevel = scr.adapt(BundleStartLevel.class); scrStartLevel.setStartLevel(equinoxSDstartLevel.getStartLevel());
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; }
long id = bundle.getBundleId(); System.out.println(bundle); System.out.print(" "); //$NON-NLS-1$ ServiceReference<?>[] services = bundle.getRegisteredServices(); if (services != null) { System.out.print(" "); //$NON-NLS-1$ BundleWiring wiring = revision.getWiring(); if (wiring == null) { continue; List<BundleCapability> exports = wiring.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE); if ( exports.isEmpty()) { System.out.print(" "); //$NON-NLS-1$ title = false; for (BundleWire hostWire : hostWires) { System.out.print(" "); //$NON-NLS-1$ System.out.println(hostWire.getProvider().getBundle()); for (BundleWire fragmentWire : fragmentWires) { System.out.print(" "); //$NON-NLS-1$ System.out.println(fragmentWire.getRequirer().getBundle()); System.out.println(requiredBundle.getProvider());
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 Set<Bundle> addUninstalled(Bundle bundle, Set<Bundle> refreshCandidates) { refreshCandidates.add(bundle); // Add this bundle first, so that it gets refreshed first BundleRevisions bundleRevisions = bundle.adapt(BundleRevisions.class); if (bundleRevisions != null) { for (BundleRevision br : bundleRevisions.getRevisions()) { BundleWiring bw = br.getWiring(); if (bw != null) { for (BundleWire wire : bw.getRequiredWires(null)) { Bundle b = wire.getProvider().getBundle(); if (b.getState() == Bundle.UNINSTALLED && !refreshCandidates.contains(b)) refreshCandidates = addUninstalled(b, refreshCandidates); } } } } Set<Bundle> dependent = populateDependentGraph(bundle, new HashSet<Bundle>()); for (Bundle b : dependent) { if (b.getState() == Bundle.UNINSTALLED && !refreshCandidates.contains(b)) { refreshCandidates = addUninstalled(b, refreshCandidates); } } return refreshCandidates; }
/** * TODO Copied from BeanBundles.isBeanBundle(). Using that method from pax-cdi-spi * causes a ClassCircularityError. Is there a better way to avoid this? * @param candidate * @return */ private static boolean isBeanBundle(Bundle candidate) { List<BundleWire> wires = candidate.adapt(BundleWiring.class).getRequiredWires( Constants.EXTENDER_CAPABILITY); for (BundleWire wire : wires) { Object object = wire.getCapability().getAttributes().get(Constants.EXTENDER_CAPABILITY); if (object instanceof String) { String extender = (String) object; if (extender.equals(Constants.CDI_EXTENDER)) { return true; } } } return false; }
/** * Finds the CDI extension bundles wired to this given bundle. This method recursively calls * itself to track examine wirings of wired bundles. * * @param bundle * bean bundle * @param extensions * set of found extension bundles. */ public static void findExtensions(Bundle bundle, Set<Bundle> extensions) { List<BundleWire> wires = bundle.adapt(BundleWiring.class).getRequiredWires(null); if (wires != null) { for (BundleWire wire : wires) { String ns = wire.getCapability().getNamespace(); if (CDI_EXTENSION_CAPABILITY.equals(ns) || PAX_CDI_EXTENSION_CAPABILITY.equals(ns)) { Bundle b = wire.getProviderWiring().getBundle(); extensions.add(b); findExtensions(b, extensions); } } } } }
if (it.next().getRevision().getWiring() == null) Bundle bundle = it.next().getRevision().getBundle(); bundle.adapt(BundleRevisions.class).getRevisions(); for (int i = originRevisions.size() - 1; i >= 0; i--) List<BundleRevision> revisions = Collections.singletonList(originBr); if ((originBr.getTypes() & BundleRevision.TYPE_FRAGMENT) != 0) for (BundleWire bw : originBr.getWiring().getRequiredWires(HostNamespace.HOST_NAMESPACE)) revisions.add(bw.getProviderWiring().getRevision()); List<BundleCapability> caps = (br.getWiring() == null) ? br.getDeclaredCapabilities(null) : br.getWiring().getCapabilities(null); for (BundleCapability cap : caps) if (cap.getNamespace().equals(req.getNamespace()) && CapabilitySet.matches(cap, req.getFilter()))
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); }
List<BundleRevision> revisions = bundle.adapt(BundleRevisions.class).getRevisions(); for (BundleRevision revision : revisions) BundleWiring wiring = revision.getWiring(); if (wiring != null) for (BundleWire bw : wiring.getRequiredWires(null)) if (HostNamespace.HOST_NAMESPACE.equals(bw.getCapability().getNamespace())) result.add(bw.getProvider().getBundle()); result.add(dependentWire.getRequirer().getBundle());
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; }
final String schemaExpression) { BundleWiring bundleWiring = currentBundle.adapt(BundleWiring.class); List<BundleWire> wires = bundleWiring.getRequiredWires(LiquibaseEOSGiConstants.CAPABILITY_NS_LIQUIBASE_CHANGELOG); BundleCapability capability = wire.getCapability(); Map<String, Object> capabilityAttributes = capability.getAttributes(); if (capabilityFilter.matches(capabilityAttributes)) { Object schemaResourceAttr = capabilityAttributes.get(LiquibaseEOSGiConstants.CAPABILITY_ATTR_RESOURCE); if (schemaResourceAttr != null) { bundleResource = new BundleResource(capability.getRevision().getBundle(), String.valueOf(schemaResourceAttr), capabilityAttributes); } else {
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()]); }