Examples of BundleRequirement


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

    }

    private static CompositeData[] getRequirements(List<BundleRequirement> requirementList) throws OpenDataException {
        CompositeData [] reqData = new CompositeData[requirementList.size()];
        for (int i=0; i < requirementList.size(); i++) {
            BundleRequirement requirement = requirementList.get(i);
            reqData[i] = getCapReqCompositeData(BundleWiringStateMBean.BUNDLE_REQUIREMENT_TYPE,
                requirement.getNamespace(), requirement.getAttributes().entrySet(), requirement.getDirectives().entrySet());
        }
        return reqData;
    }
View Full Code Here

Examples of org.osgi.framework.wiring.BundleRequirement

    public static CompositeData[] getRequirementsCompositeData(List<BundleRequirement> bundleRequirements) {
        try {
            CompositeData[] data = new CompositeData[bundleRequirements.size()];

            for (int i=0; i < bundleRequirements.size(); i++) {
                BundleRequirement requirement = bundleRequirements.get(i);

                CompositeData cd = BundleWiringData.getCapReqCompositeData(BundleWiringStateMBean.BUNDLE_REQUIREMENT_TYPE,
                    requirement.getNamespace(), requirement.getAttributes().entrySet(), requirement.getDirectives().entrySet());
                data[i] = cd;
            }

            return data;
        } catch (OpenDataException e) {
View Full Code Here

Examples of org.osgi.framework.wiring.BundleRequirement

            wireItems.put(BundleWiringStateMBean.PROVIDER_BUNDLE_REVISION_ID, revisionIDMap.get(capability.getRevision()));
            wireItems.put(BundleWiringStateMBean.BUNDLE_CAPABILITY,
                    getCapReqCompositeData(BundleWiringStateMBean.BUNDLE_CAPABILITY_TYPE,
                    capability.getNamespace(), capability.getAttributes().entrySet(), capability.getDirectives().entrySet()));

            BundleRequirement requirement = requiredWire.getRequirement();
            wireItems.put(BundleWiringStateMBean.REQUIRER_BUNDLE_ID, requirement.getRevision().getBundle().getBundleId());
            wireItems.put(BundleWiringStateMBean.REQUIRER_BUNDLE_REVISION_ID, revisionIDMap.get(requirement.getRevision()));

            wireItems.put(BundleWiringStateMBean.BUNDLE_REQUIREMENT,
                getCapReqCompositeData(BundleWiringStateMBean.BUNDLE_REQUIREMENT_TYPE,
                requirement.getNamespace(), requirement.getAttributes().entrySet(), requirement.getDirectives().entrySet()));

            CompositeData wireData = new CompositeDataSupport(BundleWiringStateMBean.BUNDLE_WIRE_TYPE, wireItems);
            reqWiresData[i] = wireData;
        }
        return reqWiresData;
View Full Code Here

Examples of org.osgi.framework.wiring.BundleRequirement

                // Wrap the requirement as a hosted requirement if it comes
                // from a fragment, since we will need to know the host. We
                // also need to wrap if the requirement is a dynamic import,
                // since that requirement will be shared with any other
                // matching dynamic imports.
                BundleRequirement r = wire.getRequirement();
                if (!r.getRevision().equals(wire.getRequirerWiring().getRevision())
                    || ((r.getDirectives().get(Constants.RESOLUTION_DIRECTIVE) != null)
                        && r.getDirectives().get(Constants.RESOLUTION_DIRECTIVE).equals("dynamic")))
                {
                    r = new HostedRequirement(
                        wire.getRequirerWiring().getRevision(),
                        (BundleRequirementImpl) r);
                }
                // Wrap the capability as a hosted capability if it comes
                // from a fragment, since we will need to know the host.
                BundleCapability c = wire.getCapability();
                if (!c.getRevision().equals(wire.getProviderWiring().getRevision()))
                {
                    c = new HostedCapability(
                        wire.getProviderWiring().getRevision(),
                        (BundleCapabilityImpl) c);
                }
                reqs.add(r);
                caps.add(c);
            }

            // Since the revision is resolved, it could be dynamically importing,
            // so check to see if there are candidates for any of its dynamic
            // imports.
            for (BundleRequirement req
                : Util.getDynamicRequirements(revision.getWiring().getRequirements(null)))
            {
                // Get the candidates for the current requirement.
                SortedSet<BundleCapability> candCaps =
                    allCandidates.getCandidates((BundleRequirementImpl) req);
                // Optional requirements may not have any candidates.
                if (candCaps == null)
                {
                    continue;
                }

                BundleCapability cap = candCaps.iterator().next();
                reqs.add(req);
                caps.add(cap);
                isDynamicImporting = true;
                // Can only dynamically import one at a time, so break
                // out of the loop after the first.
                break;
            }
        }
        else
        {
            for (BundleRequirement req : revision.getDeclaredRequirements(null))
            {
                String resolution = req.getDirectives().get(Constants.RESOLUTION_DIRECTIVE);
                if ((resolution == null)
                    || !resolution.equals(FelixConstants.RESOLUTION_DYNAMIC))
                {
                    // Get the candidates for the current requirement.
                    SortedSet<BundleCapability> candCaps =
                        allCandidates.getCandidates((BundleRequirementImpl) req);
                    // Optional requirements may not have any candidates.
                    if (candCaps == null)
                    {
                        continue;
                    }

                    BundleCapability cap = candCaps.iterator().next();
                    reqs.add(req);
                    caps.add(cap);
                }
            }
        }

        // First, add all exported packages to the target revision's package space.
        calculateExportedPackages(revision, allCandidates, revisionPkgMap);
        Packages revisionPkgs = revisionPkgMap.get(revision);

        // Second, add all imported packages to the target revision's package space.
        for (int i = 0; i < reqs.size(); i++)
        {
            BundleRequirement req = reqs.get(i);
            BundleCapability cap = caps.get(i);
            calculateExportedPackages(cap.getRevision(), allCandidates, revisionPkgMap);
            mergeCandidatePackages(
                revision, req, cap, revisionPkgMap, allCandidates,
                new HashMap<BundleRevision, List<BundleCapability>>());
        }

        // Third, have all candidates to calculate their package spaces.
        for (int i = 0; i < caps.size(); i++)
        {
            calculatePackageSpaces(
                caps.get(i).getRevision(), allCandidates, revisionPkgMap,
                usesCycleMap, cycle);
        }

        // Fourth, if the target revision is unresolved or is dynamically importing,
        // then add all the uses constraints implied by its imported and required
        // packages to its package space.
        // NOTE: We do not need to do this for resolved revisions because their
        // package space is consistent by definition and these uses constraints
        // are only needed to verify the consistency of a resolving revision. The
        // only exception is if a resolved revision is dynamically importing, then
        // we need to calculate its uses constraints again to make sure the new
        // import is consistent with the existing package space.
        if ((revision.getWiring() == null) || isDynamicImporting)
        {
            // Merge uses constraints from required capabilities.
            for (int i = 0; i < reqs.size(); i++)
            {
                BundleRequirement req = reqs.get(i);
                BundleCapability cap = caps.get(i);
                // Ignore bundle/package requirements, since they are
                // considered below.
                if (!req.getNamespace().equals(BundleRevision.BUNDLE_NAMESPACE)
                    && !req.getNamespace().equals(BundleRevision.PACKAGE_NAMESPACE))
                {
                    List<BundleRequirement> blameReqs = new ArrayList<BundleRequirement>();
                    blameReqs.add(req);

                    mergeUses(
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.