void close ( boolean alreadyClosed ) { final String methodName = "close" ; if ( TraceComponent . isAnyTracingEnabled ( ) && TRACE . isEntryEnabled ( ) ) { SibTr . entry ( this , TRACE , methodName , alreadyClosed ) ; } _closed = true ; /* * 238811: * Stop all of the listeners - do not close them as the dispatchers * might still be using them. Close them after the dispatchers have * stopped. */ /* * We close dispatchers as soon as they are finished with so no longer have to * close them here. */ if ( ! alreadyClosed ) { for ( final Iterator iterator = _listeners . values ( ) . iterator ( ) ; iterator . hasNext ( ) ; ) { final SibRaListener listener = ( SibRaListener ) iterator . next ( ) ; listener . stop ( ) ; } } // The connection is closing so throw away the connection name SibRaDispatcher . resetMEName ( ) ; // We want this thread to wait until all the dispatchers have finished their work // (which will happen when the dispatcherCount hits 0. We put the thread into a // wait state if there are any dispatchers still going, the thread will be notified // each time a dispatcher closes (when it has finished its work). synchronized ( _dispatcherCount ) { if ( TraceComponent . isAnyTracingEnabled ( ) && TRACE . isDebugEnabled ( ) ) { SibTr . debug ( this , TRACE , "There are still " + _dispatcherCount . get ( ) + " open dispatchers" ) ; } if ( _dispatcherCount . get ( ) > 0 ) { Long mdbQuiescingTimeout = getMDBQuiescingTimeoutProperty ( ) ; waitForDispatchersToFinish ( mdbQuiescingTimeout ) ; } } /* * Close all of the listeners */ if ( ! alreadyClosed ) { for ( final Iterator iterator = _listeners . values ( ) . iterator ( ) ; iterator . hasNext ( ) ; ) { final SibRaListener listener = ( SibRaListener ) iterator . next ( ) ; listener . close ( ) ; } } _listeners . clear ( ) ; /* * Close the connection */ try { _connection . removeConnectionListener ( _connectionListener ) ; // It should be ok to call close on an already closed connection but comms // FFDCs thjis (processor seems ok with it though). No need to close the connection // again anyway so we'll check and if we are being called as part of MeTerminated or // connectionError then the connection will have been closed so dont close again. if ( ! alreadyClosed ) { _connection . close ( ) ; } } catch ( final SIException exception ) { FFDCFilter . processException ( exception , CLASS_NAME + "." + methodName , "1:1023:1.59" , this ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && TRACE . isEventEnabled ( ) ) { SibTr . exception ( this , TRACE , exception ) ; } } catch ( final SIErrorException exception ) { FFDCFilter . processException ( exception , CLASS_NAME + "." + methodName , "1:1031:1.59" , this ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && TRACE . isEventEnabled ( ) ) { SibTr . exception ( this , TRACE , exception ) ; } } if ( TraceComponent . isAnyTracingEnabled ( ) && TRACE . isEntryEnabled ( ) ) { SibTr . exit ( this , TRACE , methodName ) ; } }
Closes this connection and any associated listeners and dispatchers .