Class UpperBound
java.lang.Object
org.springframework.integration.util.UpperBound
Thin wrapper around a Semaphore that allows to create a potentially unlimited upper bound
 to by used in buffers of messages (e.g. a QueueChannel or a MessageStore).
- Since:
- 2.0
- Author:
- Mark Fisher, Iwein Fuld, Artem Bilan, Gary Russell
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionintvoidrelease()Releases one lock on the underlying semaphore.voidrelease(int permits) Releases several locks on the underlying semaphore.toString()booleantryAcquire(long timeoutInMilliseconds) Acquires a permit from the underlying semaphore if this UpperBound is bounded and returns true if it succeeds within the given timeout.
- 
Constructor Details- 
UpperBoundpublic UpperBound(int capacity) Create an UpperBound with the given capacity. If the given capacity is less than 1 an infinite UpperBound is created.- Parameters:
- capacity- The capacity.
 
 
- 
- 
Method Details- 
availablePermitspublic int availablePermits()
- 
tryAcquirepublic boolean tryAcquire(long timeoutInMilliseconds) Acquires a permit from the underlying semaphore if this UpperBound is bounded and returns true if it succeeds within the given timeout. If the timeout is less than 0, it will block indefinitely.- Parameters:
- timeoutInMilliseconds- The time to wait until a permit is available.
- Returns:
- true if a permit is acquired.
 
- 
releasepublic void release()Releases one lock on the underlying semaphore. This is typically not done by the same Thread that acquired the lock, but by the thread that picked up the message.
- 
releasepublic void release(int permits) Releases several locks on the underlying semaphore. This is typically not done by the same Thread that acquired the lock, but by the thread that picked up the message.- Parameters:
- permits- The number of permits to release.
 
- 
toString
 
-