fipaos.agent.conversation.standard
Class ConversationManagerImpl

java.lang.Object
  |
  +--fipaos.agent.conversation.standard.ConversationManagerImpl
All Implemented Interfaces:
ConversationManager, MessageReceiver, MessageSender, java.lang.Runnable

public class ConversationManagerImpl
extends java.lang.Object
implements java.lang.Runnable, ConversationManager

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
 Conversation addConversation(java.lang.String protocol)
          Method to create a new conversation given a protcol, and add it to the active list
 boolean addProtocol(java.lang.String protocol_name, java.lang.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.
 Conversation getConversation(java.lang.String conversation_id)
          Retrieves an active/previous Conversation that an Agent has had
 void handleMessage(Message msg)
          Looks at a Message and checks to see if it part of an exisiting conversation.
 boolean hasProtocol(java.lang.String protocol)
          Indicates whether the specified protocol is already in the cache, i.e.
static void main(java.lang.String[] args)
           
 void receiveMessage(Message msg)
          Received an incoming message - put it through the CM
 void removeConversation(java.lang.String conversation_id)
          Moves a conversation from the Active to the conversation archive
 void run()
          Main thread for dealing with non-event based Conversation updates
 void sendMessage(Message msg)
          Attempt to send the given message
 void setMessageReceiver(MessageReceiver p1)
          Attempt to set the receiver of incoming messages - not supported by this class!
 void setMessageSender(MessageSender p1)
          Set the reference to the MessageSender that should send-outgoing messages
static void setProtocolProfile(ProtocolProfile pp)
          Method to set the ProtocolProfile for the JVM
 void shutdown()
          Shutdown the CM
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

shutdown

public void shutdown()
Shutdown the CM
Specified by:
shutdown in interface MessageSender

setMessageReceiver

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

sendMessage

public void sendMessage(Message msg)
Attempt to send the given message
Specified by:
sendMessage in interface MessageSender
Following copied from interface: fipaos.mts.MessageSender
Parameters:
message - The message to be sent

receiveMessage

public void receiveMessage(Message msg)
Received an incoming message - put it through the CM
Specified by:
receiveMessage in interface MessageReceiver
Following copied from interface: fipaos.mts.MessageReceiver
Parameters:
message - The incomming message

setMessageSender

public void setMessageSender(MessageSender p1)
Description copied from interface: MessageReceiver
Set the reference to the MessageSender that should send-outgoing messages
Specified by:
setMessageSender in interface MessageReceiver

run

public void run()
Main thread for dealing with non-event based Conversation updates
Specified by:
run in interface java.lang.Runnable

setProtocolProfile

public static void setProtocolProfile(ProtocolProfile pp)
Method to set the ProtocolProfile for the JVM

handleMessage

public void handleMessage(Message msg)
                   throws UnknownProtocolException,
                          InvalidConversationIDException,
                          ProtocolErrorException,
                          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

addConversation

public Conversation addConversation(java.lang.String protocol)
                             throws UnknownProtocolException
Method to create a new conversation given a protcol, and add it to the active list
Specified by:
addConversation in interface ConversationManager

getConversation

public Conversation getConversation(java.lang.String conversation_id)
                             throws InvalidConversationIDException
Retrieves an active/previous Conversation that an Agent has had
Specified by:
getConversation in interface ConversationManager

addProtocol

public boolean addProtocol(java.lang.String protocol_name,
                           java.lang.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.
Specified by:
addProtocol in interface ConversationManager
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

hasProtocol

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

removeConversation

public void removeConversation(java.lang.String conversation_id)
Moves a conversation from the Active to the conversation archive
Specified by:
removeConversation in interface ConversationManager
Following copied from interface: fipaos.agent.conversation.ConversationManager
Parameters:
id - The conversation-id of the conversation to remove

main

public static void main(java.lang.String[] args)