fipaos.agent.conversation.lightweight
Class LightweightConversationManagerImpl


public class LightweightConversationManagerImpl
implements ConversationManager, Runnable


Constructor Summary
LightweightConversationManagerImpl(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 - this implementation will always return true since protocols are not forced.
 ConversationgetConversation(String conversation_id)
          Retrieves an active/previous Conversation that an Agent has had
 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(fipaos.mts.Message msg)
           
 voidremoveConversation(String id)
          Removes the given conversation from the ConversationManager - this may be necessary in order to end conversations that have no defined end-point
 voidrun()
          When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.
 voidsendMessage(Message msg)
          Attempt to send the message given
 voidsetMessageReceiver(MessageReceiver mr)
          Set the reference to the MessageReceiver that should receive incoming messages
 voidsetMessageSender(MessageSender ms)
          Set the reference to the MessageSender that should send-outgoing messages
 voidshutdown()
           

Constructor Detail

LightweightConversationManagerImpl

public LightweightConversationManagerImpl(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 - this implementation will always return true since protocols are not forced.
Parameters:
protocol_name - The name of the protocol to store (e.g. fipa-new-protocol)
protocol_defn - The RDF definition of the protocol
Returns: always returns true

getConversation

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

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. Since protocols are not enforced by this implementation, this method always returns true.
Parameters:
protocol - The protocol to check for
Returns: always true

main

public static void main(String[] args)

receiveMessage

public void receiveMessage(fipaos.mts.Message msg)

removeConversation

public void removeConversation(String id)
throws fipaos.agent.conversation.InvalidConversationIDException
Removes the given conversation from the ConversationManager - this may be necessary in order to end conversations that have no defined end-point
Parameters:
id - The conversation-id of the conversation to remove

run

public void run()
When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.

The general contract of the method run is that it may take any action whatsoever.

See Also:
java.lang.Thread.run()

sendMessage

public void sendMessage(Message msg)
Attempt to send the message given
Parameters:
message - The message to be sent

setMessageReceiver

public void setMessageReceiver(MessageReceiver mr)
Set the reference to the MessageReceiver that should receive incoming messages

setMessageSender

public void setMessageSender(MessageSender ms)
Set the reference to the MessageSender that should send-outgoing messages

shutdown

public void shutdown()

Association Links

to Class java.util.Map

Map of active conversations

to Class fipaos.ont.fipa.fipaman.AgentID

Agent id

to Class java.lang.String

Agent name

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 fipaos.util.Monitor

Monitor running within this CM

to Class fipaos.agent.FIPAOSAgent

Reference to the owner of this

to Class java.util.Map

Cach of protocols

to Class fipaos.agent.profile.ProtocolProfile

Contains the mappings between protocol names and their implementing classes

to Class fipaos.mts.MessageSender

Reference to MessageSender used to send messages

to Class java.lang.Thread

Thread running within the CM

to Class fipaos.util.Queue

Reference to the FIFOQueue containing updates to be dealt with