T - the type of the servicepublic abstract class AbstractServiceHolder<T> extends Object
| Constructor and Description |
|---|
AbstractServiceHolder(int instanceLimit,
long instanceAcquiringTimeoutInMillis,
long serviceDisposalDelayInMillis)
Creates new service instance
|
| Modifier and Type | Method and Description |
|---|---|
protected Object |
borrowServiceSlotFromQueue(String pushMessageInformationId,
String variantID) |
T |
dequeue(String pushMessageInformationId,
String variantID)
Dequeues the service instance if there is one available, otherwise returns null
|
T |
dequeueOrCreateNewService(String pushMessageInformationId,
String variantID,
ServiceConstructor<T> constructor)
Holder returns a service for given parameters or uses service constructor to instantiate new service.
|
void |
destroy(String pushMessageInformationId,
String variantID) |
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.
|
abstract javax.jms.Queue |
getFreeServiceSlotQueue()
Returns the Queue used as a counter of free services.
|
void |
initialize(String pushMessageInformationId,
String variantID) |
void |
queueFreedUpService(String pushMessageInformationId,
String variantID,
T service,
ServiceDestroyer<T> destroyer)
Allows to queue used and freed up service into cache so that can be reused by another consumer.
|
protected void |
returnServiceSlotToQueue(String pushMessageInformationId,
String variantID) |
public AbstractServiceHolder(int instanceLimit,
long instanceAcquiringTimeoutInMillis,
long serviceDisposalDelayInMillis)
instanceLimit - how many instances can be createdinstanceAcquiringTimeoutInMillis - what is a timeout before the holder can return nullserviceDisposalDelayInMillis - how long the service instance will be held until it is disposed for inactivitypublic abstract javax.jms.Queue getFreeServiceSlotQueue()
public T dequeueOrCreateNewService(String pushMessageInformationId, String variantID, ServiceConstructor<T> constructor)
instanceLimit.
The service blocks until a service is available or configured instanceAcquiringTimeoutInMillis.
In case the service is not available when times out, holder returns null.pushMessageInformationId - the push message idvariantID - the variantconstructor - the service constructorpublic T dequeue(String pushMessageInformationId, String variantID)
pushMessageInformationId - the push message idvariantID - the variantpublic void queueFreedUpService(String pushMessageInformationId, String variantID, T service, ServiceDestroyer<T> destroyer)
pushMessageInformationId - the push messagevariantID - the variantservice - the used and freed up servicedestroyer - the instance of ServiceDestroyer used to destroy service instancepublic void freeUpSlot(String pushMessageInformationId, String variantID)
pushMessageInformationId - the push messagevariantID - the variantprotected Object borrowServiceSlotFromQueue(String pushMessageInformationId, String variantID)
Copyright © 2016 JBoss by Red Hat. All Rights Reserved.