fipaos.agent.conversation.standard
Class ConversationManagerImpl


public class ConversationManagerImpl
implements ConversationManager, Runnable

This class embodies the core functionality of the ConversationManagerImpl.


Constructor Summary
ConversationManagerImpl(ConversationListener cl, MessageSender ms, FIPAOSAgent agent, DatabaseProfile db_profile, ProtocolProfile protocol_profile)
          Create and initalise the CM.

Method Summary
 ConversationaddConversation(String protocol)
          Method to create a new conversation given a protcol, and add it to the active list
 booleanaddProtocol(String protocol_name, String protocol_defn)
          Adds a new protocol to the CM - the CM will attempt to learn the protocol and will cache it for future use.
 ConversationgetConversation(String conversation_id)
          Retrieves an active/previous Conversation that an Agent has had
 (package private) static StringgetProtocolClassName(String protocol)
          Returns the protocol class name for the protocol passed in to the method.
 voidhandleMessage(Message msg)
          Looks at a Message and checks to see if it part of an exisiting conversation.
 booleanhasProtocol(String protocol)
          Indicates whether the specified protocol is already in the cache, i.e.
 static voidmain(String[] args)
           
 voidreceiveMessage(Message msg)
          Received an incoming message - put it through the CM
 voidremoveConversation(String conversation_id)
          Moves a conversation from the Active to the conversation archive
 voidrun()
          Main thread for dealing with non-event based Conversation updates
 voidsendMessage(Message msg)
          Attempt to send the given message
 voidsetMessageReceiver(MessageReceiver p1)
          Attempt to set the receiver of incoming messages - not supported by this class!
 voidsetMessageSender(MessageSender p1)
           
 voidshutdown()
          Shutdown the CM

Constructor Detail

ConversationManagerImpl

public ConversationManagerImpl(ConversationListener cl, MessageSender ms, FIPAOSAgent agent, DatabaseProfile db_profile, ProtocolProfile protocol_profile)
Create and initalise the CM. This will invoked the setMessageSender() method on the ConversationListener passed as part of the initialisation
Method Detail

addConversation

public Conversation addConversation(String protocol)
throws fipaos.agent.conversation.UnknownProtocolException
Method to create a new conversation given a protcol, and add it to the active list

addProtocol

public boolean addProtocol(String protocol_name, String protocol_defn)
Adds a new protocol to the CM - the CM will attempt to learn the protocol and will cache it for future use.
Parameters:
protocol_name - The name of the protocol to store (e.g. fipa-new-protocol)
protocol_defn - The RDF definition of the protocol
Returns: True if the protocol was learned and stored correctly, false otherwise

getConversation

public Conversation getConversation(String conversation_id)
throws fipaos.agent.conversation.InvalidConversationIDException
Retrieves an active/previous Conversation that an Agent has had

getProtocolClassName

static String getProtocolClassName(String protocol)
throws fipaos.agent.conversation.UnknownProtocolException
Returns the protocol class name for the protocol passed in to the method. If no protocol class can be found then "NoProtocol" is returned. This will also be returned if you use the "no-protocol" protocol.
Parameters:
protocol - The protocol that you want the class name for
Returns: The class name for the protocol class, or NoProtocol

handleMessage

public void handleMessage(Message msg)
throws fipaos.agent.conversation.UnknownProtocolException,
fipaos.agent.conversation.InvalidConversationIDException,
fipaos.agent.conversation.ProtocolErrorException,
fipaos.agent.conversation.ConversationFinishedException
Looks at a Message and checks to see if it part of an exisiting conversation. if yes adds it to the conversation object in the conversation list. Otherwise, creates a new Conversation object

hasProtocol

public boolean hasProtocol(String protocol)
Indicates whether the specified protocol is already in the cache, i.e. has it already been learned.
Parameters:
protocol - The protocol to check for
Returns: True if the protocol has already been learned, false otherwise

main

public static void main(String[] args)

receiveMessage

public void receiveMessage(Message msg)
Received an incoming message - put it through the CM

removeConversation

public void removeConversation(String conversation_id)
Moves a conversation from the Active to the conversation archive

run

public void run()
Main thread for dealing with non-event based Conversation updates

sendMessage

public void sendMessage(Message msg)
Attempt to send the given message

setMessageReceiver

public void setMessageReceiver(MessageReceiver p1)
Attempt to set the receiver of incoming messages - not supported by this class!

setMessageSender

public void setMessageSender(MessageSender p1)

shutdown

public void shutdown()
Shutdown the CM

Association Links

to Class java.lang.String

Agent name

to Class fipaos.ont.fipa.fipaman.AgentID

Agent id

to Class java.util.Map

Map of active conversations

to Class java.util.Map

Cach of protocols

to Class fipaos.util.Queue

Reference to the FIFOQueue containing updates to be dealt with

to Class fipaos.mts.MessageSender

Reference to MessageSender used to send messages

to Class fipaos.agent.FIPAOSAgent

Reference to the owner of this

to Class fipaos.agent.conversation.ConversationListener

Reference to the object that Conversations should be handed onto. Typically this will be the TaskManager.

to Class fipaos.skill.db.Database

Database in use to archive finished conversations

to Class java.lang.Thread

Thread running within the CM

to Class fipaos.util.Monitor

Monitor running within this CM

to Class fipaos.agent.profile.ProtocolProfile

Contains the mappings between protocol names and their implementing classes