|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectzeus.actors.MailBox
Each agent has a Mailbox component that implements its communication mechanism. The sub-components of the MailBox are together responsible for creating and reading the TCP/IP sockets that send and receive messages.
The MailBox maintains two independent threads of activity, one is a reader
thread, which continually listens for incoming socket connections, whereupon
a new transient thread is created to read the message and deliver it to the
MsgHandler, which processes it. This approach delegates
responsibility for reading messages to the new connection thread, leaving the
main Server thread free to continue listening for incoming messages, (thus
enabling several messages to be received simultaneously). When the incoming
message is read, the connection thread terminates.
The other Mailbox thread is a PostMan object, which creates transient
threads that open sockets to the message recipients. If the connection is made
the message is then streamed down the socket, this allows the agent to
dispatch more than one message at a time.
More details on the workings of the communication mechanism are provided in the Zeus Technical Manual.
| Field Summary | |
protected java.util.Hashtable |
asTable
|
protected Queue |
ccMail
Holds mail messages that need to be CC'ed to Visualiser agents |
protected AgentContext |
context
|
static int |
DISPATCH
|
protected HSet[] |
eventMonitor
eventMonitor used to be private, but I needed to alter this so that I could build an effective sub-class |
protected Queue |
inMail
A data structure holding the agent's incoming mail messages |
protected Address |
myAddress
|
static int |
NOT_DISPATCH
|
protected Queue |
outMail
A data structure holding the agent's outgoing mail messages |
protected PostMan[] |
postman
The sub-component responsible for dispatching outgoing mail |
static int |
QUEUE
|
static int |
RECEIVE
|
protected Server |
server
The sub-component responsible for reading incoming mail |
protected java.util.Hashtable |
visualisers
|
| Constructor Summary | |
MailBox()
|
|
MailBox(AgentContext context)
|
|
| Method Summary | |
void |
add(Address addr)
|
void |
add(java.util.Vector v)
|
void |
addMessageMonitor(MessageMonitor monitor,
long event_type)
Use this method to add a MessageMonitor if your code needs to react to changes in the state of the mailbox. |
void |
addressReceived(Performative msg)
|
java.lang.String |
addressSought(java.lang.String agent)
changed to public so that subclasses of the classes in this package can have access (Simon) |
void |
del(Address addr)
|
void |
del(java.util.Vector v)
|
Address |
getAddress()
|
AgentContext |
getAgentContext()
|
InTray |
getInTray()
added so that transports can be accessed |
void |
informVisualisers(Performative msg)
|
java.util.Vector |
listAddresses()
|
void |
logMessages(java.lang.String agent,
java.lang.String tag)
|
Address |
lookup(java.lang.String name)
|
void |
lowerStatus()
|
Performative |
nextMsg()
redundant now |
void |
notifyMonitors(Performative message,
int type)
|
void |
postErrorMsg(Performative msg,
java.lang.String content)
|
void |
register(Performative msg)
|
void |
removeMessageMonitor(MessageMonitor monitor,
long event_type)
|
void |
sendMsg(Performative msg)
|
void |
shutdown()
|
void |
stopDispatching()
|
void |
stopLoggingMessages(java.lang.String agent)
|
void |
stopProcessing()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected HSet[] eventMonitor
public static final int RECEIVE
public static final int QUEUE
public static final int DISPATCH
public static final int NOT_DISPATCH
protected Queue inMail
protected Queue outMail
protected Queue ccMail
protected java.util.Hashtable asTable
protected java.util.Hashtable visualisers
protected Server server
protected PostMan[] postman
protected Address myAddress
protected AgentContext context
| Constructor Detail |
public MailBox()
public MailBox(AgentContext context)
| Method Detail |
public void register(Performative msg)
public AgentContext getAgentContext()
public void del(Address addr)
public void del(java.util.Vector v)
public void add(Address addr)
public void add(java.util.Vector v)
public Address lookup(java.lang.String name)
public void stopDispatching()
public void stopProcessing()
public void lowerStatus()
public java.lang.String addressSought(java.lang.String agent)
public void addressReceived(Performative msg)
public void logMessages(java.lang.String agent,
java.lang.String tag)
public void stopLoggingMessages(java.lang.String agent)
public void informVisualisers(Performative msg)
public Address getAddress()
public void shutdown()
public void postErrorMsg(Performative msg,
java.lang.String content)
public void sendMsg(Performative msg)
public Performative nextMsg()
public java.util.Vector listAddresses()
public void addMessageMonitor(MessageMonitor monitor,
long event_type)
public void removeMessageMonitor(MessageMonitor monitor,
long event_type)
public void notifyMonitors(Performative message,
int type)
public InTray getInTray()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||