com.caucho.message.common
Class AbstractMessageReceiver<T>

java.lang.Object
  extended by com.caucho.message.common.AbstractMessageReceiver<T>
All Implemented Interfaces:
MessageReceiver<T>, java.lang.Iterable<T>, java.util.Collection<T>, java.util.concurrent.BlockingQueue<T>, java.util.Queue<T>
Direct Known Subclasses:
BasicMessageReceiver, LocalReceiver

public abstract class AbstractMessageReceiver<T>
extends java.lang.Object
implements MessageReceiver<T>

abstract receiver from a message store


Constructor Summary
AbstractMessageReceiver()
           
 
Method Summary
 void accepted(long mid)
          Accept the last message.
 boolean add(T e)
           
 boolean addAll(java.util.Collection<? extends T> c)
           
 void clear()
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection<?> c)
           
 int drainTo(java.util.Collection<? super T> c)
           
 int drainTo(java.util.Collection<? super T> c, int maxElements)
           
 T element()
           
 long getLastMessageId()
          Returns the last message id for client ack.
 boolean isEmpty()
           
 java.util.Iterator<T> iterator()
           
 void modified(long mid, boolean isFailed, boolean isUndeliverableHere)
          Returns the message as modified.
 boolean offer(T e)
           
 boolean offer(T e, long timeout, java.util.concurrent.TimeUnit unit)
           
protected  void onBuild()
           
 T peek()
           
 T poll()
           
 T poll(long timeout, java.util.concurrent.TimeUnit unit)
           
protected abstract  T pollMicros(long timeoutMicros)
          Polls the queue with a timeout.
 void put(T e)
           
 void rejected(long mid, java.lang.String errorMessage)
          Reject the last message.
 void released(long mid)
          Release the last message.
 int remainingCapacity()
           
 T remove()
           
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection<?> c)
           
 boolean retainAll(java.util.Collection<?> c)
           
 int size()
           
 T take()
           
 java.lang.Object[] toArray()
           
<X> X[]
toArray(X[] a)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Constructor Detail

AbstractMessageReceiver

public AbstractMessageReceiver()
Method Detail

pollMicros

protected abstract T pollMicros(long timeoutMicros)
Polls the queue with a timeout.


onBuild

protected void onBuild()

isEmpty

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

size

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

poll

public T poll(long timeout,
              java.util.concurrent.TimeUnit unit)
Specified by:
poll in interface java.util.concurrent.BlockingQueue<T>

take

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

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>

poll

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

remove

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

getLastMessageId

public long getLastMessageId()
Description copied from interface: MessageReceiver
Returns the last message id for client ack.

Specified by:
getLastMessageId in interface MessageReceiver<T>

accepted

public void accepted(long mid)
Description copied from interface: MessageReceiver
Accept the last message.

Specified by:
accepted in interface MessageReceiver<T>

rejected

public void rejected(long mid,
                     java.lang.String errorMessage)
Description copied from interface: MessageReceiver
Reject the last message.

Specified by:
rejected in interface MessageReceiver<T>

released

public void released(long mid)
Description copied from interface: MessageReceiver
Release the last message.

Specified by:
released in interface MessageReceiver<T>

modified

public void modified(long mid,
                     boolean isFailed,
                     boolean isUndeliverableHere)
Description copied from interface: MessageReceiver
Returns the message as modified.

Specified by:
modified in interface MessageReceiver<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>

addAll

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

clear

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

put

public void put(T e)
         throws java.lang.InterruptedException
Specified by:
put 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>

containsAll

public boolean containsAll(java.util.Collection<?> c)
Specified by:
containsAll in interface java.util.Collection<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>

removeAll

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

retainAll

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

toArray

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

toArray

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

add

public boolean add(T e)
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>

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>

drainTo

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

drainTo

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

offer

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

offer

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

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object