zeus.actors
Class MsgHandler

java.lang.Object
  extended byjava.lang.Thread
      extended byzeus.actors.MsgHandler
All Implemented Interfaces:
java.lang.Runnable

public class MsgHandler
extends java.lang.Thread

The Message Handler component implements each Zeus agent's internal "mail sorting office", continually checking the incoming-message-queue of the MailBox for new messages, and forwarding them to the relevant components within the agent.

The Message Handler's behaviour is controlled by two factors: first, whether a new message represents the start of a new dialogue or it is part of an existing dialogue; and second, on the message processing rules registered with it by other components of the agent.

Change Log
----------

22/08/00 Altered spelling of organization to correct version for about 6 lines - Simon


Nested Class Summary
(package private)  class MsgHandler.AbilityLogger
           
protected  class MsgHandler.ReportLogger
           
 
Field Summary
protected  MsgHandler.AbilityLogger abilityLogger
           
protected  java.util.Hashtable abilityQueryTable
           
protected static int ADD
           
protected  java.util.Hashtable addressQueryTable
           
(package private)  java.util.Vector attributeNodes
           
(package private) static int cleanupInterval
           
protected  AgentContext context
           
protected static int DELETE
           
protected  HSet[] eventMonitor
           
protected static int FAIL
           
protected static int FIRE
           
protected  Queue handleQ
           
protected  RootNode MessageRootNode
           
protected  boolean processing
           
protected  MsgHandler.ReportLogger reportLogger
           
protected  java.util.Hashtable reportQueryTable
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
MsgHandler()
           
MsgHandler(AgentContext context)
           
 
Method Summary
 void add_agents_abilities(Performative msg)
           
 void add_information(Performative msg)
           
 void add_task(Performative msg)
           
 void addMessageHandlerMonitor(MessageHandlerMonitor monitor, long event_type)
          If your code needs to react to changes in the MessageHandler use this to add a MessageHandlerMonitor.
 void address_of(Performative msg)
           
 void addRule(MessageRule r)
           
protected  void adviseAll(Address addr)
           
 void cancel_address(Performative msg)
           
 void cancel_message(Performative msg)
           
 void cancel_report(Performative msg)
           
 void cancel_specified_ability(Performative msg)
           
private  void debug(java.lang.String str)
           
 void delete_task(Performative msg)
           
protected  java.util.Vector dereference(java.util.Vector input)
          Replication to handle the problem of variable clashes when agents communicate with one another with variables in the content data;
 void deregister(Performative msg)
           
 java.lang.Object execRule(java.lang.String rule, java.lang.Object object, java.lang.String method, Performative input)
           
protected  void failure(Performative msg, java.lang.String content)
           
 AgentContext getAgentContext()
           
 Queue getMessageQueue()
           
 void has_ability(Performative msg)
           
protected  void inform(Performative msg, java.lang.String content)
           
 void isa_facilitator(Performative msg)
           
 void kill_yourself(Performative msg)
           
 void log_address(Performative msg)
           
 void log_message(Performative msg)
           
 void log_report(Performative msg)
           
 void log_specified_ability(Performative msg)
           
 void lowerStatus()
           
 void modify_task(Performative msg)
           
protected  void not_understood(Performative msg, java.lang.String content)
           
protected  void notifyMonitors(int type, MessageHandlerEvent event)
           
 void processMessage(Performative msg)
          in old versions of Zeus the msgHandler was responsible for ensuring that incomming messages were processed.
protected  void refuse(Performative msg, java.lang.String content)
           
 void register(Performative msg)
           
 void removeMessageHandlerMonitor(MessageHandlerMonitor monitor, long event_type)
           
 void removeRule(java.lang.String name)
           
 void run()
          thread main method - try and read incomming messages until the universe ends
private  void sendInstance(Task task, AgentContext context, java.lang.String target, java.lang.String replyWith)
           
private  void sendInstanceRange(Task task, AgentContext context, java.lang.String target, java.lang.String replyWith)
           
private  void sendProcess(Task task, AgentContext context, java.lang.String target, java.lang.String replyWith)
           
private  void sendProfile(Task task, AgentContext context, java.lang.String target, java.lang.String replyWith)
           
protected  void sendServiceDescriptions(java.lang.String target, java.lang.String replyWith)
           
 void stopProcessing()
           
private  MailBox waitForSetUp()
          refactored to help readability - this method loops until it gets a valid MailBox from the agent, so that the system can initialise in the right order
 void your_abilities(Performative msg)
           
 void your_relations(Performative msg)
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

eventMonitor

protected HSet[] eventMonitor

ADD

protected static final int ADD
See Also:
Constant Field Values

FIRE

protected static final int FIRE
See Also:
Constant Field Values

DELETE

protected static final int DELETE
See Also:
Constant Field Values

FAIL

protected static final int FAIL
See Also:
Constant Field Values

