public void connectionLost ( ) { // Ensure that only one thread will try to reconnect. synchronized ( this ) { if ( reconnecting ) { return ; } reconnecting = true ; } readerThread = null ; boolean isConnected = false ; if ( ! shutdown ) { // Notify the component that connection was lost so it needs to // shutdown. The component is // still registered in the local component manager but just not // connected to the server component . shutdown ( ) ; } while ( ! isConnected && ! shutdown ) { try { connect ( host , port , subdomain ) ; isConnected = true ; // It may be possible that while a new connection was being // established the // component was required to shutdown so in this case we need to // close the new // connection if ( shutdown ) { disconnect ( ) ; } else { // Component is back again working so start it up again start ( ) ; } } catch ( ComponentException e ) { manager . getLog ( ) . error ( "Error trying to reconnect with the server" , e ) ; // Wait for 5 seconds until the next retry try { Thread . sleep ( 5000 ) ; } catch ( InterruptedException e1 ) { // Do nothing } } } reconnecting = false ; }
Notification message that the connection with the server was lost unexpectedly . We will try to reestablish the connection for ever until the connection has been reestablished or this thread has been stopped .