/** * Implementing classes should invoke this method once their service has started. It will cause * the service to transition from {@link State#STARTING} to {@link State#RUNNING}. * * @throws IllegalStateException if the service is not {@link State#STARTING}. */ protected final void notifyStarted() { lock.lock(); try { if (snapshot.state != State.STARTING) { IllegalStateException failure = new IllegalStateException( "Cannot notifyStarted() when the service is " + snapshot.state); notifyFailed(failure); throw failure; } if (snapshot.shutdownWhenStartupFinishes) { snapshot = new StateSnapshot(State.STOPPING); // We don't call listeners here because we already did that when we set the // shutdownWhenStartupFinishes flag. doStop(); } else { snapshot = new StateSnapshot(State.RUNNING); running(); } } finally { lock.unlock(); executeListeners(); } }
} else { snapshot = new StateSnapshot(RUNNING); running();
} else { snapshot = new StateSnapshot(RUNNING); running();
} else { snapshot = new StateSnapshot(RUNNING); running();
} else { snapshot = new StateSnapshot(RUNNING); running();
} else { snapshot = new StateSnapshot(RUNNING); running();
} else { snapshot = new StateSnapshot(RUNNING); running();
} else { snapshot = new StateSnapshot(RUNNING); running();