SunSPOT API V2.0


com.sun.squawk.io.mailboxes
Class Channel

java.lang.Object
  extended by com.sun.squawk.io.mailboxes.Channel

public class Channel
extends Object

A Channel is a private bidirectional link between two MailBoxes. The Channel is a wrapper over the local mailbox and the mailboxaddress of the remote mailbox.

A Channel can be used to talk to any kind of registered Mailbox, including those created by ServerChannels, and those created by the raw Mailbox API.

See Also:
ServerChannel

Method Summary
 void close()
          Closes the Channel at both ends asynchronously.
 boolean isOpen()
          Return true if the channel is open, both from here to the remote mailbox, and from the remote mailbox back.
static Channel lookup(String mailboxName)
          Create a private MailBox, and connect to the named MailBox.
 Envelope receive()
          Wait for an envlope sent to this channel.
 void send(Envelope env)
          Sends a message to the remote Mailbox.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

close

public void close()
Closes the Channel at both ends asynchronously.


isOpen

public boolean isOpen()
Return true if the channel is open, both from here to the remote mailbox, and from the remote mailbox back.

Returns:
true if open.

lookup

public static Channel lookup(String mailboxName)
                      throws NoSuchMailboxException
Create a private MailBox, and connect to the named MailBox. Note that the server side may or may not create a private mailbox to handle its side of the communication.

Throws:
NoSuchMailboxException

receive

public Envelope receive()
                 throws AddressClosedException,
                        MailboxClosedException
Wait for an envlope sent to this channel. Blocks waiting for messages. If the logical connection to this Mailbox is closed, an AddressClosedException will be thrown.

Returns:
an Envelope containing the sent message.
Throws:
AddressClosedException - if the connection to this mailbox is closed.
MailboxClosedException - if the Channel itself is closed.

send

public void send(Envelope env)
          throws AddressClosedException
Sends a message to the remote Mailbox. Does not wait for acknowledgment. The Channel must not be closed or an IllegateStateException will be thrown.

Parameters:
env - the message to send
Throws:
IllegateStateException - if the address is not in the open state.
AddressClosedException

SunSPOT API V2.0


Copyright © 2007 Sun Microsystems, Inc. All Rights Reserved.