Examples of BundleRequirementImpl


Examples of org.apache.felix.framework.wiring.BundleRequirementImpl

    ExportedPackage[] getExportedPackages(String pkgName)
    {
        // First, get all exporters of the package.
        Map<String, Object> attrs = Collections.singletonMap(
            BundleRevision.PACKAGE_NAMESPACE, (Object) pkgName);
        BundleRequirementImpl req = new BundleRequirementImpl(
            null,
            BundleRevision.PACKAGE_NAMESPACE,
            Collections.EMPTY_MAP,
            attrs);
        List<BundleCapability> exports = m_resolver.findProviders(req, false);

        // We only want resolved capabilities.
        for (Iterator<BundleCapability> it = exports.iterator(); it.hasNext(); )
        {
            if (it.next().getRevision().getWiring() == null)
            {
                it.remove();
            }
        }

        if (exports != null)
        {
            List pkgs = new ArrayList();

            for (Iterator<BundleCapability> it = exports.iterator(); it.hasNext(); )
            {
                // Get the bundle associated with the current exporting revision.
                Bundle bundle = it.next().getRevision().getBundle();

                // We need to find the version of the exported package, but this
                // is tricky since there may be multiple versions of the package
                // offered by a given bundle, since multiple revisions of the
                // bundle JAR file may exist if the bundle was updated without
                // refreshing the framework. In this case, each revision of the
                // bundle JAR file is represented as a revision ordered from
                // newest to oldest. We assume that the first revision found to
                // be exporting the package is the provider of the package,
                // which makes sense since it must have been resolved first.
                List<BundleRevision> revisions =
                    bundle.adapt(BundleRevisions.class).getRevisions();
                for (int i = revisions.size() - 1; i >= 0; i--)
                {
                    BundleRevision br = revisions.get(i);
                    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()))
                        {
                            pkgs.add(
                                new ExportedPackageImpl(
                                    this, (BundleImpl) bundle, br, cap));
                        }
View Full Code Here

Examples of org.apache.felix.framework.wiring.BundleRequirementImpl

        }

        // Determine if any providers of the package exist.
        Map<String, Object> attrs = Collections.singletonMap(
            BundleRevision.PACKAGE_NAMESPACE, (Object) pkgName);
        BundleRequirementImpl req = new BundleRequirementImpl(
            revision,
            BundleRevision.PACKAGE_NAMESPACE,
            Collections.EMPTY_MAP,
            attrs);
        List<BundleCapability> candidates = rc.findProviders(req, false);

        // Try to find a dynamic requirement that matches the capabilities.
        BundleRequirementImpl dynReq = null;
        for (int dynIdx = 0;
            (candidates.size() > 0) && (dynReq == null) && (dynIdx < dynamics.size());
            dynIdx++)
        {
            for (Iterator<BundleCapability> itCand = candidates.iterator();
                (dynReq == null) && itCand.hasNext(); )
            {
                BundleCapability cap = itCand.next();
                if (CapabilitySet.matches(
                    (BundleCapabilityImpl) cap,
                    ((BundleRequirementImpl) dynamics.get(dynIdx)).getFilter()))
                {
                    dynReq = (BundleRequirementImpl) dynamics.get(dynIdx);
                }
            }
        }

        // If we found a matching dynamic requirement, then filter out
        // any candidates that do not match it.
        if (dynReq != null)
        {
            for (Iterator<BundleCapability> itCand = candidates.iterator();
                itCand.hasNext(); )
            {
                BundleCapability cap = itCand.next();
                if (!CapabilitySet.matches(
                    (BundleCapabilityImpl) cap, dynReq.getFilter()))
                {
                    itCand.remove();
                }
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.