public void add ( OutboundConnection outboundConnection , EndPointDescriptor descriptor ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "add" , new Object [ ] { outboundConnection , descriptor } ) ; if ( connectionCloseTimeout == 0 ) { // Optimisation - if the close timeout has been set to zero, then close // the connection immediately, rather than even trying to add it to the pool if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "close timeout == 0, closing immediately" ) ; outboundConnection . physicalClose ( true ) ; } else { // Add the connection into the pool and register and alarm with the alarm // manager so we know to close the connection if it remains idle. LinkedList < Object [ ] > connectionList = null ; Object [ ] listEntry = null ; // Take our own monitor to prevent anyone else updating the pool // while we carry out this operation. synchronized ( this ) { // See if other connections to the same endpoint have already // been added to the pool. connectionList = descriptorToConnectionListMap . get ( descriptor ) ; if ( connectionList == null ) { // No connections to the same end point, this is the first. connectionList = new LinkedList < Object [ ] > ( ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "pool does not contain other connections for this endpoint, adding new list: " + connectionList ) ; descriptorToConnectionListMap . put ( descriptor , connectionList ) ; } else if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { // If debug trace is on, the dump out what connections relating to this // endpoint are already present in the pool. SibTr . debug ( this , tc , "connections already present in list: " + connectionList + " are" , connectionList . toArray ( ) ) ; } AlarmValid alarmValid = new AlarmValid ( ) ; // The entry placed into the list is a tuple (for which we use // a object array of size 2) consisting of outbound connection // and an object which is used to determine if the alarm we // are about to set is still valid. listEntry = new Object [ ] { outboundConnection , alarmValid } ; connectionList . addLast ( listEntry ) ; } // Set an alarm so that we can close the connection if it remains // idle for too long. AlarmManager alarmManager = Framework . getInstance ( ) . getAlarmManager ( ) ; alarmManager . createDeferrable ( connectionCloseTimeout , this , new Object [ ] { connectionList , listEntry } ) ; // D197042 } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "add" ) ; }
Adds an outbound connection into the idle connection pool . This connection will remain in the pool until either it is removed via the remove method or remains idle long enough to be closed .