Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.squawk.io.mailboxes
Class MailboxAddress

    java.lang.Object
      com.sun.squawk.io.mailboxes.MailboxAddress

    public final class MailboxAddress

extends Object

deprecated Use the higher-level `Channel` and `ServerChannel` classes instead.

In the context of Channels, MailboxAddresses are the way a local Channel refers to a remote Channel. Envelopes are tagged with the address of the sender and the receiver. The receiver can use `getReplyAddress()` The MailboxAddress class is likely to become a private imeplementation-only class.

A MailboxAddress is a private reference to a remote Mailbox. It is a logical connection between a sender and a Mailbox.

MailboxAddress are created by lookupMailbox(), which creates a new MailboxAddress each time called, or by receiving a reference to a MailboxAddress in an envelope.

If several isolates want to send messages to the same Mailbox in another isolate, each will use a different MailboxAddress. Even within an isolate, it may be simpler to use different MailboxAddresses to the same Mailbox.

Any attempt to call send() on a MailboxAddress to a Mailbox that is closed throws a MailboxClosedException.

See Also:
  `Channel`, `ServerChannel`

Method Summary
`void` | `close()` Sends a close message to the corresponding Mailbox, explaining that no more messages will be sent via this MailboxAddress.
`MailboxAddress` | `getReplyAddress()` Get the reply address that was associated with this address during lookup.
`boolean` | `isOpen()` Returns true if close() was called, or a MailboxClosedException was thrown by send().
`boolean` | `isOwner(Isolate anIsolate)` Returns true if anIsolate is the owner of this address.
`static MailboxAddress` | `lookupMailbox(String name, Mailbox replyMailbox)` This method looks up a MailboxAddress that has been registered with the system, and implicitly opens the connection to the remote Mailbox.
`void` | `send(Envelope env)` Sends a message to the Mailbox.
`String` | `toString()` Returns a string representation of the object.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Method Detail

### close

    public void close()

  Sends a close message to the corresponding Mailbox, explaining that no more messages will be sent via this MailboxAddress. Also closes otherAddress if it's open, to eagerly break connections between isolates. Redundant closes on a Mailbox are ignored. Do NOT call while synchronized on "this". Can deadlock on otherAddress.close().

### isOpen

    public boolean isOpen()

  Returns true if close() was called, or a MailboxClosedException was thrown by send(). Note - this is intentionally unsynchronized to avoid deadlock in close(), where we call otherAddress.close().

### isOwner

    public boolean isOwner(Isolate anIsolate)

  Returns true if anIsolate is the owner of this address.

### lookupMailbox

    public static MailboxAddress lookupMailbox(String name,
                                               Mailbox replyMailbox)
                                        throws NoSuchMailboxException

  This method looks up a MailboxAddress that has been registered with the system, and implicitly opens the connection to the remote Mailbox. It also opens the reply address for the remote mailbox, so it may send responses back to this Isolate.

  Parameters:
    `name` - the name of the Mailbox to lookup.
    `replyMailbox` - the address of a local mailbox that the remote isolate can send replies to.
  Returns:
    an open address to the remote mailbox named `name`.
  Throws:
    `NoSuchMailboxException` - if there is no mailbox named `name`.

### send

    public void send(Envelope env)
              throws AddressClosedException

  Sends a message to the Mailbox. Does not wait for acknowledgment. The MailboxAddress must have been opened by #lookup, must not have been closed, and caller must by the owning isolate of this MailboxAddress, or an IllegateStateException will be thrown.

  Parameters:
    `env` - the message to send
  Throws:
    `IllegateStateException` - if the address is not in the open state, or if the caller is not the "owner" of this MailboxAddress.
    `AddressClosedException`

### getReplyAddress

    public MailboxAddress getReplyAddress()

  Get the reply address that was associated with this address during lookup. The returned reply address may already be closed.

  Returns:
    the reply address for this address
  Throws:
    `IllegalStateException` - if this address is not open

### toString

    public String toString()

  Returns a string representation of the object. In general, the `toString` method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

  The `toString` method for class `Object` returns a string consisting of the name of the class of which the object is an instance, the at-sign character ``@`', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

  >      getClass().getName() + '@' + Integer.toHexString(hashCode())

  Overrides:
    `toString` in class `Object`
  Returns:
    a string representation of the object.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

"
For updated information see the Java FRC site
"