mam.agent
Class Agent

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--mam.agent.Agent
Direct Known Subclasses:
AnalyzeAgent, MonitorAgent, OddAgent, TransactionalAgent, UrlKnowledgeAgent, WebServerAgent

public class Agent
extends Thread
implements MessageReceiver, Serializable, XmlSerializable

Basic Agent class Implements the necessary Agent interface messages from that interface.

Author:
nideffer
created November 25, 2001

Field Summary
 final static StringAGENT_ACCESS_STATISTICS_TAG_NAME
           
 final static StringAGENT_PROPERTIES_TAG_NAME
           
 final static StringAGENT_TRAITS_TAG_NAME
           
 final static RoutingTagALL_AGENTS_ROUTING_TAG
           
 final static StringDEFAULT_TAG_NAME
           
 protected AccessStatisticsGroupm_accessStatisticsGroup
           
 protected AgentPropertiesm_agentProperties
           
 protected Facilitym_facility
           
 protected MessageQueuem_incomingMessageQueue
           
 protected booleanm_shutdown
           
 protected SleepManagerm_sleepManager
           
 private booleanm_xmlSerializable
           
 final static StringROLE_TAG_NAME
           

Fields inherited from class java.lang.Thread
MIN_PRIORITY, NORM_PRIORITY, MAX_PRIORITY

Constructor Summary
Agent()
          Constructor for the Agent object
Agent(Facility facility, AgentProperties defaultAgentProperties)
          Constructor for the Agent object

Method Summary
 synchronized voidenqueueMessage(AgentMessage incomingMessage)
          Description of the Method
 voidfromXmlElement(Element source)
          Description of the Method
 AccessStatisticsGroupgetAccessStatisticsGroup()
          Gets the AccessStatisticsGroup attribute of the Agent object
 AccountgetAccount()
          Gets the Account attribute of the Agent object
 AgentPropertiesgetAgentProperties()
          Gets the AgentProperties attribute of the Agent object
 AgentTraitsgetAgentTraits()
          Gets the AgentTraits attribute of the Agent object
 StringgetDescription()
          Gets the Description attribute of the Agent object
 protected FacilitygetFacility()
          Gets the Facility attribute of the Agent object
 MamIdgetMamId()
          Gets the MamId attribute of the Agent object
 StringgetNickname()
          Gets the Nickname attribute of the Agent object
 StringgetQuote()
          Gets the Quote attribute of the Agent object
 StringgetRole()
          Gets the Role attribute of the Agent object
 RoutingTaggetRoutingTagToSelf()
          Gets the RoutingTagToSelf attribute of the Agent object
 booleangetXmlSerializable()
          Gets the XmlSerializable attribute of the Agent object
 voidhandleDoAgentShutdownMessage(AgentMessage m)
          Description of the Method
 voidhandleGetAccessStatisticsMessage(AgentMessage m)
          Description of the Method
 voidhandleGetAgentPropertiesMessage(AgentMessage m)
          Description of the Method
 voidhandleGetAgentTraitsMessage(AgentMessage m)
          Message Handling notes: For some reason, the reflection mechanism fails when dealing with protected methods.
 voidhandleGetQuoteMessage(AgentMessage m)
          Description of the Method
 protected voidhandleMessages()
          Generic message handler Override this method to provide custom message handling.
 voidhandleSetDescriptionMessage(AgentMessage m)
          Description of the Method
 voidhandleSetNicknameMessage(AgentMessage m)
          Description of the Method
 protected voididleActivity()
          Description of the Method
 protected voidinvokeMessageHandler(AgentMessage message)
          Utility method to use reflection to invoke the standard handler for whatever message is passed.
 protected voidregisterRoutingTags()
          Description of the Method
 booleanrequiresPersistence()
          Description of the Method
 voidrun()
          A basic message handling loop.
 voidsetAccount(Account account)
          Sets the Account attribute of the Agent object
 voidsetAgentTraits(AgentTraits agentTraits)
          Sets the AgentTraits attribute of the Agent object
 voidsetDescription(String description)
          Sets the Description attribute of the Agent object
 voidsetFacility(Facility localFacility)
          Sets the Facility attribute of the Agent object
 voidsetMamId(MamId newMamId)
          Sets the MamId attribute of the Agent object
 voidsetNickname(String nickname)
          Sets the Nickname attribute of the Agent object
 voidsetRole(String role)
          Sets the Role attribute of the Agent object
 protected voidsetXmlSerializable(boolean xmlSerializable)
          Sets the XmlSerializable attribute of the Agent object
 StringtoString()
          Description of the Method
 ElementtoXmlElement()
          Description of the Method
 ElementtoXmlElement(String tagName)
          Description of the Method
 protected voidunregisterRoutingTags()
          Description of the Method

Methods inherited from class java.lang.Thread
currentThread, yield, sleep, sleep, start, stop, stop, interrupt, interrupted, isInterrupted, destroy, isAlive, suspend, resume, setPriority, getPriority, setName, getName, getThreadGroup, activeCount, enumerate, countStackFrames, join, join, join, dumpStack, setDaemon, isDaemon, checkAccess, getContextClassLoader, setContextClassLoader

Methods inherited from class java.lang.Object
getClass, hashCode, equals, clone, notify, notifyAll, wait, wait, wait, finalize

Field Detail

AGENT_ACCESS_STATISTICS_TAG_NAME

public final static String AGENT_ACCESS_STATISTICS_TAG_NAME

AGENT_PROPERTIES_TAG_NAME

public final static String AGENT_PROPERTIES_TAG_NAME

AGENT_TRAITS_TAG_NAME

public final static String AGENT_TRAITS_TAG_NAME

ALL_AGENTS_ROUTING_TAG

public final static RoutingTag ALL_AGENTS_ROUTING_TAG

DEFAULT_TAG_NAME

public final static String DEFAULT_TAG_NAME

m_accessStatisticsGroup

protected AccessStatisticsGroup m_accessStatisticsGroup

m_agentProperties

protected AgentProperties m_agentProperties

m_facility

protected Facility m_facility

m_incomingMessageQueue

protected MessageQueue m_incomingMessageQueue

m_shutdown

protected boolean m_shutdown

m_sleepManager

protected SleepManager m_sleepManager

m_xmlSerializable

private boolean m_xmlSerializable

ROLE_TAG_NAME

public final static String ROLE_TAG_NAME
Constructor Detail

Agent

public Agent()
Constructor for the Agent object
Since:

Agent

public Agent(Facility facility, AgentProperties defaultAgentProperties)
Constructor for the Agent object
Parameters:
facility - Description of Parameter
defaultAgentProperties - Description of Parameter
Since:
Method Detail

enqueueMessage

public synchronized void enqueueMessage(AgentMessage incomingMessage)
Description of the Method
Parameters:
incomingMessage - Description of Parameter
Since:

fromXmlElement

public void fromXmlElement(Element source)
Description of the Method
Parameters:
source - Description of Parameter
Since:

getAccessStatisticsGroup

public AccessStatisticsGroup getAccessStatisticsGroup()
Gets the AccessStatisticsGroup attribute of the Agent object
Returns: The AccessStatisticsGroup value
Since:

getAccount

public Account getAccount()
Gets the Account attribute of the Agent object
Returns: The Account value
Since:

getAgentProperties

public AgentProperties getAgentProperties()
Gets the AgentProperties attribute of the Agent object
Returns: The AgentProperties value
Since:

getAgentTraits

public AgentTraits getAgentTraits()
Gets the AgentTraits attribute of the Agent object
Returns: The AgentTraits value
Since:

getDescription

public String getDescription()
Gets the Description attribute of the Agent object
Returns: The Description value
Since:

getFacility

protected Facility getFacility()
Gets the Facility attribute of the Agent object
Returns: The Facility value
Since:

getMamId

public MamId getMamId()
Gets the MamId attribute of the Agent object
Returns: The MamId value
Since:

getNickname

public String getNickname()
Gets the Nickname attribute of the Agent object
Returns: The Nickname value
Since:

getQuote

public String getQuote()
Gets the Quote attribute of the Agent object
Returns: The Quote value
Since:

getRole

public String getRole()
Gets the Role attribute of the Agent object
Returns: The Role value
Since:

getRoutingTagToSelf

