String determineCachingName ( final File file , final String defaultBundleSymbolicName ) { String bundleSymbolicName = null ; String bundleVersion = null ; JarFile jar = null ; try { // verify that is a valid jar. Do not verify that is signed (the false param). jar = new JarFile ( file , false ) ; final Manifest manifest = jar . getManifest ( ) ; if ( manifest != null ) { bundleSymbolicName = manifest . getMainAttributes ( ) . getValue ( Constants . BUNDLE_SYMBOLICNAME ) ; bundleVersion = manifest . getMainAttributes ( ) . getValue ( Constants . BUNDLE_VERSION ) ; } } catch ( IOException ignore ) { // just ignore } finally { if ( jar != null ) { try { jar . close ( ) ; } catch ( IOException ignore ) { // just ignore as this is less probably to happen. } } } if ( bundleSymbolicName == null ) { bundleSymbolicName = defaultBundleSymbolicName ; } else { // remove directives like "; singleton:=true" int semicolonPos = bundleSymbolicName . indexOf ( ";" ) ; if ( semicolonPos > 0 ) { bundleSymbolicName = bundleSymbolicName . substring ( 0 , semicolonPos ) ; } } if ( bundleVersion == null ) { bundleVersion = "0.0.0" ; } return bundleSymbolicName + "_" + bundleVersion + ".jar" ; }
Determine name to be used for caching on local file system .