public void alarm ( Object alarmContext ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "alarm" , alarmContext ) ; boolean alarmValid = false ; boolean presentInConnectionList = false ; Object [ ] listEntry = null ; // Take the pools monitor so that no-one else can try and remove the // connection from the pool while we decide if we should close it or not. synchronized ( this ) { // The alarm context is a tuple (implemented as an object array of // size 2) containing the connection list to which the connection // belongs and another tuple. This second tuple contains the connection // itself and an object which represents whether it is still valid to // close the connection. Object [ ] contextArray = ( Object [ ] ) alarmContext ; LinkedList connectionList = ( LinkedList ) contextArray [ 0 ] ; listEntry = ( Object [ ] ) contextArray [ 1 ] ; alarmValid = ( ( AlarmValid ) listEntry [ 1 ] ) . isValid ( ) ; if ( alarmValid ) presentInConnectionList = connectionList . remove ( listEntry ) ; } // If we found (and removed) a connection suitable to be closed, then // close it. As we did all the updates to shared structures in the // above synchronized block, we are safe to do the close without // holding any monitors. if ( presentInConnectionList ) { OutboundConnection connection = ( OutboundConnection ) listEntry [ 0 ] ; connection . physicalClose ( true ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "alarm" ) ; }
AlarmListener fired when a connection may have been idle for too long . This listener is registered with the alarm manager every time a connection is added to the pool . When fired it determines if the connection has remained idle and if so closes it .