Spring Integration

org.springframework.integration.util
Class UpperBound

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

public final class UpperBound
extends 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
 Semaphore semaphore
           
 
Constructor Summary
UpperBound(int capacity)
          Create an UpperBound with the given capacity.
 
Method Summary
 void release()
          Releases one lock 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 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

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.


Spring Integration

Copyright © 2010. All Rights Reserved.