public synchronized void pause ( PauseListener listener ) { closed = true ; if ( configuredServerEndpoints . isEmpty ( ) ) { listener . paused ( ) ; return ; } if ( listener != null ) { pauseListeners . add ( listener ) ; } for ( ConfiguredServerEndpoint endpoint : configuredServerEndpoints ) { for ( final Session session : endpoint . getOpenSessions ( ) ) { ( ( UndertowSession ) session ) . getExecutor ( ) . execute ( new Runnable ( ) { @ Override public void run ( ) { try { session . close ( new CloseReason ( CloseReason . CloseCodes . GOING_AWAY , "" ) ) ; } catch ( Exception e ) { JsrWebSocketLogger . ROOT_LOGGER . couldNotCloseOnUndeploy ( e ) ; } } } ) ; } } Runnable done = new Runnable ( ) { int count = configuredServerEndpoints . size ( ) ; @ Override public synchronized void run ( ) { List < PauseListener > copy = null ; synchronized ( ServerWebSocketContainer . this ) { count -- ; if ( count == 0 ) { copy = new ArrayList <> ( pauseListeners ) ; pauseListeners . clear ( ) ; } } if ( copy != null ) { for ( PauseListener p : copy ) { p . paused ( ) ; } } } } ; for ( ConfiguredServerEndpoint endpoint : configuredServerEndpoints ) { endpoint . notifyClosed ( done ) ; } }
Pauses the container