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