if (bf.getSymbolicName() == null) { // a regular jar nestedJARsDir = callback.handleJar(bf); } else { // an osgi bundle
@Override public int visitFile(File file) { // first check if this is a possible bundle String fileName = file.getName(); if (patterns != null) { if (!acceptFile(fileName, patterns)) { return FileWalker.CONTINUE; } } // check if this is an OSGi bundle try (JarFile jarFile = new JarFile(file)) { if (jarFile.getManifest() == null) { return FileWalker.CONTINUE; } BundleFile bundleFile = new JarBundleFile(jarFile); if (bundleFile.getSymbolicName() != null) { // notify the callback about the new bundle callback.visitBundle(bundleFile); } else { // notify the callback about the new jar callback.visitJar(bundleFile); } } catch (IOException e) { // ignore } return FileWalker.CONTINUE; }
public void visitNestedBundles(BundleFile bundleFile) throws IOException { if (bundleFile instanceof NestedJarBundleFile) { return; // do not allows more than one level of nesting } if (extractNestedJARs) { Collection<BundleFile> bundles; if (scanForNestedJARs) { bundles = bundleFile.findNestedBundles(tmpDir); } else { // use manifest to find nested jars bundles = bundleFile.getNestedBundles(tmpDir); } if (bundles == null || bundles.isEmpty()) { return; } for (BundleFile bundle : bundles) { if (bundle.getSymbolicName() != null) { visitBundle(bundle); } else { visitJar(bundle); } } } } }