private static void addBundleManifestRequireCapability(FileSystem zipSystem,
                                                           Path bundle,
                                                           Map<Path, String> requiresMap) throws IOException {

        Path extractedJar = null;
        try {
            // Need to extract the bundles to read their manifest, can't find a way to do this in place.
            extractedJar = Files.createTempFile("unpackedBundle", ".jar");
            extractedJar.toFile().deleteOnExit();
            Files.copy(bundle, extractedJar, StandardCopyOption.REPLACE_EXISTING);

            Manifest bundleJarManifest = null;
            JarFile bundleJar = null;
            try {
                bundleJar = new JarFile(extractedJar.toFile());
                bundleJarManifest = bundleJar.getManifest();
            } finally {
                if (bundleJar != null) {
                    bundleJar.close();
                }
            }

            Attributes bundleManifestAttrs = bundleJarManifest.getMainAttributes();
            String requireCapabilityAttr = bundleManifestAttrs.getValue(REQUIRE_CAPABILITY_HEADER_NAME);
            if (requireCapabilityAttr != null) {
                requiresMap.put(bundle, requireCapabilityAttr);
            }

        } finally {
            if (extractedJar != null) {
                extractedJar.toFile().delete();
            }
        }
    }
private static void addBundleManifestRequireCapability ( FileSystem zipSystem , Path bundle , Map < Path , String > requiresMap ) throws IOException { Path extractedJar = null ; try { extractedJar = Files . createTempFile ( "unpackedBundle" , ".jar" ) ; extractedJar . toFile ( ) . deleteOnExit ( ) ; Files . copy ( bundle , extractedJar , StandardCopyOption . REPLACE_EXISTING ) ; Manifest bundleJarManifest = null ; JarFile bundleJar = null ; try { bundleJar = new JarFile ( extractedJar . toFile ( ) ) ; bundleJarManifest = bundleJar . getManifest ( ) ; } finally { if ( bundleJar != null ) { bundleJar . close ( ) ; } } Attributes bundleManifestAttrs = bundleJarManifest . getMainAttributes ( ) ; String requireCapabilityAttr = bundleManifestAttrs . getValue ( REQUIRE_CAPABILITY_HEADER_NAME ) ; if ( requireCapabilityAttr != null ) { requiresMap . put ( bundle , requireCapabilityAttr ) ; } } finally { if ( extractedJar != null ) { extractedJar . toFile ( ) . delete ( ) ; } } }
Adds the Require-Capability Strings from a bundle jar to the Map of
Require-Capabilities found

@param zipSystem - the FileSystem mapping to the feature containing this bundle
@param bundle - the bundle within a zipped up feature
@param requiresMap - Map of Path to Require-Capability
@throws IOException