public void waitForBundlesActivation ( CloseableHttpClient httpClient ) { if ( StringUtils . isBlank ( props . getBundleStatusUrl ( ) ) ) { log . debug ( "Skipping check for bundle activation state because no bundleStatusURL is defined." ) ; return ; } final int WAIT_INTERVAL_SEC = 3 ; final long CHECK_RETRY_COUNT = props . getBundleStatusWaitLimitSec ( ) / WAIT_INTERVAL_SEC ; log . info ( "Check bundle activation status..." ) ; for ( int i = 1 ; i <= CHECK_RETRY_COUNT ; i ++ ) { BundleStatusCall call = new BundleStatusCall ( httpClient , props . getBundleStatusUrl ( ) , log ) ; BundleStatus bundleStatus = executeHttpCallWithRetry ( call , 0 ) ; boolean instanceReady = true ; // check if bundles are still stopping/staring if ( ! bundleStatus . isAllBundlesRunning ( ) ) { log . info ( "Bundles starting/stopping: " + bundleStatus . getStatusLineCompact ( ) + " - wait " + WAIT_INTERVAL_SEC + " sec " + "(max. " + props . getBundleStatusWaitLimitSec ( ) + " sec) ..." ) ; sleep ( WAIT_INTERVAL_SEC ) ; instanceReady = false ; } // check if any of the blacklisted bundles is still present if ( instanceReady ) { for ( Pattern blacklistBundleNamePattern : props . getBundleStatusBlacklistBundleNames ( ) ) { String bundleSymbolicName = bundleStatus . getMatchingBundle ( blacklistBundleNamePattern ) ; if ( bundleSymbolicName != null ) { log . info ( "Bundle '" + bundleSymbolicName + "' is still deployed " + " - wait " + WAIT_INTERVAL_SEC + " sec " + "(max. " + props . getBundleStatusWaitLimitSec ( ) + " sec) ..." ) ; sleep ( WAIT_INTERVAL_SEC ) ; instanceReady = false ; break ; } } } // instance is ready if ( instanceReady ) { break ; } } }
Wait for bundles to become active .