public static URL [ ] getClassPathJars ( final Bundle bundle ) { final List < URL > urls = new ArrayList <> ( ) ; final String bundleClasspath = ( String ) bundle . getHeaders ( ) . get ( "Bundle-ClassPath" ) ; if ( bundleClasspath != null ) { String [ ] segments = bundleClasspath . split ( "," ) ; for ( String segment : segments ) { final URL url = bundle . getEntry ( segment ) ; if ( url != null ) { if ( url . toExternalForm ( ) . endsWith ( "jar" ) ) { LOG . debug ( "Using url: " + url ) ; try { URL jarUrl = new URL ( "jar:" + url . toExternalForm ( ) + "!/" ) ; urls . add ( jarUrl ) ; } catch ( MalformedURLException ignore ) { LOG . debug ( ignore . getMessage ( ) ) ; } } } } } LOG . debug ( "Bundle-ClassPath URLs: " + urls ) ; // adds the depending bundles to the "classloader" space urls . addAll ( getLocationsOfBundlesInClassSpace ( bundle ) ) ; return urls . toArray ( new URL [ urls . size ( ) ] ) ; }
Returns a list of urls to jars that composes the Bundle - ClassPath .