public class BasicTokenManager<T> extends Object implements SimpleTokenManager<T>
getNextAvailableToken
is called tokens are issued in the order they were added to the manager, FIFO. The BasicTokenManager acts as a circular queue
of tokens. Once the manager issues all available tokens it will cycle back to the first token and start issuing tokens again.
When adding tokens to the pool of available tokens, the manager will not add tokens that are already in the pool.
The manager class is thread safe.| Constructor and Description |
|---|
BasicTokenManager() |
BasicTokenManager(Collection<T> tokens)
BasicTokenManager constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addAllTokensToPool(Collection<T> tokens)
Adds a
Collection of tokens to the available token pool. |
boolean |
addTokenToPool(T token)
Adds a token to the available token pool.
|
T |
getNextAvailableToken()
Get an available token.
|
int |
numAvailableTokens()
Get the number of available tokens.
|
public BasicTokenManager()
public BasicTokenManager(Collection<T> tokens)
tokens - Collection of tokenspublic boolean addTokenToPool(T token)
SimpleTokenManageraddTokenToPool in interface SimpleTokenManager<T>token - Token to be addedpublic boolean addAllTokensToPool(Collection<T> tokens)
SimpleTokenManagerCollection of tokens to the available token pool.addAllTokensToPool in interface SimpleTokenManager<T>tokens - Tokens to be addedpublic T getNextAvailableToken()
SimpleTokenManagergetNextAvailableToken in interface SimpleTokenManager<T>public int numAvailableTokens()
SimpleTokenManagernumAvailableTokens in interface SimpleTokenManager<T>Copyright © 2020 The Apache Software Foundation. All rights reserved.