org.apache.axis2.transport.base.threads.watermark
Class DefaultWaterMarkQueue<T>

java.lang.Object
  extended by org.apache.axis2.transport.base.threads.watermark.DefaultWaterMarkQueue<T>
Type Parameters:
T -
All Implemented Interfaces:
java.lang.Iterable<T>, java.util.Collection<T>, java.util.concurrent.BlockingQueue<T>, java.util.Queue<T>, WaterMarkQueue<T>

public class DefaultWaterMarkQueue<T>
extends java.lang.Object
implements WaterMarkQueue<T>

A Default implementation for WaterMarkQueue interface. The implementation uses an ArrayBlockingQueue up to water mark. Then it uses a LinkedBlockingQueue or ArrayBlocking queue from the water mark point. The LinkedBlockingQueue is used if a queue size is specified other than the waterMark.


Constructor Summary
DefaultWaterMarkQueue(int waterMark)
          Create a WaterMarkQueue with a waterMark.
DefaultWaterMarkQueue(int waterMark, int size)
          Create a WaterMarkQueue with a waterMark.
 
Method Summary
 boolean add(T t)
           
 boolean addAll(java.util.Collection<? extends T> ts)
           
 void clear()
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection<?> objects)
           
 int drainTo(java.util.Collection<? super T> objects)
           
 int drainTo(java.util.Collection<? super T> objects, int i)
           
 T element()
           
 boolean isEmpty()
           
 java.util.Iterator<T> iterator()
           
 boolean offer(T t)
           
 boolean offer(T t, long l, java.util.concurrent.TimeUnit timeUnit)
           
 boolean offerAfter(T t)
          Offer the element after the water mark.
 T peek()
           
 T poll()
           
 T poll(long l, java.util.concurrent.TimeUnit timeUnit)
           
 void put(T t)
           
 int remainingCapacity()
           
 T remove()
           
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection<?> objects)
           
 boolean retainAll(java.util.Collection<?> objects)
           
 int size()
           
 T take()
           
 java.lang.Object[] toArray()
           
<T> T[]
toArray(T[] ts)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Constructor Detail

DefaultWaterMarkQueue

public DefaultWaterMarkQueue(int waterMark)
Create a WaterMarkQueue with a waterMark. The queue will first fill up to waterMark. These items will be inserted in to an ArrayBlockingQueue. After this an LinkedBlockingQueue will be used without a bound.

Parameters:
waterMark - the waterMark of the queue

DefaultWaterMarkQueue

public DefaultWaterMarkQueue(int waterMark,
                             int size)
Create a WaterMarkQueue with a waterMark. The queue will first fill up to waterMark. These items will be inserted in to an ArrayBlockingQueue. After this an LinkedBlockingQueue will be used with capacity size - waterMark.

Parameters:
waterMark - the waterMark of the queue
size - the size of the queue
Method Detail

add

public boolean add(T t)
Specified by:
add in interface java.util.Collection<T>
Specified by:
add in interface java.util.concurrent.BlockingQueue<T>
Specified by:
add in interface java.util.Queue<T>

offer

public boolean offer(T t)
Specified by:
offer in interface java.util.concurrent.BlockingQueue<T>
Specified by:
offer in interface java.util.Queue<T>

remove

public T remove()
Specified by:
remove in interface java.util.Queue<T>

poll

public T poll()
Specified by:
poll in interface java.util.Queue<T>

element

public T element()
Specified by:
element in interface java.util.Queue<T>

peek

public T peek()
Specified by:
peek in interface java.util.Queue<T>

put

public void put(T t)
         throws java.lang.InterruptedException
Specified by:
put in interface java.util.concurrent.BlockingQueue<T>
Throws:
java.lang.InterruptedException

offer

public boolean offer(T t,
                     long l,
                     java.util.concurrent.TimeUnit timeUnit)
              throws java.lang.InterruptedException
Specified by:
offer in interface java.util.concurrent.BlockingQueue<T>
Throws:
java.lang.InterruptedException

take

public T take()
       throws java.lang.InterruptedException
Specified by:
take in interface java.util.concurrent.BlockingQueue<T>
Throws:
java.lang.InterruptedException

poll

public T poll(long l,
              java.util.concurrent.TimeUnit timeUnit)
       throws java.lang.InterruptedException
Specified by:
poll in interface java.util.concurrent.BlockingQueue<T>
Throws:
java.lang.InterruptedException

remainingCapacity

public int remainingCapacity()
Specified by:
remainingCapacity in interface java.util.concurrent.BlockingQueue<T>

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection<T>
Specified by:
remove in interface java.util.concurrent.BlockingQueue<T>

containsAll

public boolean containsAll(java.util.Collection<?> objects)
Specified by:
containsAll in interface java.util.Collection<T>

addAll

public boolean addAll(java.util.Collection<? extends T> ts)
Specified by:
addAll in interface java.util.Collection<T>

removeAll

public boolean removeAll(java.util.Collection<?> objects)
Specified by:
removeAll in interface java.util.Collection<T>

retainAll

public boolean retainAll(java.util.Collection<?> objects)
Specified by:
retainAll in interface java.util.Collection<T>

clear

public void clear()
Specified by:
clear in interface java.util.Collection<T>

size

public int size()
Specified by:
size in interface java.util.Collection<T>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection<T>

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection<T>
Specified by:
contains in interface java.util.concurrent.BlockingQueue<T>

iterator

public java.util.Iterator<T> iterator()
Specified by:
iterator in interface java.lang.Iterable<T>
Specified by:
iterator in interface java.util.Collection<T>

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<T>

toArray

public <T> T[] toArray(T[] ts)
Specified by:
toArray in interface java.util.Collection<T>

drainTo

public int drainTo(java.util.Collection<? super T> objects)
Specified by:
drainTo in interface java.util.concurrent.BlockingQueue<T>

drainTo

public int drainTo(java.util.Collection<? super T> objects,
                   int i)
Specified by:
drainTo in interface java.util.concurrent.BlockingQueue<T>

offerAfter

public boolean offerAfter(T t)
Description copied from interface: WaterMarkQueue
Offer the element after the water mark.

Specified by:
offerAfter in interface WaterMarkQueue<T>
Parameters:
t - object to be inserted
Returns:
true if the insert is successful


Copyright © 2004-2014 The Apache Software Foundation. All Rights Reserved.