Examples of BundleCapability


Examples of org.osgi.framework.wiring.BundleCapability

        // Populate the candidates for the dynamic import.
        ResolveException rethrow = null;
        for (Iterator<BundleCapability> itCandCap = candidates.iterator();
            itCandCap.hasNext(); )
        {
            BundleCapability candCap = itCandCap.next();
            if (candCap.getRevision().getWiring() == null)
            {
                try
                {
                    populateRevision(state, candCap.getRevision());
                }
                catch (ResolveException ex)
                {
                    if (rethrow == null)
                    {
View Full Code Here

Examples of org.osgi.framework.wiring.BundleCapability

        List<BundleRevision> unselectedFragments = new ArrayList<BundleRevision>();
        for (Entry<BundleCapability, Map<String, Map<Version, List<BundleRequirement>>>>
            hostEntry : m_hostFragments.entrySet())
        {
            // Step 1
            BundleCapability hostCap = hostEntry.getKey();
            Map<String, Map<Version, List<BundleRequirement>>> fragments
                = hostEntry.getValue();
            List<BundleRevision> selectedFragments = new ArrayList<BundleRevision>();
            for (Entry<String, Map<Version, List<BundleRequirement>>> fragEntry
                : fragments.entrySet())
            {
                boolean isFirst = true;
                for (Entry<Version, List<BundleRequirement>> versionEntry
                    : fragEntry.getValue().entrySet())
                {
                    for (BundleRequirement hostReq : versionEntry.getValue())
                    {
                        // Select the highest version of the fragment that
                        // is not removal pending.
                        if (isFirst
                            ) // TODO: karl - is this correct? && !((BundleRevisionImpl) hostReq.getRevision()).isRemovalPending())
                        {
                            selectedFragments.add(hostReq.getRevision());
                            isFirst = false;
                        }
                        // For any fragment that wasn't selected, remove the
                        // current host as a potential host for it and remove it
                        // as a dependent on the host. If there are no more
                        // potential hosts for the fragment, then mark it as
                        // unselected for later removal.
                        else
                        {
                            m_dependentMap.get(hostCap).remove(hostReq);
                            SortedSet<BundleCapability> hosts = m_candidateMap.get(hostReq);
                            hosts.remove(hostCap);
                            if (hosts.isEmpty())
                            {
                                unselectedFragments.add(hostReq.getRevision());
                            }
                        }
                    }
                }
            }

            // Step 2
            HostBundleRevision wrappedHost =
                new HostBundleRevision(hostCap.getRevision(), selectedFragments);
            hostRevisions.add(wrappedHost);
            m_allWrappedHosts.put(hostCap.getRevision(), wrappedHost);
        }

        // Step 3
        for (BundleRevision br : unselectedFragments)
        {
            removeRevision(br,
                new ResolveException(
                    "Fragment was not selected for attachment.", br, null));
        }

        // Step 4
        for (HostBundleRevision hostRevision : hostRevisions)
        {
            // Replaces capabilities from fragments with the capabilities
            // from the merged host.
            for (BundleCapability c : hostRevision.getDeclaredCapabilities(null))
            {
                // Don't replace the host capability, since the fragment will
                // really be attached to the original host, not the wrapper.
                if (!c.getNamespace().equals(BundleRevision.HOST_NAMESPACE))
                {
                    BundleCapability origCap =
                        ((HostedCapability) c).getOriginalCapability();
                    // Note that you might think we could remove the original cap
                    // from the dependent map, but you can't since it may come from
                    // a fragment that is attached to multiple hosts, so each host
                    // will need to make their own copy.
View Full Code Here

Examples of org.osgi.framework.wiring.BundleCapability

        List<BundleCapability> aliasCaps = new ArrayList<BundleCapability>(capabilities);

        for (int capIdx = 0; capIdx < aliasCaps.size(); capIdx++)
        {
            BundleCapability capability = aliasCaps.get(capIdx);
           
            // Get the attributes and search for bundle symbolic name.
            Map<String, Object> attributes = capability.getAttributes();
           
            for (Entry<String, Object> entry : attributes.entrySet())
            {
                // If there is a bundle symbolic name attribute, add the
                // standard alias as a value.
                if (Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE.equalsIgnoreCase(entry.getKey()))
                {
                    // Make a copy of the attribute array.
                    Map<String, Object> aliasAttrs = new HashMap<String, Object>(attributes);
                    // Add the aliased value.
                    aliasAttrs.put(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE, new String[] { (String) entry.getValue(), Constants.SYSTEM_BUNDLE_SYMBOLICNAME });
                    // Create the aliased capability to replace the old capability.
                    aliasCaps.set(capIdx, new BundleCapabilityImpl(capability.getRevision(), capability.getNamespace(), capability.getDirectives(), aliasAttrs));
                    // Continue with the next capability.
                    break;
                }
            }
        }
View Full Code Here

Examples of org.osgi.framework.wiring.BundleCapability

            }
            else
            {
                for (Iterator<BundleCapability> it = caps.iterator(); it.hasNext(); )
                {
                    BundleCapability cap = it.next();
                    Object lhs = cap.getAttributes().get(sf.getName());
                    if (lhs != null)
                    {
                        if (compare(lhs, sf.getValue(), sf.getOperation()))
                        {
                            matches.add(cap);
View Full Code Here

Examples of org.osgi.framework.wiring.BundleCapability

    private static Set<BundleCapability> matchMandatory(
        Set<BundleCapability> caps, SimpleFilter sf)
    {
        for (Iterator<BundleCapability> it = caps.iterator(); it.hasNext(); )
        {
            BundleCapability cap = it.next();
            if (!matchMandatory(cap, sf))
            {
                it.remove();
            }
        }
View Full Code Here

Examples of org.osgi.framework.wiring.BundleCapability

                BundleWiring wiring = bundle.adapt(BundleWiring.class);
                BundleWire reqwire = null;
                if (wiring != null) {
                    for (BundleWire wire : wiring.getRequiredWires(PackageNamespace.PACKAGE_NAMESPACE)) {
                        if (req.equals(wire.getRequirement())) {
                            BundleCapability cap = wire.getCapability();
                            BundleRevision provider = wire.getProvider();
                            LOGGER.debug("Optional requirement {} from {} wires to capability {} provided by {}", req, bundle, cap, provider);
                            reqwire = wire;
                            break;
                        }
View Full Code Here

Examples of org.osgi.framework.wiring.BundleCapability

    }

    private static CompositeData[] getCapabilities(List<BundleCapability> capabilityList) throws OpenDataException {
        CompositeData[] capData = new CompositeData[capabilityList.size()];
        for (int i=0; i < capabilityList.size(); i++) {
            BundleCapability capability = capabilityList.get(i);
            capData[i] = getCapReqCompositeData(BundleWiringStateMBean.BUNDLE_CAPABILITY_TYPE,
                capability.getNamespace(), capability.getAttributes().entrySet(), capability.getDirectives().entrySet());
        }
        return capData;
    }
View Full Code Here

Examples of org.osgi.framework.wiring.BundleCapability

    public static CompositeData[] getCapabilitiesCompositeData(List<BundleCapability> bundleCapabilities) {
        try {
            CompositeData[] data = new CompositeData[bundleCapabilities.size()];

            for (int i=0; i < bundleCapabilities.size(); i++) {
                BundleCapability requirement = bundleCapabilities.get(i);

                CompositeData cd = BundleWiringData.getCapReqCompositeData(BundleWiringStateMBean.BUNDLE_CAPABILITY_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.BundleCapability

        CompositeData[] reqWiresData = new CompositeData[wires.size()];
        for (int i=0; i < wires.size(); i++) {
            BundleWire requiredWire = wires.get(i);
            Map<String, Object> wireItems = new HashMap<String, Object>();

            BundleCapability capability = requiredWire.getCapability();
            wireItems.put(BundleWiringStateMBean.PROVIDER_BUNDLE_ID, capability.getRevision().getBundle().getBundleId());
            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()));
View Full Code Here

Examples of org.osgi.framework.wiring.BundleCapability

            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.