repserver
Class RepAgent

java.lang.Object
  |
  +--fipaos.agent.FIPAOSAgent
        |
        +--repserver.RepAgent
All Implemented Interfaces:
fipaos.agent.conversation.ConversationListener, LocalMsg
Direct Known Subclasses:
MMAgent, PersAgent

public abstract class RepAgent
extends fipaos.agent.FIPAOSAgent
implements LocalMsg

RepAgent is an abstract class representing an agent shell suitable for use with a replication server. It is an extension of the standard FIPAOSAgent shell. It adds variables to store the id of the replication server associated with this agent, the name of the replicant group this agent belongs to, the agentID of the message proxy for the replicant group and the current role of the agent.

Responses to various repserver-management tasks are included. The person using this is responsible for including an appropriate set of code in the agents IDLECLASS which will call the message handlers.

A setAState and getAState method stub is included in this abstract class. The user must override these as appropriate.


Inner Class Summary
 class RepAgent.RegisterTask
          RegisterTask, registers an agent with a RepGroup
 class RepAgent.RepServerManagementTask
          Handles other RepServerManagementTask functions.
 class RepAgent.StateTask
          StateTask sends a request to the repserver, then when an AGREE comes back send an INFORM with the agent state in the content field.
 
Inner classes inherited from class fipaos.agent.FIPAOSAgent
fipaos.agent.FIPAOSAgent.TopLevelHandlerTask
 
Fields inherited from class fipaos.agent.FIPAOSAgent
_database_profile, _registered_with, _state, _tm
 
Constructor Summary
RepAgent(java.lang.String platform_profile_location, java.lang.String agent_name, java.lang.String ownership, fipaos.ont.fipa.fipaman.AgentID rs, java.lang.String role, java.lang.String group_name)
          Constructor.
 
Method Summary
 void doneRepAgent_RegisterTask(fipaos.agent.task.Task t)
           
 byte[] getAState()
          returns a byte stream representing the current state of this agent.
 int getConvs()
          Get the number of current conversations
 java.lang.String getGroupName()
          Return the group name of the replicant group this agent is registered with
 LocalPostOffice getLocalPostOffice()
           
 fipaos.ont.fipa.fipaman.AgentID getProxyAID()
          Return the AgentID of the message proxy this agent is registered with
 fipaos.ont.fipa.fipaman.AgentID getReceiver(fipaos.ont.fipa.ACL acl)
          retreive the replytoAID.
 fipaos.ont.fipa.fipaman.AgentID getRepServer()
          Returns the AgentID of this agents RepServer
 java.lang.String getRole()
          Returns the current role of this REPLICANT
 void goActive()
          Code to execute when this agent is set to ACTIVE_AGENT.
 boolean isActiveAgent()
          Returns true if this agent is currently in ACTIVE_AGENT role
 boolean isReplicant()
          Returns true if this agent is currently in REPLICANT role
 void removeConv(fipaos.agent.conversation.Conversation conv)
          remove the given conversation
 boolean sendReply(fipaos.ont.fipa.ACL orig_acl, java.lang.String performative)
           
 boolean sendReply(fipaos.ont.fipa.ACL orig_acl, java.lang.String performative, java.lang.String content)
          Send a reply message in response to the given ACL message
 boolean setAState(byte[] state)
          sets the state for this agent.
 void setLocalPostOffice(LocalPostOffice lpo)
           
 void setRepServer(fipaos.ont.fipa.fipaman.AgentID aid)
           
 boolean setRole(java.lang.String role)
          Sets the role of this agent.
 
Methods inherited from class fipaos.agent.FIPAOSAgent
activate, addNewProtocol, deregisterWithAMS, deregisterWithDF, forward, forward, getAID, getCM, getCurrentConversation, getHAP, getLocalAMS, getLocalAMSAID, getLocalDF, getLocalDFAID, getNewConversation, getOwnership, getPlatformProfile, getProfile, getState, isShutdown, knowsProtocol, notify, notify, notifyDone, notifyError, notifyMessageInEndedConversation, notifyMessageUndeliverable, notifyTimeout, registeredWith, registeredWithAMS, registeredWithDF, registerWithAMS, registerWithAMS, registerWithAMS, registerWithAMS, registerWithDF, registerWithDF, registerWithDF, registerWithDF, sendNotUnderstood, sendNotUnderstood, setListenerTask, setMessageSender, shutdown, startPushing, waitForPushLock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RepAgent

public RepAgent(java.lang.String platform_profile_location,
                java.lang.String agent_name,
                java.lang.String ownership,
                fipaos.ont.fipa.fipaman.AgentID rs,
                java.lang.String role,
                java.lang.String group_name)
Constructor. Call the FIPAOSAgent constructor but also set the role, group name and replication server.
Method Detail

setLocalPostOffice

public void setLocalPostOffice(LocalPostOffice lpo)
Specified by:
setLocalPostOffice in interface LocalMsg

getLocalPostOffice

public LocalPostOffice getLocalPostOffice()
Specified by:
getLocalPostOffice in interface LocalMsg

isActiveAgent

public boolean isActiveAgent()
Returns true if this agent is currently in ACTIVE_AGENT role

isReplicant

public boolean isReplicant()
Returns true if this agent is currently in REPLICANT role

getRole

public java.lang.String getRole()
Returns the current role of this REPLICANT

setRole

public boolean setRole(java.lang.String role)
Sets the role of this agent. If the switch is from REPLICANT to ACTIVE_AGENT, call the goActive() method
Parameters:
role - String representing the role, see RSCONSTANTS.

getRepServer

public fipaos.ont.fipa.fipaman.AgentID getRepServer()
Returns the AgentID of this agents RepServer

setRepServer

public void setRepServer(fipaos.ont.fipa.fipaman.AgentID aid)

doneRepAgent_RegisterTask

public void doneRepAgent_RegisterTask(fipaos.agent.task.Task t)

getGroupName

public java.lang.String getGroupName()
Return the group name of the replicant group this agent is registered with

getProxyAID

public fipaos.ont.fipa.fipaman.AgentID getProxyAID()
Return the AgentID of the message proxy this agent is registered with

goActive

public void goActive()
Code to execute when this agent is set to ACTIVE_AGENT. This method should be overridden when implementing an agent.

getAState

public byte[] getAState()
returns a byte stream representing the current state of this agent. This should be overridden by the implementing agent.

setAState

public boolean setAState(byte[] state)
sets the state for this agent.
Parameters:
state - a byte stream representing the state of this agent. returns true if successful.

getReceiver

public fipaos.ont.fipa.fipaman.AgentID getReceiver(fipaos.ont.fipa.ACL acl)
retreive the replytoAID. Convenience method

sendReply

public boolean sendReply(fipaos.ont.fipa.ACL orig_acl,
                         java.lang.String performative,
                         java.lang.String content)
Send a reply message in response to the given ACL message
Parameters:
acl - The ACL object to reply to
reason - Any additional message

sendReply

public boolean sendReply(fipaos.ont.fipa.ACL orig_acl,
                         java.lang.String performative)

getConvs

public int getConvs()
Get the number of current conversations

removeConv

public void removeConv(fipaos.agent.conversation.Conversation conv)
remove the given conversation