fipaos.agent.conversation.lightweight
Class LightweightConversationManagerImpl

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

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


Constructor Summary
LightweightConversationManagerImpl(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 - this implementation will always return true since protocols are not forced.
 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)
          Deal with the incoming message
 void removeConversation(java.lang.String id)
          Removes the given conversation from the ConversationManager - this may be necessary in order to end conversations that have no defined end-point
 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.
 void sendMessage(Message msg)
          Attempt to send the message given
 void setMessageReceiver(MessageReceiver mr)
          Set the reference to the MessageReceiver that should receive incoming messages
 void setMessageSender(MessageSender ms)
          Set the reference to the MessageSender that should send-outgoing messages
 void shutdown()
          Attempt to shutdown the implementation safely
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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(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

removeConversation

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

addProtocol

public boolean addProtocol(java.lang.String protocol_name,
                           java.lang.String protocol_defn)
Adds a new protocol to the CM - this implementation will always return true since protocols are not forced.
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:
always returns true

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

sendMessage

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

setMessageSender

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

setMessageReceiver

public void setMessageReceiver(MessageReceiver mr)
Set the reference to the MessageReceiver that should receive incoming messages
Specified by:
setMessageReceiver in interface MessageSender

shutdown

public void shutdown()
Description copied from interface: MessageSender
Attempt to shutdown the implementation safely
Specified by:
shutdown in interface MessageSender

receiveMessage

public void receiveMessage(Message msg)
Description copied from interface: MessageReceiver
Deal with the incoming message
Specified by:
receiveMessage in interface MessageReceiver
Following copied from interface: fipaos.mts.MessageReceiver
Parameters:
message - The incomming message

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.

Specified by:
run in interface java.lang.Runnable
See Also:
Thread.run()

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

main

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