public static Manifest getManifest(File file) { try { if (file.isDirectory()) { return getDirectoryManifest(file); } else { return getJarManifest(file); } } catch (IOException ignored) { return null; } }
@Override public String getOSGIBundleName(File file) { Manifest mf = JarUtils.getManifest(file); if (mf == null) { return null; } String bundleName = mf.getMainAttributes().getValue("Bundle-SymbolicName"); if (bundleName == null) { return null; } int index = bundleName.indexOf(';'); if (index > -1) { bundleName = bundleName.substring(0, index); } return bundleName; }
@Override public int visitDirectory(File file) { // System.out.println("###### Processing DIR: " + 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 { Manifest mf = JarUtils.getDirectoryManifest(file); if (mf == null) { return FileWalker.CONTINUE; } String bundleName = mf.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME); if (bundleName != null) { // notify the callback about the new bundle callback.visitBundle(new DirectoryBundleFile(file, mf)); // assume that a directory OSGi bundle cannot contain other bundles so skip it return FileWalker.BREAK; } } catch (IOException e) { log.error(e, e); } return FileWalker.CONTINUE; }
URI uri = toJarURI(target);
if (Files.isDirectory(bundlePath)) { bundlePath = JarUtils.zipDirectory(bundlePath, destinationPath.resolve("hotreload-bundle-" + System.currentTimeMillis() + ".jar"), StandardCopyOption.REPLACE_EXISTING);
public static Dictionary<String, String> getHeadersFromFile(File file) { Manifest mf = JarUtils.getManifest(file); if (mf != null) { try { return getHeaders(mf); } catch (BundleException e) { log.error(e, e); } } // not an osgi bundle return getDefaultHeaders(file.getAbsolutePath()); }
public static Dictionary<String, String> getHeadersFromJar(URL url) { Manifest mf = JarUtils.getManifest(url); if (mf != null) { try { return getHeaders(mf); } catch (BundleException e) { log.error(e, e); } } // not an osgi bundle return getDefaultHeaders(url.toExternalForm()); }