Implementing classes should invoke this method once their service has stopped. It will cause the service to transition from State#STOPPING to State#TERMINATED. @throws IllegalStateException if the service is neither State#STOPPING nor State#RUNNING.
()
| 375 | |
| 376 | |
| 377 | protected final void notifyStopped() { |
| 378 | monitor.enter(); |
| 379 | try { |
| 380 | // We check the internal state of the snapshot instead of state() directly so we don't allow |
| 381 | // notifyStopped() to be called while STARTING, even if stop() has already been called. |
| 382 | State previous = snapshot.state; |
| 383 | if (previous != STOPPING && previous != RUNNING) { |
| 384 | IllegalStateException failure = new IllegalStateException("Cannot notifyStopped() when the service is " + previous); |
| 385 | notifyFailed(failure); |
| 386 | throw failure; |
| 387 | } |
| 388 | snapshot = new StateSnapshot(TERMINATED); |
| 389 | terminated(previous); |
| 390 | } finally { |
| 391 | monitor.leave(); |
| 392 | executeListeners(); |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | /** |
| 397 | * Invoke this method to transition the service to the {@link State#FAILED}. The service will |
no test coverage detected