Examples of CapabilitySet


Examples of org.apache.felix.framework.capabilityset.CapabilitySet

     */
  public synchronized SortedSet<BundleCapability> getCandidates(BundleRequirement req, boolean obeyMandatory) {
//    BundleRevision reqRevision = req.getRevision();
    SortedSet<BundleCapability> result = new TreeSet<BundleCapability>(new CandidateComparator());

    CapabilitySet capSet = m_capSets.get(req.getNamespace());
    if (capSet != null) {
      // Get the requirement's filter; if this is our own impl we
      // have a shortcut to get the already parsed filter, otherwise
      // we must parse it from the directive.
      SimpleFilter sf = null;
      if (req instanceof BundleRequirementImpl) {
        sf = ((BundleRequirementImpl) req).getFilter();
      } else {
        String filter = req.getDirectives().get(
            Constants.FILTER_DIRECTIVE);
        if (filter == null) {
          sf = new SimpleFilter(null, null, SimpleFilter.MATCH_ALL);
        } else {
          sf = SimpleFilter.parse(filter);
        }
      }

      // Find the matching candidates.
      Set<BundleCapability> matches = capSet.match(sf, obeyMandatory);
      for (BundleCapability cap : matches) {
        /* TODO: karl - is this correct?
         * if (System.getSecurityManager() != null) {
          if (req.getNamespace().equals(
              BundleRevision.PACKAGE_NAMESPACE)
View Full Code Here

Examples of org.apache.felix.framework.capabilityset.CapabilitySet

        m_fwkExecEnvStr = (fwkExecEnvStr != null) ? fwkExecEnvStr.trim() : null;
        m_fwkExecEnvSet = parseExecutionEnvironments(fwkExecEnvStr);

        List<String> indices = new ArrayList<String>();
        indices.add(BundleRevision.BUNDLE_NAMESPACE);
        m_capSets.put(BundleRevision.BUNDLE_NAMESPACE, new CapabilitySet(indices, true));

        indices = new ArrayList<String>();
        indices.add(BundleRevision.PACKAGE_NAMESPACE);
        m_capSets.put(BundleRevision.PACKAGE_NAMESPACE, new CapabilitySet(indices, true));

        indices = new ArrayList<String>();
        indices.add(BundleRevision.HOST_NAMESPACE);
        m_capSets.put(BundleRevision.HOST_NAMESPACE,  new CapabilitySet(indices, true));
    }
View Full Code Here

Examples of org.apache.felix.framework.capabilityset.CapabilitySet

    synchronized List<BundleCapability> findProvidersInternal(
        ResolverHookRecord record, BundleRequirement req, boolean obeyMandatory)
    {
        List<BundleCapability> result = new ArrayList<BundleCapability>();

        CapabilitySet capSet = m_capSets.get(req.getNamespace());
        if (capSet != null)
        {
            // Get the requirement's filter; if this is our own impl we
            // have a shortcut to get the already parsed filter, otherwise
            // we must parse it from the directive.
            SimpleFilter sf;
            if (req instanceof BundleRequirementImpl)
            {
                sf = ((BundleRequirementImpl) req).getFilter();
            }
            else
            {
                String filter = req.getDirectives().get(Constants.FILTER_DIRECTIVE);
                if (filter == null)
                {
                    sf = new SimpleFilter(null, null, SimpleFilter.MATCH_ALL);
                }
                else
                {
                    sf = SimpleFilter.parse(filter);
                }
            }

            // Find the matching candidates.
            Set<BundleCapability> matches = capSet.match(sf, obeyMandatory);
            // Filter matching candidates.
            for (BundleCapability cap : matches)
            {
                // Filter according to security.
                if (filteredBySecurity(req, cap))
View Full Code Here

Examples of org.apache.felix.framework.capabilityset.CapabilitySet

                // In that case, the fragment capability is still indexed.
                // It will be the resolver's responsibility to find all
                // attached hosts for fragments.
                if (cap.getRevision() == br)
                {
                    CapabilitySet capSet = m_capSets.get(cap.getNamespace());
                    if (capSet == null)
                    {
                        capSet = new CapabilitySet(null, true);
                        m_capSets.put(cap.getNamespace(), capSet);
                    }
                    capSet.addCapability(cap);
                }
            }
        }
    }
View Full Code Here

Examples of org.apache.felix.framework.capabilityset.CapabilitySet

        List<BundleCapability> caps = br.getDeclaredCapabilities(null);
        if (caps != null)
        {
            for (BundleCapability cap : caps)
            {
                CapabilitySet capSet = m_capSets.get(cap.getNamespace());
                if (capSet != null)
                {
                    capSet.removeCapability(cap);
                }
            }
        }
    }
View Full Code Here

Examples of org.apache.felix.framework.capabilityset.CapabilitySet

        m_logger = logger;
        m_callbacks = callbacks;

        List indices = new ArrayList();
        indices.add(Constants.OBJECTCLASS);
        m_regCapSet = new CapabilitySet(indices, false);
    }
View Full Code Here

Examples of org.apache.karaf.features.internal.resolver.CapabilitySet

        for (Resource r : resources) {
            for (Capability cap : r.getCapabilities(null)) {
                namespaces.add(cap.getNamespace());
            }
        }
        CapabilitySet capSet = new CapabilitySet(new ArrayList<String>(namespaces));
        for (Resource r : resources) {
            for (Capability cap : r.getCapabilities(null)) {
                capSet.addCapability(cap);
            }
        }
        Set<T> sorted = new LinkedHashSet<T>();
        Set<T> visited = new LinkedHashSet<T>();
        for (T r : resources) {
View Full Code Here

Examples of org.apache.karaf.features.internal.resolver.CapabilitySet

            super.addResource(resource);
        }
    }

    private boolean hasResource(String type, String name, Version version) {
        CapabilitySet set = capSets.get(IDENTITY_NAMESPACE);
        if (set != null) {
            Map<String, Object> attrs = new HashMap<String, Object>();
            attrs.put(CAPABILITY_TYPE_ATTRIBUTE, type);
            attrs.put(IDENTITY_NAMESPACE, name);
            attrs.put(CAPABILITY_VERSION_ATTRIBUTE, version);
            SimpleFilter sf = SimpleFilter.convert(attrs);
            return !set.match(sf, true).isEmpty();
        } else {
            return false;
        }
    }
View Full Code Here

Examples of org.apache.karaf.features.internal.resolver.CapabilitySet

    }

    protected void addResource(Resource resource) {
        for (Capability cap : resource.getCapabilities(null)) {
            String ns = cap.getNamespace();
            CapabilitySet set = capSets.get(ns);
            if (set == null) {
                set = new CapabilitySet(Collections.singletonList(ns));
                capSets.put(ns, set);
            }
            set.addCapability(cap);
        }
        resources.add(resource);
    }
View Full Code Here

Examples of org.apache.karaf.features.internal.resolver.CapabilitySet

    @Override
    public Map<Requirement, Collection<Capability>> findProviders(Collection<? extends Requirement> requirements) {
        Map<Requirement, Collection<Capability>> result = new HashMap<Requirement, Collection<Capability>>();
        for (Requirement requirement : requirements) {
            CapabilitySet set = capSets.get(requirement.getNamespace());
            if (set != null) {
                SimpleFilter sf;
                if (requirement instanceof RequirementImpl) {
                    sf = ((RequirementImpl) requirement).getFilter();
                } else {
                    String filter = requirement.getDirectives().get(Constants.FILTER_DIRECTIVE);
                    sf = (filter != null)
                            ? SimpleFilter.parse(filter)
                            : new SimpleFilter(null, null, SimpleFilter.MATCH_ALL);
                }
                result.put(requirement, set.match(sf, true));
            } else {
                result.put(requirement, Collections.<Capability>emptyList());
            }
        }
        return result;
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.