zeus.actors
Class MailBox

java.lang.Object
  extended byzeus.actors.MailBox
Direct Known Subclasses:
Zeus_ACC_MailBox

public class MailBox
extends java.lang.Object

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

eventMonitor

protected HSet[] eventMonitor
eventMonitor used to be private, but I needed to alter this so that I could build an effective sub-class


RECEIVE

public static final int RECEIVE
See Also:
Constant Field Values

QUEUE

public static final int QUEUE
See Also:
Constant Field Values

DISPATCH

public static final int DISPATCH
See Also:
Constant Field Values

NOT_DISPATCH

public static final int NOT_DISPATCH
See Also:
Constant Field Values

inMail

protected Queue inMail
A data structure holding the agent's incoming mail messages


outMail

protected Queue outMail
A data structure holding the agent's outgoing mail messages


ccMail

protected Queue ccMail
Holds mail messages that need to be CC'ed to Visualiser agents


asTable

protected java.util.Hashtable asTable

visualisers

protected java.util.Hashtable visualisers

server

protected Server server
The sub-component responsible for reading incoming mail


postman

protected PostMan[] postman
The sub-component responsible for dispatching outgoing mail


myAddress

protected Address myAddress

context

protected AgentContext context
Constructor Detail

MailBox

public MailBox()

MailBox

public MailBox(AgentContext context)
Method Detail

register

public void register(Performative msg)

getAgentContext

public AgentContext getAgentContext()

del

public void del(Address addr)

del

public void del(java.util.Vector v)

add

public void add(Address addr)

add

public void add(java.util.Vector v)

lookup

public Address lookup(java.lang.String name)

stopDispatching

public void stopDispatching()

stopProcessing

public void stopProcessing()

lowerStatus

public void lowerStatus()

addressSought

public java.lang.String addressSought(java.lang.String agent)
changed to public so that subclasses of the classes in this package can have access (Simon)


addressReceived

public void addressReceived(Performative msg)

logMessages

public void logMessages(java.lang.String agent,
                        java.lang.String tag)

stopLoggingMessages

public void stopLoggingMessages(java.lang.String agent)

informVisualisers

public void informVisualisers(Performative msg)

getAddress

public Address getAddress()

shutdown

public void shutdown()

postErrorMsg

public void postErrorMsg(Performative msg,
                         java.lang.String content)

sendMsg

public void sendMsg(Performative msg)

nextMsg

public Performative nextMsg()
redundant now


listAddresses

public java.util.Vector listAddresses()

addMessageMonitor

public 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. This is programatic alternative to writing reaction rules


removeMessageMonitor

public void removeMessageMonitor(MessageMonitor monitor,
                                 long event_type)

notifyMonitors

public void notifyMonitors(Performative message,
                           int type)

getInTray

public InTray getInTray()
added so that transports can be accessed

Since:
1.1


Copyright © 2000-2003 BT Exact Technologies. All Rights Reserved.