ucb.util.mailbox
Class QueuedMailbox

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--ucb.util.mailbox.QueuedMailbox
All Implemented Interfaces:
Mailbox, java.rmi.Remote, java.io.Serializable
Direct Known Subclasses:
QueuedConcurrentMailbox

public class QueuedMailbox
extends java.rmi.server.UnicastRemoteObject
implements Mailbox

A Mailbox with a specified (positive) capacity.

See Also:
Serialized Form

Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
QueuedMailbox(int capacity)
          A QueuedMailbox with capacity () fixed at CAPACITY that retains messages for receipt.
QueuedMailbox(int capacity, boolean retain)
          A QueuedMailbox with capacity () fixed at CAPACITY and retains () fixed at RETAIN.
 
Method Summary
 int capacity()
          The capacity (as defined in the documentation for Mailbox) of THIS.
 void close()
          Delete any pending messages and then invalidate this Mailbox, so that further use causes an exception.
 int concurrency()
          The degree of concurrency for forwarding (0).
 void deposit(java.io.Serializable msg)
          Deposit MSG in this Mailbox.
 boolean depositIfPossible(java.io.Serializable msg)
          Deposit MSG in this Mailbox, if it is not full.
 void flush()
          Wait until all pending messages have been received.
 void forwardTo(Mailbox box, boolean forwardCurrent)
          Begin forwarding copies of all messages to BOX in the order received.
 java.io.Serializable receive()
          Receive the next queued message in this Mailbox.
 java.io.Serializable receiveIfPossible()
          Receive the next queued message in this Mailbox, if one is immediately available.
 boolean retains()
          True iff this Mailbox retains messages sent to it for later receipt.
 void stopForwardingTo(Mailbox box)
          Stop forwarding copies of messages to BOX.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QueuedMailbox

public QueuedMailbox(int capacity,
                     boolean retain)
              throws java.rmi.RemoteException
A QueuedMailbox with capacity () fixed at CAPACITY and retains () fixed at RETAIN. Forwarding is synchronous.

QueuedMailbox

public QueuedMailbox(int capacity)
              throws java.rmi.RemoteException
A QueuedMailbox with capacity () fixed at CAPACITY that retains messages for receipt.
Method Detail

deposit

public void deposit(java.io.Serializable msg)
             throws java.rmi.RemoteException,
                    java.lang.InterruptedException
Deposit MSG in this Mailbox. If the Mailbox is full, wait if necessary for space to be available.
Specified by:
deposit in interface Mailbox

depositIfPossible

public boolean depositIfPossible(java.io.Serializable msg)
                          throws java.rmi.RemoteException,
                                 java.lang.InterruptedException
Deposit MSG in this Mailbox, if it is not full. Returns true iff the message was deposited.
Specified by:
depositIfPossible in interface Mailbox

receive

public java.io.Serializable receive()
                             throws java.lang.InterruptedException
Receive the next queued message in this Mailbox.
Specified by:
receive in interface Mailbox

receiveIfPossible

public java.io.Serializable receiveIfPossible()
                                       throws java.lang.InterruptedException
Receive the next queued message in this Mailbox, if one is immediately available. Returns null otherwise.
Specified by:
receiveIfPossible in interface Mailbox

forwardTo

public void forwardTo(Mailbox box,
                      boolean forwardCurrent)
               throws java.rmi.RemoteException,
                      java.lang.InterruptedException
Begin forwarding copies of all messages to BOX in the order received. If FORWARDCURRENT, first forwards all messages currently contained in BOX and as yet unreceived.
Specified by:
forwardTo in interface Mailbox

stopForwardingTo

public void stopForwardingTo(Mailbox box)
Stop forwarding copies of messages to BOX.
Specified by:
stopForwardingTo in interface Mailbox

flush

public void flush()
           throws java.rmi.RemoteException,
                  java.lang.InterruptedException
Wait until all pending messages have been received.
Specified by:
flush in interface Mailbox

close

public void close()
Delete any pending messages and then invalidate this Mailbox, so that further use causes an exception.
Specified by:
close in interface Mailbox

retains

public boolean retains()
True iff this Mailbox retains messages sent to it for later receipt. A mailbox that neither retains nor forwards acts as a bit bucket.
Specified by:
retains in interface Mailbox

capacity

public int capacity()
The capacity (as defined in the documentation for Mailbox) of THIS.
Specified by:
capacity in interface Mailbox

concurrency

public int concurrency()
The degree of concurrency for forwarding (0).
Specified by:
concurrency in interface Mailbox