|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.miv.mbox.MBoxBase
org.miv.mbox.MBoxStandalone
public class MBoxStandalone
Implementation of a message box to be used without having to inherit it.
This message box is a fully fledged box that can work by itself, receive
messages and dispatch them to a listener when invoked. It is the pending of
the MBoxBase when it is not possible to inherit from it.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.miv.mbox.MBoxBase |
|---|
MBoxBase.Message |
| Field Summary | |
|---|---|
protected ArrayList<MBoxListener> |
listeners
Listener for this message box. |
protected boolean |
notifyOnPost
Notify every threads waiting on this mbox monitor at each post?. |
| Fields inherited from class org.miv.mbox.MBoxBase |
|---|
messages, mtmp |
| Constructor Summary | |
|---|---|
MBoxStandalone()
New empty message box. |
|
MBoxStandalone(MBoxListener listener)
New empty message box dispatching messages to a given listener. |
|
| Method Summary | |
|---|---|
void |
addListener(MBoxListener listener)
Add a listener for this message box. |
boolean |
notifyOnPost()
Does the post(String,Object...) method must notify any
thread waiting on the monitor of this message box?. |
void |
post(String from,
Object... data)
Post a message in the message box. |
void |
processMessage(String from,
Object[] data)
Method to override to process each incomming message. |
void |
removeListener(MBoxListener listener)
Remove a listener. |
void |
setListener(MBoxListener listener)
Deprecated. |
void |
setNotifyOnPost(boolean on)
Specify if each call to post(String, Object...) should notify threads
waiting on the monitor of this message box. |
| Methods inherited from class org.miv.mbox.MBoxBase |
|---|
getMessageCount, isMBoxEmpty, popPendingMessages, processMessages |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected ArrayList<MBoxListener> listeners
protected boolean notifyOnPost
| Constructor Detail |
|---|
public MBoxStandalone(MBoxListener listener)
listener - The message reader.public MBoxStandalone()
| Method Detail |
|---|
public boolean notifyOnPost()
post(String,Object...) method must notify any
thread waiting on the monitor of this message box?.
public void setNotifyOnPost(boolean on)
post(String, Object...) should notify threads
waiting on the monitor of this message box.
public void post(String from,
Object... data)
MBox
post in interface MBoxpost in class MBoxBasefrom - Identifier of the sending object.data - Array of posted objects.
public void processMessage(String from,
Object[] data)
MBoxBase
processMessage in interface MBoxListenerprocessMessage in class MBoxBasefrom - The address of the sender.data - The data sent by the sender.@Deprecated public void setListener(MBoxListener listener)
MBoxBase.processMessages() will be called.
listener - The message listener.public void addListener(MBoxListener listener)
MBoxBase.processMessages() is called. Note that all listeners
receive all messages. That is if there is N listeners, and the box
received one message, the message is sent N times, once for each
listener.
listener - The listener to add.public void removeListener(MBoxListener listener)
listener - The listener to remove.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||