addressQueryTable

protected java.util.Hashtable addressQueryTable

abilityQueryTable

protected java.util.Hashtable abilityQueryTable

reportQueryTable

protected java.util.Hashtable reportQueryTable

reportLogger

protected MsgHandler.ReportLogger reportLogger

abilityLogger

protected MsgHandler.AbilityLogger abilityLogger

processing

protected boolean processing

context

protected AgentContext context

MessageRootNode

protected RootNode MessageRootNode

attributeNodes

java.util.Vector attributeNodes

cleanupInterval

static int cleanupInterval

handleQ

protected Queue handleQ
Constructor Detail

MsgHandler

public MsgHandler()

MsgHandler

public MsgHandler(AgentContext context)
Method Detail

getAgentContext

public AgentContext getAgentContext()

lowerStatus

public void lowerStatus()

stopProcessing

public void stopProcessing()

waitForSetUp

private MailBox waitForSetUp()
refactored to help readability - this method loops until it gets a valid MailBox from the agent, so that the system can initialise in the right order


run

public void run()
thread main method - try and read incomming messages until the universe ends


processMessage

public void processMessage(Performative msg)
in old versions of Zeus the msgHandler was responsible for ensuring that incomming messages were processed. However this approach meant that reengineering of the msgHandler would be necessary whenever a mailbox was built that had more than one server - basically this was a problem in terms of both coupling the mailbox,server and msgHandler objects and reducing the coheasion of the msgHandler.

solution: processMessage is a method that can be called by any object to see if message rules have been set that apply to this message. The servers (inboxes) are responsible for calling this method which will process the message for them - or not as they like.

This method puts the message on a queue, which is internal to the msgHandler. The thread run by msgHandler will then process it. //synch


getMessageQueue

public Queue getMessageQueue()

addRule

public void addRule(MessageRule r)

removeRule

public void removeRule(java.lang.String name)

execRule

public java.lang.Object execRule(java.lang.String rule,
                                 java.lang.Object object,
                                 java.lang.String method,
                                 Performative input)

adviseAll

protected void adviseAll(Address addr)

register

public void register(Performative msg)

deregister

public void deregister(Performative msg)

kill_yourself

public void kill_yourself(Performative msg)

add_task

public void add_task(Performative msg)

modify_task

public void modify_task(Performative msg)

delete_task

public void delete_task(Performative msg)

cancel_message

public void cancel_message(Performative msg)

cancel_report

public void cancel_report(Performative msg)

cancel_specified_ability

public void cancel_specified_ability(Performative msg)

cancel_address

public void cancel_address(Performative msg)

log_message

public void log_message(Performative msg)

log_report

public void log_report(Performative msg)

log_address

public void log_address(Performative msg)

log_specified_ability

public void log_specified_ability(Performative msg)

address_of

public void address_of(Performative msg)

your_abilities

public void your_abilities(Performative msg)

sendServiceDescriptions

protected void sendServiceDescriptions(java.lang.String target,
                                       java.lang.String replyWith)

sendProfile

private void sendProfile(Task task,
                         AgentContext context,
                         java.lang.String target,
                         java.lang.String replyWith)

sendInstance

private void sendInstance(Task task,
                          AgentContext context,
                          java.lang.String target,
                          java.lang.String replyWith)

sendInstanceRange

private void sendInstanceRange(Task task,
                               AgentContext context,
                               java.lang.String target,
                               java.lang.String replyWith)

sendProcess

private void sendProcess(Task task,
                         AgentContext context,
                         java.lang.String target,
                         java.lang.String replyWith)

your_relations

public void your_relations(Performative msg)

has_ability

public void has_ability(Performative msg)

isa_facilitator

public void isa_facilitator(Performative msg)

add_agents_abilities

public void add_agents_abilities(Performative msg)

add_information

public void add_information(Performative msg)

refuse

protected void refuse(Performative msg,
                      java.lang.String content)

failure

protected void failure(Performative msg,
                       java.lang.String content)

not_understood

protected void not_understood(Performative msg,
                              java.lang.String content)

inform

protected void inform(Performative msg,
                      java.lang.String content)

addMessageHandlerMonitor

public void addMessageHandlerMonitor(MessageHandlerMonitor monitor,
                                     long event_type)
If your code needs to react to changes in the MessageHandler use this to add a MessageHandlerMonitor. This provides a programatic alternative to writing reaction rules


removeMessageHandlerMonitor

public void removeMessageHandlerMonitor(MessageHandlerMonitor monitor,
                                        long event_type)

notifyMonitors

protected void notifyMonitors(int type,
                              MessageHandlerEvent event)

dereference

protected final java.util.Vector dereference(java.util.Vector input)
Replication to handle the problem of variable clashes when agents communicate with one another with variables in the content data;


debug

private void debug(java.lang.String str)


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