public RoutingTag getRoutingTagToSelf()
Gets the RoutingTagToSelf attribute of the Agent object
Returns: The RoutingTagToSelf value
Since:

getXmlSerializable

public boolean getXmlSerializable()
Gets the XmlSerializable attribute of the Agent object
Returns: The XmlSerializable value
Since:

handleDoAgentShutdownMessage

public void handleDoAgentShutdownMessage(AgentMessage m)
Description of the Method
Parameters:
m - Description of Parameter
Since:

handleGetAccessStatisticsMessage

public void handleGetAccessStatisticsMessage(AgentMessage m)
Description of the Method
Parameters:
m - Description of Parameter
Since:

handleGetAgentPropertiesMessage

public void handleGetAgentPropertiesMessage(AgentMessage m)
Description of the Method
Parameters:
m - Description of Parameter
Since:

handleGetAgentTraitsMessage

public void handleGetAgentTraitsMessage(AgentMessage m)
Message Handling notes: For some reason, the reflection mechanism fails when dealing with protected methods. Therefore, all the basic messages must be public in order to let descendents use them. Not sure why this is happening... will look into it.
Parameters:
m - Description of Parameter
Since:

handleGetQuoteMessage

public void handleGetQuoteMessage(AgentMessage m)
Description of the Method
Parameters:
m - Description of Parameter
Since:

handleMessages

protected void handleMessages()
Generic message handler Override this method to provide custom message handling. Default is to handle messages one at a time, in the order they come in. Send an error message if you don't know how to handle a given message.
Since:

handleSetDescriptionMessage

public void handleSetDescriptionMessage(AgentMessage m)
Description of the Method
Parameters:
m - Description of Parameter
Since:

handleSetNicknameMessage

public void handleSetNicknameMessage(AgentMessage m)
Description of the Method
Parameters:
m - Description of Parameter
Since:

idleActivity

protected void idleActivity()
Description of the Method
Since:

invokeMessageHandler

protected void invokeMessageHandler(AgentMessage message)
throws java.lang.Exception
Utility method to use reflection to invoke the standard handler for whatever message is passed.
Parameters:
message - Description of Parameter
Throws:
Exception - Description of Exception
Since:

registerRoutingTags

protected void registerRoutingTags()
Description of the Method
Since:

requiresPersistence

public boolean requiresPersistence()
Description of the Method
Returns: Description of the Returned Value
Since:

run

public void run()
A basic message handling loop. All it does is sit and listen for messages, and then respond to each message it gets. Shuts down when the NMS does.
Since:

setAccount

public void setAccount(Account account)
Sets the Account attribute of the Agent object
Parameters:
account - The new Account value
Since:

setAgentTraits

public void setAgentTraits(AgentTraits agentTraits)
Sets the AgentTraits attribute of the Agent object
Parameters:
agentTraits - The new AgentTraits value
Since:

setDescription

public void setDescription(String description)
Sets the Description attribute of the Agent object
Parameters:
description - The new Description value
Since:

setFacility

public void setFacility(Facility localFacility)
Sets the Facility attribute of the Agent object
Parameters:
localFacility - The new Facility value
Since:

setMamId

public void setMamId(MamId newMamId)
Sets the MamId attribute of the Agent object
Parameters:
newMamId - The new MamId value
Since:

setNickname

public void setNickname(String nickname)
Sets the Nickname attribute of the Agent object
Parameters:
nickname - The new Nickname value
Since:

setRole

public void setRole(String role)
Sets the Role attribute of the Agent object
Parameters:
role - The new Role value
Since:

setXmlSerializable

protected void setXmlSerializable(boolean xmlSerializable)
Sets the XmlSerializable attribute of the Agent object
Parameters:
xmlSerializable - The new XmlSerializable value
Since:

toString

public String toString()
Description of the Method
Returns: Description of the Returned Value
Since:

toXmlElement

public Element toXmlElement()
Description of the Method
Returns: Description of the Returned Value
Since:

toXmlElement

public Element toXmlElement(String tagName)
Description of the Method
Parameters:
tagName - Description of Parameter
Returns: Description of the Returned Value
Since:

unregisterRoutingTags

protected void unregisterRoutingTags()
Description of the Method
Since: