private static void waitForService ( final ServiceController < ? > controller ) throws OperationFailedException { if ( controller . getState ( ) == ServiceController . State . UP ) return ; final StabilityMonitor monitor = new StabilityMonitor ( ) ; monitor . addController ( controller ) ; try { monitor . awaitStability ( 100 , MILLISECONDS ) ; } catch ( final InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; throw SecurityLogger . ROOT_LOGGER . interruptedWaitingForSecurityDomain ( controller . getName ( ) . getSimpleName ( ) ) ; } finally { monitor . removeController ( controller ) ; } if ( controller . getState ( ) != ServiceController . State . UP ) { throw SecurityLogger . ROOT_LOGGER . requiredSecurityDomainServiceNotAvailable ( controller . getName ( ) . getSimpleName ( ) ) ; } }
Wait for the required service to start up and fail otherwise . This method is necessary when a runtime operation uses a service that might have been created within a composite operation .