AsteriskChannelImpl getChannelImplByName ( String name ) { Date dateOfCreation = null ; AsteriskChannelImpl channel = null ; if ( name == null ) { return null ; } synchronized ( channels ) { for ( AsteriskChannelImpl tmp : channels . values ( ) ) { if ( name . equals ( tmp . getName ( ) ) ) { // return the most recent channel or when dates are similar, // the active one if ( dateOfCreation == null || tmp . getDateOfCreation ( ) . after ( dateOfCreation ) || ( tmp . getDateOfCreation ( ) . equals ( dateOfCreation ) && tmp . getState ( ) != ChannelState . HUNGUP ) ) { channel = tmp ; dateOfCreation = channel . getDateOfCreation ( ) ; } } } } return channel ; }
Returns a channel from the ChannelManager s cache with the given name If multiple channels are found returns the most recently CREATED one . If two channels with the very same date exist avoid HUNGUP ones .