public MailAccount reserveMailAccount ( final String accountReservationKey , final String pool ) { if ( pool == null && emailAddressPools . keySet ( ) . size ( ) > 1 ) { throw new IllegalStateException ( "No pool specified but multiple pools available." ) ; } String poolKey = pool == null ? defaultPool : pool ; List < MailAccount > addressPool = newArrayList ( emailAddressPools . get ( poolKey ) ) ; Collections . shuffle ( addressPool , random . getRandom ( ) ) ; return reserveAvailableMailAccount ( accountReservationKey , addressPool ) ; }
Reserves an available mail account from the specified pool under the specified reservation key . The method blocks until an account is available .