|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gumbo.util.AbstractDisposable | +--gumbo.net.msg.MessageAgent
Base class for an agent that conveniently facilitates network messaging for a network node (client, server). This class combines the sending of request messages, via sendMessage(), and the handling of response messages, via addHandler(), although use of both functions is not required. Note that message sending (requests) and message handling (responses) are stateless (responses are not checked against requests).
Includes support for standard reporting of status to the application "root" window and/or a "target" child window, and for showing an error dialog.
Nested Class Summary | |
protected class |
MessageAgent.Handler
Used by subclasses to handle messages received from this agent's message router (see addHandler()). |
Constructor Summary | |
MessageAgent(MessageThread thread,
MainWindow root,
MainWindow target)
Creates an instance. |
Method Summary | |
void |
addHandler(MessageAgent.Handler handler)
Used by subclasses to add a message handler to this agent's message router. |
NetThread |
getMessageThread()
Returns the message thread, which is used to send and receive messages. |
MainWindow |
getRootWindow()
Returns the root window, for status and error reporting. |
MainWindow |
getTargetWindow()
Returns the target window, for status and error reporting. |
protected void |
implDispose()
Removes all handlers from message router, disposes self. |
java.lang.String |
reportProblem(java.lang.String msg,
java.lang.Throwable th)
Used by the system and subclasses to show a dialog with a message and the throwable's stack trace. |
java.lang.String |
reportStatus(java.lang.String msg)
Used by the system and subclasses to report a status message to the window status bar, such as during message send, receive, and handling. |
boolean |
sendMessage(java.lang.String action,
Message msg)
Used by subclasses to send a message using this agent's message writer. |
Methods inherited from class gumbo.util.AbstractDisposable |
dispose, isDisposed |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public MessageAgent(MessageThread thread, MainWindow root, MainWindow target)
thread
- The message thread, for sending and receiving messages.
Never null.root
- The root window, for status and error reporting.
None if null.target
- The target window, for status and error reporting.
None if null.Method Detail |
public final NetThread getMessageThread()
public final MainWindow getRootWindow()
public final MainWindow getTargetWindow()
public java.lang.String reportProblem(java.lang.String msg, java.lang.Throwable th)
public java.lang.String reportStatus(java.lang.String msg)
public final boolean sendMessage(java.lang.String action, Message msg)
action
- The name of the action performed by the message
(such as "open source window"), which is used for status and error
reporting. Never null.msg
- The message to be sent. Never null.
public final void addHandler(MessageAgent.Handler handler)
handler
- The message handler. Never null.protected void implDispose()
implDispose
in class AbstractDisposable
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |