fipaos.agent
Class FIPAOSAgent

Direct Known Subclasses:
PingAgent, AgentManagementSystem, DFGUIAgent, DirectoryFacilitator, JessAgent, AgentMessagingTest.TestAgent, MessageTimingAgent, IOTestAgent, MarketManagerAgent, SubscribingAgent, GenericAgent, PingAgent, SearchAgent

public abstract class FIPAOSAgent
implements ConversationListener

Base FIPA-OS agent class implementing FIPA-OS specifics for agent to agent communication. Override

notify()
deal with updated Conversations directly in the underlying Agent implementation, or use the
setListenerTask()
to set a default Task if you wish to use the TaskManager to implement the Agent.


Inner Class Summary
 public classFIPAOSAgent.TopLevelHandlerTask
           

Field Summary
 List_registered_with
          List of Agents that this Agent is registered with
 String_state
          Agent states: unknown, waiting, suspended, transit, initiated, active

Constructor Summary
FIPAOSAgent(String platform_profile_location, String agent_name, String ownership)
          Constructor method to initialise an Agent.
FIPAOSAgent(String platform_profile_location, String agent_name, String ownership, boolean using_task_manager)
          Constructor method to initialise an Agent.
FIPAOSAgent(PlatformProfile platform_profile, AgentProfile agent_profile, String agent_name, String ownership, boolean using_task_manager)
          Constructor method to initialise an Agent.
FIPAOSAgent(PlatformProfile platform_profile, AgentProfile agent_profile, String agent_name, String ownership, boolean using_task_manager, FIPAOSAgentComponentFactory factory)
          Constructor method to initialise an Agent.

Method Summary
 voidactivate()
          This method should be overriden by the FIPAOSAgent - it is invoked when the user of the local machine wishes it to do something (usually display a GUI) By default it does nothing
 voidforward(ACL acl)
          Forward an acl message out via the ConversationManagerImpl
 voidforward(Message msg)
          Forward an message out via the ConversationManager
 AgentIDgetAID()
          Gets the AgentID of this Agent
 ConversationgetCurrentConversation(String conv)
          Method to retreive a conversation from the active list
 StringgetHAP()
          Gets the local HAP name
 StringgetLocalAMS()
          Returns the agent AID of the local platform AMS.
 AgentIDgetLocalAMSAID()
          Returns the agent AID of the local platform AMS.
 StringgetLocalDF()
          Returns the agent AID of the local platform DF.
 AgentIDgetLocalDFAID()
          Returns the agent AID of the local platform DF.
 ConversationgetNewConversation(String protocol)
          Method to get a new Conversation object from the conversation manager given the protocol specified
 StringgetOwnership()
          Returns the ownership id of the agent.
 PlatformProfilegetPlatformProfile()
          Gets the platform profile for this Agent
 AgentProfilegetProfile()
          Gets the profile for this Agent
 StringgetState()
          Returns the state of the agent Currently, only 2 states might be returned: "unknown" and "active"
 booleanisShutdown()
          Indicates if this Agent has been shutdown
 voidnotify(Conversation conv)
          Conversation listener method to deal with conversations being sent by the planner scheduler.
 voidnotify(Enumeration enum)
          Deals with multiple conversations at once - just calls notify( Conversation ) for each one.
 voidnotifyDone(Task child, String method, Object result)
          Default method invoked to dispatch done callbacks - override this with a method to dispatch the callback statically to improve efficiency :)
 voidnotifyError(Task child, String method, Throwable error)
          Default method invoked to dispatch error callbacks - override this with a method to dispatch the callback statically to improve efficiency :)
 voidnotifyMessageInEndedConversation(Message msg)
          Indicates that the given Message arrived for a completed Conversation - override to deal with this if a TaskManager is not in use
 voidnotifyMessageUndeliverable(Message msg)
          Indicates that the given Message was not deliverable - override to deal with this if a TaskManager is not in use
 voidnotifyTimeout(Task child, String method)
          Default method invoked to dispatch timeout callbacks - override this with a method to dispatch the callback statically to improve efficiency :)
 booleansendNotUnderstood(ACL orig_acl)
          Send a not understood message in response to the given ACL message
 booleansendNotUnderstood(ACL orig_acl, String reason)
          Send a not understood message in response to the given ACL message
 voidsetMessageSender(MessageSender ms)
          Sets the MessageSender for this
 synchronized voidshutdown()
          Shutdown the Agent safely
 voidwaitForPushLock()
          Blocks until the Agent is ready to receive messages/conversations

Field Detail

_registered_with

public List _registered_with
List of Agents that this Agent is registered with

_state

public String _state
Agent states: unknown, waiting, suspended, transit, initiated, active
Constructor Detail

FIPAOSAgent

public FIPAOSAgent(String platform_profile_location, String agent_name, String ownership)
Constructor method to initialise an Agent. This loads the AgentProfile and creates an AgentComms instance for the Agent with the required CommsTransports. This constructor creates an agent that uses the Task Manager by default. This is going to be the required way of creating an agent in future versions of FIPA-OS, so this constructor should provide forward compatability. It will initialise the agent to use the Conversation Manager as well (as this is required for use of the Task Manager).
Parameters:
platform_profile_location - The location of the platform.profile (a fully qualified file name)
agent_name - globally unique identifier for the agent
ownership - the ownership of the agent

FIPAOSAgent

public FIPAOSAgent(String platform_profile_location, String agent_name, String ownership, boolean using_task_manager)
Constructor method to initialise an Agent. This loads the AgentProfile and creates an AgentComms instance for the Agent with the required CommsTransports. Can optionally create a Task Manager in the agent. If you are using the task manager then you must also call setListenerTask( Task ) in your constructor code in order to set up the default task. This default task handles all incoming messages that are new (i.e. that are not replies to message that we have previously sent). If you do not register a default task then incoming messages will be ignored.
Parameters:
platform_profile_location - The location of the platform.profile (a fully qualified file name)
agent_name - unique name of the Agent within its platform
ownership - the ownership of the agent
using_task_manager - Selected if a task manager is to be used

FIPAOSAgent

public FIPAOSAgent(PlatformProfile platform_profile, AgentProfile agent_profile, String agent_name, String ownership, boolean using_task_manager)
Constructor method to initialise an Agent. This uses the given AgentProfile and creates an MTS instance for the Agent with the required MTP's. Can optionally create a Task Manager in the agent. If you are using the task manager then you must also call setListenerTask( Task ) in your constructor code in order to set up the default task. This default task handles all incoming messages that are new (i.e. that are not replies to message that we have previously sent). If you do not register a default task then incoming messages will be ignored.
Parameters:
platform_profile - Representation of the Platform's profile
agent_profile - Representation of the Agent's profile
agent_name - unique name of the Agent within its platform
ownership - the ownership of the agent
using_task_manager - Selected if a task manager is to be used

FIPAOSAgent

public FIPAOSAgent(PlatformProfile platform_profile, AgentProfile agent_profile, String agent_name, String ownership, boolean using_task_manager, FIPAOSAgentComponentFactory factory)
Constructor method to initialise an Agent. This uses the given AgentProfile and creates an MTS instance for the Agent with the required MTP's. Can optionally create a Task Manager in the agent. If you are using the task manager then you must also call setListenerTask( Task ) in your constructor code in order to set up the default task. This default task handles all incoming messages that are new (i.e. that are not replies to message that we have previously sent). If you do not register a default task then incoming messages will be ignored.
Parameters:
platform_profile - Representation of the Platform's profile
agent_profile - Representation of the Agent's profile
agent_name - unique name of the Agent within its platform
ownership - the ownership of the agent
using_task_manager - Selected if a task manager is to be used
factory - Factory to be used to generate Agent components
Method Detail

activate

public void activate()
This method should be overriden by the FIPAOSAgent - it is invoked when the user of the local machine wishes it to do something (usually display a GUI)

By default it does nothing


forward

public void forward(ACL acl)
Forward an acl message out via the ConversationManagerImpl
Parameters:
acl - ACL containing an agent communication language (acl) message

forward

public void forward(Message msg)
Forward an message out via the ConversationManager
Parameters:
msg - Message containing an agent communication language (acl) message and its associated envelope

getAID

public AgentID getAID()
Gets the AgentID of this Agent

getCurrentConversation

public Conversation getCurrentConversation(String conv)
throws fipaos.agent.conversation.InvalidConversationIDException
Method to retreive a conversation from the active list
Parameters:
conv - The conversation id of the Conversation object to retreive

getHAP

public String getHAP()
Gets the local HAP name

getLocalAMS

public String getLocalAMS()
Returns the agent AID of the local platform AMS.
Returns: The local AMS GUID

getLocalAMSAID

public AgentID getLocalAMSAID()
Returns the agent AID of the local platform AMS.
Returns: The local AMS GUID

getLocalDF

public String getLocalDF()
Returns the agent AID of the local platform DF.
Returns: The local DF GUID

getLocalDFAID

public AgentID getLocalDFAID()
Returns the agent AID of the local platform DF.
Returns: The local DF GUID

getNewConversation

public Conversation getNewConversation(String protocol)
throws fipaos.agent.conversation.UnknownProtocolException
Method to get a new Conversation object from the conversation manager given the protocol specified

getOwnership

public String getOwnership()
Returns the ownership id of the agent.

getPlatformProfile

public PlatformProfile getPlatformProfile()
Gets the platform profile for this Agent

getProfile

public AgentProfile getProfile()
Gets the profile for this Agent

getState

public String getState()
Returns the state of the agent Currently, only 2 states might be returned: "unknown" and "active"

isShutdown

public boolean isShutdown()
Indicates if this Agent has been shutdown

notify

public void notify(Conversation conv)
Conversation listener method to deal with conversations being sent by the planner scheduler. These should be overriden as default by the sub-class if necessary
Parameters:
conv - The updated conversation to deal with

notify

public void notify(Enumeration enum)
Deals with multiple conversations at once - just calls notify( Conversation ) for each one. Override in sub class to replace this behavior. ( NOTE: When overriding this method, it should be noted that care should be taken because this method could be invoked at any time after the FIPAOSAgent() constructor had been used. Normally this method doesn't do anything until after startPushing() is invoked).
Parameters:
enum - An enumeration of updated conversations to deal with

notifyDone

public void notifyDone(Task child, String method, Object result)
Default method invoked to dispatch done callbacks - override this with a method to dispatch the callback statically to improve efficiency :)
Parameters:
child - Child-Task that has completed
method - Name of the method to invoke
result - Result associated with the completion (null if no result given)

notifyError

public void notifyError(Task child, String method, Throwable error)
Default method invoked to dispatch error callbacks - override this with a method to dispatch the callback statically to improve efficiency :)
Parameters:
child - Child-Task that has failed
method - Name of the method to invoke

notifyMessageInEndedConversation

public void notifyMessageInEndedConversation(Message msg)
Indicates that the given Message arrived for a completed Conversation - override to deal with this if a TaskManager is not in use

notifyMessageUndeliverable

public void notifyMessageUndeliverable(Message msg)
Indicates that the given Message was not deliverable - override to deal with this if a TaskManager is not in use

notifyTimeout

public void notifyTimeout(Task child, String method)
Default method invoked to dispatch timeout callbacks - override this with a method to dispatch the callback statically to improve efficiency :)
Parameters:
child - Child-Task that has timed-out
method - Name of the method to invoke

sendNotUnderstood

public boolean sendNotUnderstood(ACL orig_acl)
Send a not understood message in response to the given ACL message
Parameters:
acl - The ACL object to reply to

sendNotUnderstood

public boolean sendNotUnderstood(ACL orig_acl, String reason)
Send a not understood message in response to the given ACL message
Parameters:
acl - The ACL object to reply to
reason - The reason for not-understanding

setMessageSender

public void setMessageSender(MessageSender ms)
Sets the MessageSender for this

shutdown

public synchronized void shutdown()
Shutdown the Agent safely

waitForPushLock

public void waitForPushLock()
Blocks until the Agent is ready to receive messages/conversations

Association Links

to Class java.lang.String

to Class fipaos.mts.MessageSender

MessageSender to deal with our outgoing messages

to Class java.lang.Object

Lock used to prevent messages being pushed before the Agent is ready for them

to Class fipaos.agent.task.TaskManager

Task manager.

to Class fipaos.agent.conversation.ConversationManager

Conversation manager.

to Class fipaos.mts.MTS

MTS for this Agent

to Class fipaos.ont.fipa.fipaman.AgentID

My AgentID

to Class fipaos.agent.profile.AgentProfile

My profile

to Class fipaos.agent.profile.PlatformProfile

Platform profile

to Class fipaos.agent.profile.DatabaseProfile

Database Profile

to Class java.lang.String

Ownership info

to Class fipaos.agent.FIPAOSAgent.TopLevelHandlerTask

Task to handle top-level task completions (i.e. pass callbacks to Agent implementation!)

to Class java.lang.String

Agent states: unknown, waiting, suspended, transit, initiated, active

to Class java.util.List

List of Agents that this Agent is registered with