public class BasicTokenManger<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 |
---|
BasicTokenManger() |
BasicTokenManger(Collection<T> tokens) |
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 BasicTokenManger()
public BasicTokenManger(Collection<T> tokens)
public boolean addTokenToPool(T token)
SimpleTokenManager
addTokenToPool
in interface SimpleTokenManager<T>
token
- Token to be addedpublic boolean addAllTokensToPool(Collection<T> tokens)
SimpleTokenManager
Collection
of tokens to the available token pool.addAllTokensToPool
in interface SimpleTokenManager<T>
tokens
- Tokens to be addedpublic T getNextAvailableToken()
SimpleTokenManager
getNextAvailableToken
in interface SimpleTokenManager<T>
public int numAvailableTokens()
SimpleTokenManager
numAvailableTokens
in interface SimpleTokenManager<T>
Copyright © 2012–2016 The Apache Software Foundation. All rights reserved.