Package org.osgi.service.indexer

Examples of org.osgi.service.indexer.Resource


    assertEquals("META-INF/", children.get(0));
  }

  public void testJarFileContent() throws Exception {
    JarResource resource = new JarResource(new File("testdata/01-bsn+version.jar"));
    Resource pkgInfoResource = resource.getChild("org/example/a/packageinfo");

    assertEquals("version 1.0", Utils.readStream(pkgInfoResource.getStream()));
  }
View Full Code Here


  }

  public Manifest getManifest() throws IOException {
    synchronized (this) {
      if (manifest == null) {
        Resource manifestResource = getChild("META-INF/MANIFEST.MF");
        if (manifestResource != null) {
          try {
            manifest = new Manifest(manifestResource.getStream());
          } finally {
            manifestResource.close();
          }
        }
      }
      return manifest;
    }
View Full Code Here

      reqs.add(requirement);
    }
  }

  private Version processScrXml(Resource resource, String path, List<Capability> caps, List<Requirement> reqs) throws IOException {
    Resource childResource = resource.getChild(path);
    if (childResource == null) {
      if (log != null)
        log.log(LogService.LOG_WARNING,
            MessageFormat.format("Cannot analyse SCR requirement version: resource {0} does not contain path {1} referred from Service-Component header.",
                resource.getLocation(), path));
      return null;
    }

    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setNamespaceAware(true);

    try {
      SAXParser parser = spf.newSAXParser();
      SCRContentHandler handler = new SCRContentHandler(caps, reqs);
      parser.parse(childResource.getStream(), handler);

      return handler.highest;
    } catch (Exception e) {
      if (log != null)
        log.log(LogService.LOG_ERROR, MessageFormat.format("Processing error: failed to parse child resource {0} in resource {1}.", path, resource.getLocation()), e);
View Full Code Here

  }

  public Manifest getManifest() throws IOException {
    synchronized (this) {
      if (manifest == null) {
        Resource manifestResource = getChild("META-INF/MANIFEST.MF");
        if (manifestResource != null) {
          try {
            manifest = new Manifest(manifestResource.getStream());
          } finally {
            manifestResource.close();
          }
        }
      }
      return manifest;
    }
View Full Code Here

  public OSGiFrameworkAnalyzer(LogService log) {
    this.log = log;
  }

  public void analyzeResource(Resource resource, List<Capability> caps, List<Requirement> reqs) throws Exception {
    Resource fwkFactorySvc = resource.getChild(SERVICE_FRAMEWORK_FACTORY);
    if (fwkFactorySvc != null) {
      Builder builder = new Builder().setNamespace(Namespaces.NS_CONTRACT).addAttribute(Namespaces.NS_CONTRACT, Namespaces.CONTRACT_OSGI_FRAMEWORK);

      Version specVersion = null;
      StringBuilder uses = new StringBuilder();
View Full Code Here

      reqs.add(requirement);
    }
  }

  private Version processScrXml(Resource resource, String path) throws IOException {
    Resource childResource = resource.getChild(path);
    if (childResource == null) {
      if (log != null)
        log.log(LogService.LOG_WARNING,
            MessageFormat.format("Cannot analyse SCR requirement version: resource {0} does not contain path {1} referred from Service-Component header.",
                resource.getLocation(), path));
      return null;
    }

    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setNamespaceAware(true);

    try {
      SAXParser parser = spf.newSAXParser();
      SCRContentHandler handler = new SCRContentHandler();
      parser.parse(childResource.getStream(), handler);

      return handler.highest;
    } catch (Exception e) {
      if (log != null)
        log.log(LogService.LOG_ERROR, MessageFormat.format("Processing error: failed to parse child resource {0} in resource {1}.", path, resource.getLocation()), e);
View Full Code Here

TOP

Related Classes of org.osgi.service.indexer.Resource

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.