本文整理汇总了Java中com.sun.squawk.VM.lookupMailbox方法的典型用法代码示例。如果您正苦于以下问题:Java VM.lookupMailbox方法的具体用法?Java VM.lookupMailbox怎么用?Java VM.lookupMailbox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.squawk.VM
的用法示例。
在下文中一共展示了VM.lookupMailbox方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: lookupMailbox
import com.sun.squawk.VM; //导入方法依赖的package包/类
/**
* 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.
*
* @param name the name of the Mailbox to lookup.
* @param replyMailbox the address of a local mailbox that the remote isolate can send replies to.
* @return an open address to the remote mailbox named <code>name</code>.
* @throws NoSuchMailboxException if there is no mailbox named <code>name</code>.
*/
public static MailboxAddress lookupMailbox(String name, Mailbox replyMailbox) throws NoSuchMailboxException {
Mailbox box = VM.lookupMailbox(name);
if (box == null) {
throw new NoSuchMailboxException(name);
}
MailboxAddress replyAddress = new MailboxAddress(replyMailbox);
MailboxAddress startingAddress = new MailboxAddress(box);
MailboxAddress finalAddress = box.callHandleOpen(startingAddress, replyAddress);
if (finalAddress == null) {
// something fell apart in callHandleOpen
throw new NoSuchMailboxException(name);
}
// record the address of the remote mailbox with this isolate:
finalAddress.recordAddress(Isolate.currentIsolate(), replyAddress);
// also, tell the isolate containing the remote mailbox about the
// reply address that it will use to send replies back to this isolate.
replyAddress.recordAddress(box.getOwner(), finalAddress);
return finalAddress;
}