private BundleContext getBundleContext ( Bundle bundle , long timeout ) { long endTime = System . currentTimeMillis ( ) + timeout ; BundleContext bc = null ; while ( bc == null ) { bc = bundle . getBundleContext ( ) ; if ( bc == null ) { if ( System . currentTimeMillis ( ) >= endTime ) { throw new TestContainerException ( "Unable to retrieve bundle context from bundle " + bundle ) ; } try { Thread . sleep ( 100 ) ; } catch ( InterruptedException e ) { // Ignore } } } return bc ; }
Retrieve bundle context from given bundle . If the bundle is being restarted the bundle context can be null for some time