ucb.util.mailbox
Class SimpleMailbox

java.lang.Object
  |
  +--ucb.util.mailbox.SimpleMailbox
All Implemented Interfaces:
Mailbox, java.rmi.Remote

public class SimpleMailbox
extends java.lang.Object
implements Mailbox

A filter on Mailboxes that turns all InterruptedException and RemoteExceptions into RuntimeExceptions (MailboxExceptions). Although this indirectly implements the Remote interface, it cannot be made into a remote class, because its methods do not mention RemoteException in their throws clauses.


Field Summary
 Mailbox box
          The Mailbox being filtered (argument to the constructor).
 
Constructor Summary
SimpleMailbox(Mailbox box)
           
 
Method Summary
 int capacity()
          The capacity (see interface comment above) of THIS.
 void close()
          Flush any pending messages and then invalidate this Mailbox, so that further use causes an exception.
 int concurrency()
          The level of concurrency for forwarding mail.
 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.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

box

public final Mailbox box
The Mailbox being filtered (argument to the constructor).
Constructor Detail

SimpleMailbox

public SimpleMailbox(Mailbox box)
Method Detail

deposit

public void deposit(java.io.Serializable msg)
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)
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()
Receive the next queued message in this Mailbox.
Specified by:
receive in interface Mailbox

receiveIfPossible

public java.io.Serializable receiveIfPossible()
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)
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()
Wait until all pending messages have been received.
Specified by:
flush in interface Mailbox

close

public void close()
Flush 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

concurrency

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

capacity

public int capacity()
The capacity (see interface comment above) of THIS.
Specified by:
capacity in interface Mailbox