Examples of BundleRequirement


Examples of org.osgi.framework.wiring.BundleRequirement

                        ? mutated
                        : new HashSet<BundleRequirement>();

                    for (int reqIdx = usedBlame.m_reqs.size() - 1; reqIdx >= 0; reqIdx--)
                    {
                        BundleRequirement req = usedBlame.m_reqs.get(reqIdx);

                        // If we've already permutated this requirement in another
                        // uses constraint, don't permutate it again just continue
                        // with the next uses constraint.
                        if (mutated.contains(req))
                        {
                            break;
                        }

                        // See if we can permutate the candidates for blamed
                        // requirement; there may be no candidates if the revision
                        // associated with the requirement is already resolved.
                        SortedSet<BundleCapability> candidates =
                            permutation.getCandidates(req);
                        if ((candidates != null) && (candidates.size() > 1))
                        {
                            mutated.add(req);
                            Iterator it = candidates.iterator();
                            it.next();
                            it.remove();
                            // Continue with the next uses constraint.
                            break;
                        }
                    }
                }
            }

            if (rethrow != null)
            {
                if (mutated.size() > 0)
                {
                    m_usesPermutations.add(permutation);
                }
                m_logger.log(
                    Logger.LOG_DEBUG,
                    "Candidate permutation failed due to a conflict between "
                    + "an export and import; will try another if possible.",
                    rethrow);
                throw rethrow;
            }
        }

        // Check if there are any uses conflicts with imported packages.
        for (Entry<String, List<Blame>> entry : pkgs.m_importedPkgs.entrySet())
        {
            for (Blame importBlame : entry.getValue())
            {
                String pkgName = entry.getKey();
                if (!pkgs.m_usedPkgs.containsKey(pkgName))
                {
                    continue;
                }
                for (Blame usedBlame : pkgs.m_usedPkgs.get(pkgName))
                {
                    if (!isCompatible(importBlame.m_cap, usedBlame.m_cap, revisionPkgMap))
                    {
                        // Create a candidate permutation that eliminates any candidates
                        // that conflict with existing selected candidates.
                        permutation = (permutation != null)
                            ? permutation
                            : allCandidates.copy();
                        rethrow = (rethrow != null)
                            ? rethrow
                            : new ResolveException(
                                "Uses constraint violation. Unable to resolve bundle revision "
                                + revision.getSymbolicName()
                                + " [" + revision
                                + "] because it is exposed to package '"
                                + pkgName
                                + "' from bundle revisions "
                                + importBlame.m_cap.getRevision().getSymbolicName()
                                + " [" + importBlame.m_cap.getRevision()
                                + "] and "
                                + usedBlame.m_cap.getRevision().getSymbolicName()
                                + " [" + usedBlame.m_cap.getRevision()
                                + "] via two dependency chains.\n\nChain 1:\n"
                                + toStringBlame(importBlame)
                                + "\n\nChain 2:\n"
                                + toStringBlame(usedBlame),
                                null,
                                null);

                        mutated = (mutated != null)
                            ? mutated
                            : new HashSet();

                        for (int reqIdx = usedBlame.m_reqs.size() - 1; reqIdx >= 0; reqIdx--)
                        {
                            BundleRequirement req = usedBlame.m_reqs.get(reqIdx);

                            // If we've already permutated this requirement in another
                            // uses constraint, don't permutate it again just continue
                            // with the next uses constraint.
                            if (mutated.contains(req))
                            {
                                break;
                            }

                            // See if we can permutate the candidates for blamed
                            // requirement; there may be no candidates if the revision
                            // associated with the requirement is already resolved.
                            SortedSet<BundleCapability> candidates =
                                permutation.getCandidates(req);
                            if ((candidates != null) && (candidates.size() > 1))
                            {
                                mutated.add(req);
                                Iterator it = candidates.iterator();
                                it.next();
                                it.remove();
                                // Continue with the next uses constraint.
                                break;
                            }
                        }
                    }
                }

                // If there was a uses conflict, then we should add a uses
                // permutation if we were able to permutate any candidates.
                // Additionally, we should try to push an import permutation
                // for the original import to force a backtracking on the
                // original candidate decision if no viable candidate is found
                // for the conflicting uses constraint.
                if (rethrow != null)
                {
                    // Add uses permutation if we mutated any candidates.
                    if (mutated.size() > 0)
                    {
                        m_usesPermutations.add(permutation);
                    }

                    // Try to permutate the candidate for the original
                    // import requirement; only permutate it if we haven't
                    // done so already.
                    BundleRequirement req = importBlame.m_reqs.get(0);
                    if (!mutated.contains(req))
                    {
                        // Since there may be lots of uses constraint violations
                        // with existing import decisions, we may end up trying
                        // to permutate the same import a lot of times, so we should
                        // try to check if that the case and only permutate it once.
                        permutateIfNeeded(allCandidates, req, m_importPermutations);
                    }

                    m_logger.log(
                        Logger.LOG_DEBUG,
                        "Candidate permutation failed due to a conflict between "
                        + "imports; will try another if possible.",
                        rethrow);
                    throw rethrow;
                }
            }
        }

        resultCache.put(revision, Boolean.TRUE);

        // Now check the consistency of all revisions on which the
        // current revision depends. Keep track of the current number
        // of permutations so we know if the lower level check was
        // able to create a permutation or not in the case of failure.
        int permCount = m_usesPermutations.size() + m_importPermutations.size();
        for (Entry<String, List<Blame>> entry : pkgs.m_importedPkgs.entrySet())
        {
            for (Blame importBlame : entry.getValue())
            {
                if (!revision.equals(importBlame.m_cap.getRevision()))
                {
                    try
                    {
                        checkPackageSpaceConsistency(
                            false, importBlame.m_cap.getRevision(),
                            allCandidates, revisionPkgMap, resultCache);
                    }
                    catch (ResolveException ex)
                    {
                        // If the lower level check didn't create any permutations,
                        // then we should create an import permutation for the
                        // requirement with the dependency on the failing revision
                        // to backtrack on our current candidate selection.
                        if (permCount == (m_usesPermutations.size() + m_importPermutations.size()))
                        {
                            BundleRequirement req = importBlame.m_reqs.get(0);
                            permutate(allCandidates, req, m_importPermutations);
                        }
                        throw ex;
                    }
                }
View Full Code Here

Examples of org.osgi.framework.wiring.BundleRequirement

    {
        wireMap.put(revision, (List<ResolverWire>) Collections.EMPTY_LIST);

        List<ResolverWire> packageWires = new ArrayList<ResolverWire>();

        BundleRequirement dynReq = null;
        BundleCapability dynCand = null;
        for (BundleRequirement req
            : Util.getDynamicRequirements(revision.getWiring().getRequirements(null)))
        {
            // Get the candidates for the current dynamic requirement.
View Full Code Here

Examples of org.osgi.framework.wiring.BundleRequirement

        StringBuffer sb = new StringBuffer();
        if ((blame.m_reqs != null) && !blame.m_reqs.isEmpty())
        {
            for (int i = 0; i < blame.m_reqs.size(); i++)
            {
                BundleRequirement req = blame.m_reqs.get(i);
                sb.append("  ");
                sb.append(req.getRevision().getSymbolicName());
                sb.append(" [");
                sb.append(req.getRevision().toString());
                sb.append("]\n");
                if (req.getNamespace().equals(BundleRevision.PACKAGE_NAMESPACE))
                {
                    sb.append("    import: ");
                }
                else
                {
                    sb.append("    require: ");
                }
                sb.append(((BundleRequirementImpl) req).getFilter().toString());
                sb.append("\n     |");
                if (req.getNamespace().equals(BundleRevision.PACKAGE_NAMESPACE))
                {
                    sb.append("\n    export: ");
                }
                else
                {
View Full Code Here

Examples of org.osgi.framework.wiring.BundleRequirement

        }

        // If we have requirements remaining, then find candidates for them.
        while (remainingReqs.size() > 0)
        {
            BundleRequirement req = remainingReqs.remove(0);

            // Ignore non-effective and dynamic requirements.
            String resolution = req.getDirectives().get(Constants.RESOLUTION_DIRECTIVE);
            if (!state.isEffective(req)
                || ((resolution != null)
                    && resolution.equals(FelixConstants.RESOLUTION_DYNAMIC)))
            {
                continue;
View Full Code Here

Examples of org.osgi.framework.wiring.BundleRequirement

    {
        // Create a modifiable list of the revision's requirements.
        List<BundleRequirement> remainingReqs =
            new ArrayList(revision.getDeclaredRequirements(null));
        // Find the host requirement.
        BundleRequirement hostReq = null;
        for (Iterator<BundleRequirement> it = remainingReqs.iterator();
            it.hasNext(); )
        {
            BundleRequirement r = it.next();
            if (r.getNamespace().equals(BundleRevision.HOST_NAMESPACE))
            {
                hostReq = r;
                it.remove();
                break;
            }
View Full Code Here

Examples of org.osgi.framework.wiring.BundleRequirement

            }

            // Copy candidates for fragment requirements to the host.
            for (BundleRequirement r : hostRevision.getDeclaredRequirements(null))
            {
                BundleRequirement origReq =
                    ((HostedRequirement) r).getOriginalRequirement();
                SortedSet<BundleCapability> cands = m_candidateMap.get(origReq);
                if (cands != null)
                {
                    m_candidateMap.put(r, new TreeSet<BundleCapability>(cands));
View Full Code Here

Examples of org.osgi.framework.wiring.BundleRequirement

    private void populateDependents()
    {
        for (Entry<BundleRequirement, SortedSet<BundleCapability>> entry
            : m_candidateMap.entrySet())
        {
            BundleRequirement req = entry.getKey();
            SortedSet<BundleCapability> caps = entry.getValue();
            for (BundleCapability cap : caps)
            {
                // Record the requirement as dependent on the capability.
                Set<BundleRequirement> dependents = m_dependentMap.get(cap);
                if (dependents == null)
                {
                    dependents = new HashSet<BundleRequirement>();
                    m_dependentMap.put(cap, dependents);
                }
                dependents.add(req);

                // Keep track of hosts and associated fragments.
                if (req.getNamespace().equals(BundleRevision.HOST_NAMESPACE))
                {
                    Map<String, Map<Version, List<BundleRequirement>>>
                        fragments = m_hostFragments.get(cap);
                    if (fragments == null)
                    {
                        fragments = new HashMap<String, Map<Version, List<BundleRequirement>>>();
                        m_hostFragments.put(cap, fragments);
                    }
                    Map<Version, List<BundleRequirement>> fragmentVersions =
                        fragments.get(req.getRevision().getSymbolicName());
                    if (fragmentVersions == null)
                    {
                        fragmentVersions =
                            new TreeMap<Version, List<BundleRequirement>>(Collections.reverseOrder());
                        fragments.put(req.getRevision().getSymbolicName(), fragmentVersions);
                    }
                    List<BundleRequirement> actual = fragmentVersions.get(req.getRevision().getVersion());
                    if (actual == null)
                    {
                        actual = new ArrayList<BundleRequirement>();
                        fragmentVersions.put(req.getRevision().getVersion(), actual);
                    }
                    actual.add(req);
                }
            }
        }
View Full Code Here

Examples of org.osgi.framework.wiring.BundleRequirement

        }

        // If we have requirements remaining, then find candidates for them.
        while (!remainingReqs.isEmpty())
        {
            BundleRequirement req = remainingReqs.remove(0);

            // Ignore non-effective and dynamic requirements.
            String resolution = req.getDirectives().get(Constants.RESOLUTION_DIRECTIVE);
            if (!rc.isEffective(req)
                || ((resolution != null)
                    && resolution.equals(FelixConstants.RESOLUTION_DYNAMIC)))
            {
                continue;
View Full Code Here

Examples of org.osgi.framework.wiring.BundleRequirement

    {
        // Create a modifiable list of the revision's requirements.
        List<BundleRequirement> remainingReqs =
            new ArrayList(revision.getDeclaredRequirements(null));
        // Find the host requirement.
        BundleRequirement hostReq = null;
        for (Iterator<BundleRequirement> it = remainingReqs.iterator();
            it.hasNext(); )
        {
            BundleRequirement r = it.next();
            if (r.getNamespace().equals(BundleRevision.HOST_NAMESPACE))
            {
                hostReq = r;
                it.remove();
                break;
            }
View Full Code Here

Examples of org.osgi.framework.wiring.BundleRequirement

            }

            // Copy candidates for fragment requirements to the host.
            for (BundleRequirement r : hostRevision.getDeclaredRequirements(null))
            {
                BundleRequirement origReq =
                    ((WrappedRequirement) r).getOriginalRequirement();
                List<BundleCapability> cands = m_candidateMap.get(origReq);
                if (cands != null)
                {
                    m_candidateMap.put(r, new ArrayList<BundleCapability>(cands));
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.