Package org.apache.felix.bundlerepository

Examples of org.apache.felix.bundlerepository.Requirement


        log.debug("Searching for fragments for {}", hostResource);
       
        DataModelHelper helper = repositoryAdmin.getHelper();
       
        String filter = "(&(host=" + hostResource.getSymbolicName() + "))";
        Requirement fragmentRequirement = helper.requirement(Capability.FRAGMENT, filter);
        Resource[] fragmentResources = repositoryAdmin.discoverResources(new Requirement[] { fragmentRequirement });
        if (fragmentResources != null && fragmentResources.length > 0) {

            if (log.isDebugEnabled()) {
                log.debug("Fragments found for {}: {}", new Object[] { hostResource, Arrays.asList(fragmentResources) } );               
            }
           
            List<Resource> candidateFragments = new ArrayList<Resource>();

            // trim out fragments that do not match the host
            for (Resource fragmentResource : fragmentResources) {
                Requirement fragmentHostRequirement = getFragmentHostRequirement(fragmentResource.getRequirements());
                if (fragmentHostRequirement == null) {
                    log.debug("Ignoring {} fragment. No host requirement found.", fragmentResource);
                    continue;
                }
                if (fragmentHostRequirement.isSatisfied(hostCapability)) {
                    candidateFragments.add(fragmentResource);
                }
            }

            int candiates = candidateFragments.size();
View Full Code Here


    Map<Requirement,Set<String>> req_resources = new HashMap<Requirement,Set<String>>();
    // add the reasons to the map, use the requirement as the key, the resources required the requirement as the values
    Set<Resource> resources = new HashSet<Resource>();
    for (Reason reason: reasons) {
      resources.add(reason.getResource());
      Requirement key = reason.getRequirement();
      String value = reason.getResource().getSymbolicName()+"_" + reason.getResource().getVersion().toString();
      Set<String> values = req_resources.get(key);
      if (values == null) {
        values = new HashSet<String>();
      }
      values.add(value);
      req_resources.put(key, values);
    }
   
    // remove the requirements that can be satisifed by the resources. It is listed because the resources are not satisfied by other requirements.
    // For an instance, the unsatisfied reasons are [package a, required by bundle aa], [package b, required by bundle bb] and [package c, required by bundle cc],
    // If the bundle aa exports the package a and c. In our error message, we only want to display package a is needed by bundle aa.
    // Go through each requirement and find out whether the requirement can be satisfied by the reasons.
    Set<Capability> caps = new HashSet<Capability>();
    for (Resource res : resources) {
      if ((res !=null) && (res.getCapabilities() != null)) {
       
      List<Capability> capList = Arrays.asList(res.getCapabilities());
      if (capList != null) {
      caps.addAll(capList);
      }
      }
    }
    Iterator<Map.Entry<Requirement, Set<String>>> iterator = req_resources.entrySet().iterator();
    while (iterator.hasNext()) {
      Map.Entry<Requirement, Set<String>> entry = iterator.next();
      Requirement req = entry.getKey();
      for (Capability cap :caps) {
        if (req.isSatisfied(cap)){ // remove the key from the map
          iterator.remove();
          break;
        }
      }
    }
View Full Code Here

    Map<Requirement,Set<String>> req_resources = new HashMap<Requirement,Set<String>>();
    // add the reasons to the map, use the requirement as the key, the resources required the requirement as the values
    Set<Resource> resources = new HashSet<Resource>();
    for (Reason reason: reasons) {
      resources.add(reason.getResource());
      Requirement key = reason.getRequirement();
      String value = reason.getResource().getSymbolicName()+"_" + reason.getResource().getVersion().toString();
      Set<String> values = req_resources.get(key);
      if (values == null) {
        values = new HashSet<String>();
      }
      values.add(value);
      req_resources.put(key, values);
    }
   
    // remove the requirements that can be satisifed by the resources. It is listed because the resources are not satisfied by other requirements.
    // For an instance, the unsatisfied reasons are [package a, required by bundle aa], [package b, required by bundle bb] and [package c, required by bundle cc],
    // If the bundle aa exports the package a and c. In our error message, we only want to display package a is needed by bundle aa.
    // Go through each requirement and find out whether the requirement can be satisfied by the reasons.
    Set<Capability> caps = new HashSet<Capability>();
    for (Resource res : resources) {
      if ((res !=null) && (res.getCapabilities() != null)) {
       
      List<Capability> capList = Arrays.asList(res.getCapabilities());
      if (capList != null) {
      caps.addAll(capList);
      }
      }
    }
    Iterator<Map.Entry<Requirement, Set<String>>> iterator = req_resources.entrySet().iterator();
    while (iterator.hasNext()) {
      Map.Entry<Requirement, Set<String>> entry = iterator.next();
      Requirement req = entry.getKey();
      for (Capability cap :caps) {
        if (req.isSatisfied(cap)){ // remove the key from the map
          iterator.remove();
          break;
        }
      }
    }
View Full Code Here

                URL url = new URL(bundleInfo.getLocation());
                Resource res = repositoryAdmin.getHelper().createResource(url);
                ress.add(res);
                infos.put(res, bundleInfo);
            } catch (MalformedURLException e) {
                Requirement req = parseRequirement(bundleInfo.getLocation());
                reqs.add(req);
                infos.put(req, bundleInfo);
            }
        }
