public Bundle getBundle ( String symbolicName ) { final String sourceMethod = "getBundle" ; //$NON-NLS-1$ boolean isTraceLogging = log . isLoggable ( Level . FINER ) ; if ( isTraceLogging ) { log . entering ( FrameworkWiringBundleResolver . class . getName ( ) , sourceMethod , new Object [ ] { symbolicName } ) ; } Bundle [ ] candidates = Platform . getBundles ( symbolicName , null ) ; if ( isTraceLogging ) { log . finer ( "candidate bundles = " + Arrays . toString ( candidates ) ) ; //$NON-NLS-1$ } if ( candidates == null || candidates . length == 0 ) { if ( isTraceLogging ) { log . exiting ( FrameworkWiringBundleResolver . class . getName ( ) , sourceMethod , null ) ; } return null ; } if ( candidates . length == 1 ) { // Only one choice, so return it if ( isTraceLogging ) { log . exiting ( FrameworkWiringBundleResolver . class . getName ( ) , sourceMethod , candidates [ 0 ] ) ; } return candidates [ 0 ] ; } if ( fw == null ) { if ( isTraceLogging ) { log . finer ( "Framework wiring not available. Returning bundle with latest version" ) ; //$NON-NLS-1$ log . exiting ( FrameworkWiringBundleResolver . class . getName ( ) , sourceMethod , candidates [ 0 ] ) ; } return candidates [ 0 ] ; } Bundle result = null ; // For each candidate bundle, check to see if it's wired, directly or indirectly, to the contributing bundle for ( Bundle candidate : candidates ) { Collection < Bundle > bundles = fw . getDependencyClosure ( Arrays . asList ( new Bundle [ ] { candidate } ) ) ; for ( Bundle bundle : bundles ) { if ( bundle . equals ( contributingBundle ) ) { // found wired bundle. Return the candidate. result = candidate ; break ; } } if ( result != null ) { break ; } } if ( result == null ) { if ( isTraceLogging ) { log . finer ( "No wired bundle found amoung candidates. Returning bundle with most recent version." ) ; //$NON-NLS-1$ } result = candidates [ 0 ] ; } if ( isTraceLogging ) { log . exiting ( FrameworkWiringBundleResolver . class . getName ( ) , sourceMethod , result ) ; } return result ; }
Returns the bundle with the requested symbolic name that is wired to the contributing bundle or the bundle with the latest version if unable to determine wiring .