Spring Integration

org.springframework.integration.util
Class UpperBound

java.lang.Object
  extended by org.springframework.integration.util.UpperBound

public final class UpperBound
extends java.lang.Object

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

Field Summary
 java.util.concurrent.Semaphore semaphore
           
 
Constructor Summary
UpperBound(int capacity)
          Create an UpperBound with the given capacity.
 
Method Summary
 int availablePermits()
           
 void release()
          Releases one lock on the underlying semaphore.
 void release(int permits)
          Releases several locks on the underlying semaphore.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

semaphore

public final java.util.concurrent.Semaphore semaphore
Constructor Detail

UpperBound

public UpperBound(int capacity)
Create an UpperBound with the given capacity. If the given capacity is less than 1 an infinite UpperBound is created.

Method Detail

availablePermits

public int availablePermits()

tryAcquire

public 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.


release

public 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.


release

public 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.


Spring Integration