Package org.osgi.resource

Examples of org.osgi.resource.Capability


    assertFalse("Capability should not match requirement", ResourceHelper.matches(req, cap));
  }
 
  @Test
  public void testMandatoryDirectiveCaseSensitive() {
    Capability cap = new BasicCapability.Builder()
        .namespace(PackageNamespace.PACKAGE_NAMESPACE)
        .attribute(PackageNamespace.PACKAGE_NAMESPACE, "com.foo")
        .attribute("a", "b")
        .attribute("bAr", "c")
        .attribute("c", "d")
View Full Code Here


    assertFalse("Capability should not match requirement", ResourceHelper.matches(req, cap));
  }
 
  @Test
  public void testMandatoryDirectiveExportPackageFail() {
    Capability cap = new BasicCapability.Builder()
        .namespace(PackageNamespace.PACKAGE_NAMESPACE)
        .attribute(PackageNamespace.PACKAGE_NAMESPACE, "com.foo")
        .attribute("a", "b")
        .attribute("b", "c")
        .attribute("c", "d")
View Full Code Here

    assertFalse("Capability should not match requirement", ResourceHelper.matches(req, cap));
  }
 
  @Test
  public void testMandatoryDirectiveExportPackagePass() {
    Capability cap = new BasicCapability.Builder()
        .namespace(PackageNamespace.PACKAGE_NAMESPACE)
        .attribute(PackageNamespace.PACKAGE_NAMESPACE, "com.foo")
        .attribute("a", "b")
        .attribute("b", "c")
        .attribute("c", "d")
View Full Code Here

    assertTrue("Capability should match requirement", ResourceHelper.matches(req, cap));
  }
 
  @Test
  public void testMandatoryDirectiveWithWhitespace() {
    Capability cap = new BasicCapability.Builder()
        .namespace(PackageNamespace.PACKAGE_NAMESPACE)
        .attribute(PackageNamespace.PACKAGE_NAMESPACE, "com.foo")
        .attribute("a", "b")
        .attribute("b", "c")
        .attribute("c", "d")
View Full Code Here

  public boolean equals(Object o) {
    if (o == this)
      return true;
    if (!(o instanceof Capability))
      return false;
    Capability c = (Capability)o;
    return c.getNamespace().equals(getNamespace())
        && c.getAttributes().equals(getAttributes())
        && c.getDirectives().equals(getDirectives())
        && c.getResource().equals(getResource());
  }
View Full Code Here

  }
 
  public List<Capability> getCapabilities(String namespace) {
    namespace = NamespaceTranslator.translate(namespace);
    if (namespace == null || namespace.equals(IdentityNamespace.IDENTITY_NAMESPACE)) {
      Capability c = new OsgiIdentityCapability(this, resource.getSymbolicName(), resource.getVersion());
      return Collections.singletonList(c);
    }
    // TODO Add to constants.
    if (namespace.equals("osgi.content")) {
      Capability c = new OsgiContentCapability(this, resource.getURI());
      return Collections.singletonList(c);
    }
    org.apache.felix.bundlerepository.Capability[] capabilities = resource.getCapabilities();
    ArrayList<Capability> result = new ArrayList<Capability>(capabilities.length);
    for (org.apache.felix.bundlerepository.Capability capability : capabilities) {
View Full Code Here

    return result;
  }
 
  @Override
  public String toString() {
    Capability c = getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE)
        .iterator().next();
    Map<String, Object> atts = c.getAttributes();
    return new StringBuilder()
        .append(atts.get(IdentityNamespace.IDENTITY_NAMESPACE))
        .append(';')
        .append(atts
            .get(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE))
View Full Code Here

  }
 
  public static Object getContentAttribute(Resource resource, String name) {
    // TODO Add to constants.
    List<Capability> capabilities = resource.getCapabilities("osgi.content");
    Capability capability = capabilities.get(0);
    return capability.getAttributes().get(name);
  }
View Full Code Here

    return capability.getAttributes().get(name);
  }
 
  public static Object getIdentityAttribute(Resource resource, String name) {
    List<Capability> capabilities = resource.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE);
    Capability capability = capabilities.get(0);
    return capability.getAttributes().get(name);
  }
View Full Code Here

        }
        // Get candidates hosts and keep any that have been populated.
        List<Capability> hosts = rc.findProviders(hostReq);
        for (Iterator<Capability> it = hosts.iterator(); it.hasNext(); )
        {
            Capability host = it.next();
            if (!isPopulated(host.getResource()))
            {
                it.remove();
            }
        }
        // If there aren't any populated hosts, then we can just
View Full Code Here

TOP

Related Classes of org.osgi.resource.Capability

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.