View Full Code Here

        for (BundleInfo bundleInfo : feature.getBundles()) {
          URL url = null;
            try {
                url = new URL(bundleInfo.getLocation());
            } catch (MalformedURLException e) {
                Requirement req = parseRequirement(bundleInfo.getLocation());
                reqs.add(req);
                infos.put(req, bundleInfo);
            }
            if (url != null) {
              Resource res = repositoryAdmin.getHelper().createResource(url);
View Full Code Here

        for (BundleInfo bundleInfo : feature.getBundles()) {
          URL url = null;
            try {
                url = new URL(bundleInfo.getLocation());
            } catch (MalformedURLException e) {
                Requirement req = parseRequirement(bundleInfo.getLocation());
                reqs.add(req);
                infos.put(req, bundleInfo);
            }
            if (url != null) {
              Resource res = repositoryAdmin.getHelper().createResource(url);
View Full Code Here

        // add the reasons to the map, use the requirement as the key, the
        // resources required the requirement as the values
        Set<Resource> resources = new HashSet<Resource>();
        for (Reason reason : reasons) {
            resources.add(reason.getResource());
            Requirement key = reason.getRequirement();
            String value = reason.getResource().getSymbolicName() + "_" + reason.getResource().getVersion().toString();
            Set<String> values = req_resources.get(key);
            if (values == null) {
                values = new HashSet<String>();
            }
            values.add(value);
            req_resources.put(key, values);
        }

        // remove the requirements that can be satisifed by the resources. It is
        // listed because the resources are not satisfied by other requirements.
        // For an instance, the unsatisfied reasons are [package a, required by
        // bundle aa], [package b, required by bundle bb] and [package c,
        // required by bundle cc],
        // If the bundle aa exports the package a and c. In our error message,
        // we only want to display package a is needed by bundle aa.
        // Go through each requirement and find out whether the requirement can
        // be satisfied by the reasons.
        Set<Capability> caps = new HashSet<Capability>();
        for (Resource res : resources) {
            if ((res != null) && (res.getCapabilities() != null)) {
                List<Capability> capList = Arrays.asList(res.getCapabilities());
                if (capList != null) {
                    caps.addAll(capList);
                }
            }
        }

        Iterator<Map.Entry<Requirement, Set<String>>> iterator = req_resources.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry<Requirement, Set<String>> entry = iterator.next();
            Requirement req = entry.getKey();
            for (Capability cap : caps) {
                if (req.isSatisfied(cap)) { // remove the key from the map
                    iterator.remove();
                    break;
                }
            }
        }
View Full Code Here

        log.debug("Searching for fragments for {}", hostResource);
       
        DataModelHelper helper = repositoryAdmin.getHelper();
       
        String filter = "(&(host=" + hostResource.getSymbolicName() + "))";
        Requirement fragmentRequirement = helper.requirement(Capability.FRAGMENT, filter);
        Resource[] fragmentResources = repositoryAdmin.discoverResources(new Requirement[] { fragmentRequirement });
        if (fragmentResources != null && fragmentResources.length > 0) {

            if (log.isDebugEnabled()) {
                log.debug("Fragments found for {}: {}", new Object[] { hostResource, Arrays.asList(fragmentResources) } );               
            }
           
            List<Resource> candidateFragments = new ArrayList<Resource>();

            // trim out fragments that do not match the host
            for (Resource fragmentResource : fragmentResources) {
                Requirement fragmentHostRequirement = getFragmentHostRequirement(fragmentResource.getRequirements());
                if (fragmentHostRequirement == null) {
                    log.debug("Ignoring {} fragment. No host requirement found.", fragmentResource);
                    continue;
                }
                if (fragmentHostRequirement.isSatisfied(hostCapability)) {
                    candidateFragments.add(fragmentResource);
                }
            }

            int candiates = candidateFragments.size();
View Full Code Here

                URL url = new URL(bundleInfo.getLocation());
                Resource res = repositoryAdmin.getHelper().createResource(url);
                ress.add(res);
                infos.put(res, bundleInfo);
            } catch (MalformedURLException e) {
                Requirement req = parseRequirement(bundleInfo.getLocation());
                reqs.add(req);
                infos.put(req, bundleInfo);
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.felix.bundlerepository.Requirement

Copyright © 2018 www.massapicom. 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.