200201202203204205206207208
} } protected void ensureState(ServiceState expected, String message) { ServiceState current = state.get(); if (current != expected) throw new ServiceStateException(message + " [" + current.toString() + "]"); }
209210211212213214215216217218219220221
protected ServiceState waitForStateChange() throws InterruptedException { synchronized (state) { ServiceState startState = state.get(); ServiceState newState = state.get(); while (newState == startState) { state.wait(); newState = state.get(); }