public void addShutdownListener ( final ShutdownListener shutdownListener ) { synchronized ( lock ) { if ( ! shutdown ) { throw UndertowMessages . MESSAGES . handlerNotShutdown ( ) ; } long count = activeRequestsUpdater . get ( this ) ; if ( count == 0 ) { shutdownListener . shutdown ( true ) ; } else { shutdownListeners . add ( shutdownListener ) ; } } }
Adds a shutdown listener that will be invoked when all requests have finished . If all requests have already been finished the listener will be invoked immediately .