Package org.apache.felix.bundlerepository

Examples of org.apache.felix.bundlerepository.Requirement


                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


                    if (capability != null)
                        resource.addCapability(capability);
                }
                else if (REQUIREMENT.equals(element))
                {
                    Requirement requirement = parseRequirement(reader);
                    resource.addRequire(requirement);
                }
                else
                {
                    PullParser.ignoreTag(reader);
View Full Code Here

                Capability cap = (Capability) iter.next();
                fake.addCapability(cap);
            }
            for (Iterator iter = m_addedRequirementSet.iterator(); iter.hasNext();)
            {
                Requirement req = (Requirement) iter.next();
                fake.addRequire(req);
            }
            if (!resolve(fake, locals, remotes, false))
            {
                result = false;
View Full Code Here

        {
            return true;
        }
        if (o instanceof Requirement)
        {
            Requirement r = (Requirement) o;
            return m_name.equals(r.getName()) &&
                (m_optional == r.isOptional()) &&
                (m_multiple == r.isMultiple()) &&
                m_filter.toString().equals(r.getFilter()) &&
                ((m_comment == r.getComment()) ||
                    ((m_comment != null) && (m_comment.equals(r.getComment()))));
        }
        return false;
    }
View Full Code Here

import org.osgi.resource.Resource;

public class FelixRequirementAdapterTest {
  @Test
  public void testCardinalityDirectiveMultiple() {
    Requirement req = EasyMock.createNiceMock(Requirement.class);
    EasyMock.expect(req.getFilter()).andReturn("");
    EasyMock.expect(req.isMultiple()).andReturn(true);
    EasyMock.replay(req);
    FelixRequirementAdapter adapter = new FelixRequirementAdapter(req, EasyMock.createNiceMock(Resource.class));
    assertEquals("Wrong value for directive " + Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE, Namespace.CARDINALITY_MULTIPLE, adapter.getDirectives().get(Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE));
  }
View Full Code Here

    assertEquals("Wrong value for directive " + Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE, Namespace.CARDINALITY_MULTIPLE, adapter.getDirectives().get(Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE));
  }
 
  @Test
  public void testCardinalityDirectiveSingle() {
    Requirement req = EasyMock.createNiceMock(Requirement.class);
    EasyMock.expect(req.getFilter()).andReturn("");
    EasyMock.expect(req.isMultiple()).andReturn(false);
    EasyMock.replay(req);
    FelixRequirementAdapter adapter = new FelixRequirementAdapter(req, EasyMock.createNiceMock(Resource.class));
    assertEquals("Wrong value for directive " + Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE, Namespace.CARDINALITY_SINGLE, adapter.getDirectives().get(Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE));
  }
View Full Code Here

    assertEquals("Wrong value for directive " + Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE, Namespace.CARDINALITY_SINGLE, adapter.getDirectives().get(Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE));
  }
 
  @Test
  public void testResolutionDirectiveMandatory() {
    Requirement req = EasyMock.createNiceMock(Requirement.class);
    EasyMock.expect(req.getFilter()).andReturn("");
    EasyMock.expect(req.isOptional()).andReturn(false);
    EasyMock.replay(req);
    FelixRequirementAdapter adapter = new FelixRequirementAdapter(req, EasyMock.createNiceMock(Resource.class));
    assertEquals("Wrong value for directive " + Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE, Namespace.RESOLUTION_MANDATORY, adapter.getDirectives().get(Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE));
  }
View Full Code Here

    assertEquals("Wrong value for directive " + Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE, Namespace.RESOLUTION_MANDATORY, adapter.getDirectives().get(Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE));
  }
 
  @Test
  public void testResolutionDirectiveOptional() {
    Requirement req = EasyMock.createNiceMock(Requirement.class);
    EasyMock.expect(req.getFilter()).andReturn("");
    EasyMock.expect(req.isOptional()).andReturn(true);
    EasyMock.replay(req);
    FelixRequirementAdapter adapter = new FelixRequirementAdapter(req, EasyMock.createNiceMock(Resource.class));
    assertEquals("Wrong value for directive " + Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE, Namespace.RESOLUTION_OPTIONAL, adapter.getDirectives().get(Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE));
  }
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

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.