protected E createOrAttemptToBorrow ( final PoolKey < K > key ) { E entry = null ; if ( ! pool . containsKey ( key ) ) { entry = create ( key ) . initialize ( key , this ) ; pool . put ( key , entry ) ; borrowed . add ( entry ) ; return entry ; } entry = pool . get ( key ) ; if ( borrowed . add ( entry ) ) { factory . activate ( entry . get ( ) ) ; return entry ; } return entry . isCurrentOwner ( ) ? entry : null ; }
Default Single Key to Single Object implementation . Advanced Pools extending this class can override this behavior . If the key does not exist then an entry should be created and returned . If the key exists and is not borrowed then the entry should be returned .