Exemplo n.º 1
0
  private void addBundleClasspathEntries(Set<String> entries, Bundle bundle) {
    log.debug("addBundleClasspathEntries(Bundle={})", bundle.toString());

    Set<String> cp = new LinkedHashSet<String>();
    if (DevClassPathHelper.inDevelopmentMode()) {
      cp.addAll(Arrays.asList(DevClassPathHelper.getDevClassPath(bundle.getSymbolicName())));
    }
    cp.addAll(Arrays.asList(parseBundleClasspath(bundle)));
    for (String cpe : cp) {
      String entry;
      if (".".equals(cpe)) {
        entry = getNestedJarOrDir(bundle, "/");
      } else {
        entry = getNestedJarOrDir(bundle, cpe);
      }

      if (entry != null) {
        log.debug("\tEntry:{}", entry);
        entries.add(entry);
      }
    }
  }
Exemplo n.º 2
0
  private String getNestedJarOrDir(Bundle bundle, String cp) {
    // try embeded entries first
    URL url = bundle.getEntry(cp);
    if (url != null) {
      try {
        return FileLocator.toFileURL(url).getFile();
      } catch (IOException ex) {
        log.warn("Could not get entry {} for bundle {}", new Object[] {cp, bundle.toString(), ex});
      }
    }

    // in development mode entries can be absolute paths outside of bundle basedir
    if (DevClassPathHelper.inDevelopmentMode()) {
      File file = new File(cp);
      if (file.exists() && file.isAbsolute()) {
        return file.getAbsolutePath();
      }
    }

    log.debug("Bundle {} does not have entry {}", bundle.toString(), cp);
    return null;
  }