public abstract class AbstractServiceCache<T> extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
AbstractServiceCache.ServiceConstructor<T> |
| Constructor and Description |
|---|
AbstractServiceCache(int instanceLimit,
long instanceAcquiringTimeoutInMillis)
Creates new cache
|
| Modifier and Type | Method and Description |
|---|---|
T |
dequeue(String pushMessageInformationId,
String variantID)
Dequeues the service instance if there is one available, otherwise returns null
|
T |
dequeueOrCreateNewService(String pushMessageInformationId,
String variantID,
AbstractServiceCache.ServiceConstructor<T> constructor)
Cache returns a service for given parameters or uses service constructor to instantiate new service.
|
void |
freeUpSlot(String pushMessageInformationId,
String variantID)
Allows to free up a counter of created services and thus allowing waiting consumers to create new services within the limits.
|
void |
queueFreedUpService(String pushMessageInformationId,
String variantID,
T service)
Allows to queue used and freed up service into cache so that can be reused by another consumer.
|
public AbstractServiceCache(int instanceLimit,
long instanceAcquiringTimeoutInMillis)
instanceLimit - how many instances can be createdinstanceAcquiringTimeoutInMillis - what is a timeout before the cache can return nullpublic T dequeueOrCreateNewService(String pushMessageInformationId, String variantID, AbstractServiceCache.ServiceConstructor<T> constructor)
instanceLimit.
The service blocks until a service is available or configured timeout.
In case the service is not available when times out, cache returns null.pushMessageInformationId - the push message idvariant - the variantconstructor - the service constructorpublic T dequeue(String pushMessageInformationId, String variantID)
pushMessageInformationId - the push message idvariant - the variantpublic void queueFreedUpService(String pushMessageInformationId, String variantID, T service)
pushMessageInformationId - the push messagevariant - the variantservice - the used and freed up servicepublic void freeUpSlot(String pushMessageInformationId, String variantID)
pushMessageInformationId - the push messagevariant - the variantCopyright © 2015 JBoss by Red Hat. All Rights Reserved.