ABLE 2.0.0 07/02/2003 10:25:01

com.ibm.able.conversation
Class AbleConversationManager

java.lang.Object
  |
  +--com.ibm.able.AbleObject
        |
        +--com.ibm.able.conversation.AbleConversationManager
All Implemented Interfaces:
AbleBean, AbleDataBufferManager, AbleEventListener, AbleEventListenerManager, AbleEventQueueManager, AbleEventQueueProcessor, AblePropertyChangeManager, AbleSerializable, ConversationManager, java.io.Serializable

public class AbleConversationManager
extends AbleObject
implements ConversationManager

The AbleConversationManager class is an AbleBean implementing of the ConversationManager interface.

Each conversational agent must contain one AbleConversationManager, and must make sure that the AbleConversationManager's process() method is invoked regularly.

See Also:
Serialized Form

Field Summary
static java.lang.String CONVERSATION_COMPLETED_PROPERTY
          Property name of the PropertyChangeEvent fired when a conversation is completed.
static java.lang.String CP_LAYOUT_LOADED_PROPERTY
          Property name of the PropertyChangeEvent fired when a conversation policy's graph-layout file is loaded.
static java.lang.String NEW_CONVERSATION_PROPERTY
          Property name of the PropertyChangeEvent fired when a new conversation is created.
 
Fields inherited from class com.ibm.able.AbleObject
changed, chgSupport, comment, dataFlowEnabled, defaultName, destBufferConnections, eventQueue, fileName, inputBuffer, listeners, logger, name, outputBuffer, parent, propertyConnectionMgr, sourceBufferConnections, state, stateChgSupport, trace
 
Constructor Summary
AbleConversationManager()
          Constructs an AbleConversationManager object.
AbleConversationManager(java.lang.String theName)
          Constructs an AbleConversationManager object with the given name.
AbleConversationManager(java.lang.String theName, java.lang.String theComment)
          Constructs an AbleConversationManager object with the given name and comment string.
 
Method Summary
 void addPropertyChangeListener(java.lang.String propName, java.beans.PropertyChangeListener listener)
          Adds the given PropertyChangeListener under the given property name, to the superclass's PropertyChangeSupport object.
 void closeConversation(java.lang.String convId)
          Ends the conversation with the given ID.
protected  java.lang.String createConversationId()
          Creates a new conversation ID unique to this ConversationManager.
 ConversationContext getContext(java.lang.String convId)
          Returns the ConversationContext for a given conversation.
 Conversation getConversation(java.lang.String convId)
          Returns the Conversation with the given conversation ID.
 java.util.Set getConversationIds()
          Returns the set of all active conversation IDs.
 ConversationPolicyHandlerFactory getConversationPolicyHandlerFactory()
          Returns this ConversationManager's ConversationPolicyHandlerFactory.
 java.lang.String getConversationPolicyRepositoryPath()
          Returns the repository path used by this AbleConversationManager's AbleConversationPolicyHandlerFactory.
 java.lang.String getInitialPolicyName()
          Returns the name of the policy assigned to newly created conversations.
 java.lang.String getInitiatorRole()
          Returns the role this agent should use in a new conversation, when this agent initiates it.
 MessageTransformFactory getMessageTransformFactory()
          Returns this ConversationManager's MessageTransformFactory.
 ConversationMetaData getMetaData(java.lang.String convId)
          Returns the conversation meta-data associated with a given conversation
 int getNumConversations()
          Returns the number of conversations currently going on.
 java.lang.String getPolicyLayoutFile(java.lang.String policyName)
          Returns the graph-layout file for the given conversation policy, stored in this AbleConversationManager's AbleConversationPolicyHandlerFactory.
protected  java.beans.PropertyChangeSupport getPropertyChangeSupport()
          Returns the PropertyChangeSupport object stored in the superclass.
 java.lang.String getResponderRole()
          Returns the role this agent should use in a new conversation, when another agent has initiated it.
 boolean isConversationCompleted(java.lang.String convId)
          Indicates whether a Conversation with the given ID has already been executed to completion.
 Conversation newConversation(ConversationMetaData metaData, boolean isInitiator)
          Creates and initializes a new Conversation.
 void process()
          Do one step of processing.
 void removePropertyChangeListener(java.lang.String propName, java.beans.PropertyChangeListener listener)
          Removes the given PropertyChangeListener from the given property name in the superclass's PropertyChangeSupport object.
 void setConversationPolicyRepositoryPath(java.lang.String newPath)
          Sets the repository path used by this AbleConversationManager's AbleConversationPolicyHandlerFactory.
 void setDecisionLogicAdapter(DecisionLogicAdapter dla)
          Sets the DecisionLogicAdapter used by this ConversationManager.
 void setInitialPolicy(java.lang.String name, java.lang.String initiator, java.lang.String responder)
          Sets the conversation policy to assign to a newly created Conversation, and the roles to use if this agent, or another agent, is the initiator of it.
 void setMessageSystemAdapter(MessageSystemAdapter msa)
          Sets the MessageSystemAdapter used by this ConversationManager.
 
Methods inherited from class com.ibm.able.AbleObject
addAbleEventListener, addDestBufferConnection, addPropertyChangeListener, addPropertyConnection, addSourceBufferConnection, addStateChangeListener, Copyright, dataChanged, firePropertyChange, flushAbleEventQueue, getAbleEventListeners, getAbleEventProcessingEnabled, getAbleEventQueueSize, getComment, getDestBufferConnections, getFileName, getInputBuffer, getInputBuffer, getInputBufferAsStringArray, getInputBufferContents, getLogger, getName, getOutputBuffer, getOutputBuffer, getOutputBufferAsStringArray, getOutputBufferContents, getParent, getPropertyConnectionManager, getSleepTime, getSourceBufferConnections, getState, getTraceLogger, handleAbleEvent, hasInputBuffer, hasOutputBuffer, init, init, isAbleEventPostingEnabled, isAbleEventProcessingEnabled, isChanged, isConnectable, isDataFlowEnabled, isTimerEventProcessingEnabled, notifyAbleEventListeners, process, processAbleEvent, processBufferConnections, processNoEventProcessingEnabledSituation, processTimerEvent, quitAll, quitEnabledEventProcessing, removeAbleEventListener, removeAllAbleEventListeners, removeAllBufferConnections, removeAllConnections, removeAllPropertyConnections, removeDestBufferConnection, removePropertyChangeListener, removePropertyConnection, removeSourceBufferConnection, removeStateChangeListener, reset, restartEnabledEventProcessing, restoreFromFile, restoreFromFile, restoreFromSerializedFile, restoreFromStream, resumeAll, resumeEnabledEventProcessing, saveToFile, saveToFile, setAbleEventProcessingEnabled, setChanged, setComment, setDataFlowEnabled, setFileName, setInputBuffer, setInputBuffer, setLogger, setName, setOutputBuffer, setOutputBuffer, setParent, setSleepTime, setState, setTimerEventProcessingEnabled, setTraceLogger, sourceConnectionsOK, startEnabledEventProcessing, suspendAll, suspendEnabledEventProcessing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NEW_CONVERSATION_PROPERTY

public static final java.lang.String NEW_CONVERSATION_PROPERTY
Property name of the PropertyChangeEvent fired when a new conversation is created.

CONVERSATION_COMPLETED_PROPERTY

public static final java.lang.String CONVERSATION_COMPLETED_PROPERTY
Property name of the PropertyChangeEvent fired when a conversation is completed.

CP_LAYOUT_LOADED_PROPERTY

public static final java.lang.String CP_LAYOUT_LOADED_PROPERTY
Property name of the PropertyChangeEvent fired when a conversation policy's graph-layout file is loaded.

Note: This may be removed in the future. Avoid using it if possible.

Constructor Detail

AbleConversationManager

public AbleConversationManager()
                        throws AbleException
Constructs an AbleConversationManager object.

Throws:
AbleException - If thrown by the superclass constructor.

AbleConversationManager

public AbleConversationManager(java.lang.String theName)
                        throws AbleException
Constructs an AbleConversationManager object with the given name.

Parameters:
theName - The name of the AbleBean.
Throws:
AbleException - If thrown by the superclass constructor.

AbleConversationManager

public AbleConversationManager(java.lang.String theName,
                               java.lang.String theComment)
                        throws AbleException
Constructs an AbleConversationManager object with the given name and comment string.

Parameters:
theName - The name of the AbleBean.
theComment - The comment string for the AbleBean.
Throws:
AbleException - If thrown by the superclass constructor.
Method Detail

getNumConversations

public int getNumConversations()
Description copied from interface: ConversationManager
Returns the number of conversations currently going on.

Specified by:
getNumConversations in interface ConversationManager
Following copied from interface: com.ibm.conversation.ConversationManager
Returns:
The number of conversations currently going on.

getConversationIds

public java.util.Set getConversationIds()
Description copied from interface: ConversationManager
Returns the set of all active conversation IDs.

The conversation IDs returned are the IDs assigned by this ConversationManager to the conversations currently in progress.

Specified by:
getConversationIds in interface ConversationManager
Following copied from interface: com.ibm.conversation.ConversationManager
Returns:
The set of all active conversation IDs.

getMetaData

public ConversationMetaData getMetaData(java.lang.String convId)
Description copied from interface: ConversationManager
Returns the conversation meta-data associated with a given conversation

The conversation is specified by the conversation ID assigned by this ConversationManager to the conversation.

Specified by:
getMetaData in interface ConversationManager
Following copied from interface: com.ibm.conversation.ConversationManager
Parameters:
convId - The conversation ID in question.
Returns:
The ConversationMetaData for the conversation with the given ID, or null if not found.

getContext

public ConversationContext getContext(java.lang.String convId)
Description copied from interface: ConversationManager
Returns the ConversationContext for a given conversation.

Specified by:
getContext in interface ConversationManager
Following copied from interface: com.ibm.conversation.ConversationManager
Parameters:
convId - The conversation ID of the conversation in question.
Returns:
The ConversationContext for the given conversation, or null if not found.

getInitialPolicyName

public java.lang.String getInitialPolicyName()
Description copied from interface: ConversationManager
Returns the name of the policy assigned to newly created conversations.

Specified by:
getInitialPolicyName in interface ConversationManager
Following copied from interface: com.ibm.conversation.ConversationManager
Returns:
The policy name.

getInitiatorRole

public java.lang.String getInitiatorRole()
Description copied from interface: ConversationManager
Returns the role this agent should use in a new conversation, when this agent initiates it.

Specified by:
getInitiatorRole in interface ConversationManager
Following copied from interface: com.ibm.conversation.ConversationManager
Returns:
The role.

getResponderRole

public java.lang.String getResponderRole()
Description copied from interface: ConversationManager
Returns the role this agent should use in a new conversation, when another agent has initiated it.

Specified by:
getResponderRole in interface ConversationManager
Following copied from interface: com.ibm.conversation.ConversationManager
Returns:
The role.

setInitialPolicy

public void setInitialPolicy(java.lang.String name,
                             java.lang.String initiator,
                             java.lang.String responder)
Description copied from interface: ConversationManager
Sets the conversation policy to assign to a newly created Conversation, and the roles to use if this agent, or another agent, is the initiator of it.

The policy should be a conversation-setup policy. The roles should be the roles defined in that policy.

Specified by:
setInitialPolicy in interface ConversationManager
Following copied from interface: com.ibm.conversation.ConversationManager
Parameters:
policyName - the name of the policy
initiatorRole - the role to use if this agent is the initiator.
initiatorRole - the role to use if another agent is the initiator.

getConversation

public Conversation getConversation(java.lang.String convId)
Description copied from interface: ConversationManager
Returns the Conversation with the given conversation ID.

Specified by:
getConversation in interface ConversationManager
Following copied from interface: com.ibm.conversation.ConversationManager
Parameters:
convId - The conversation ID of the conversation in question.
Returns:
The Conversation with the given conversation ID, or null if not found.

isConversationCompleted

public boolean isConversationCompleted(java.lang.String convId)
Indicates whether a Conversation with the given ID has already been executed to completion.

When each conversation is closed, its conversation ID is added to a list of completed conversations.

Parameters:
convId - The conversation ID.
Returns:
true if the conversation has been completed, false if not.

getMessageTransformFactory

public MessageTransformFactory getMessageTransformFactory()
Description copied from interface: ConversationManager
Returns this ConversationManager's MessageTransformFactory.

This MessageTransformFactory is assigned to all new Conversations when they are created.

Specified by:
getMessageTransformFactory in interface ConversationManager
Following copied from interface: com.ibm.conversation.ConversationManager
Returns:
The MessageTransformFactory.

getConversationPolicyHandlerFactory

public ConversationPolicyHandlerFactory getConversationPolicyHandlerFactory()
Description copied from interface: ConversationManager
Returns this ConversationManager's ConversationPolicyHandlerFactory.

This ConversationPolicyHandlerFactory is assigned to all new Conversations when they are created.

Specified by:
getConversationPolicyHandlerFactory in interface ConversationManager
Following copied from interface: com.ibm.conversation.ConversationManager
Returns:
The ConversationPolicyHandlerFactory.

setMessageSystemAdapter

public void setMessageSystemAdapter(MessageSystemAdapter msa)
Description copied from interface: ConversationManager
Sets the MessageSystemAdapter used by this ConversationManager.

The MessageSystemAdapter is assigned to newly created Conversations, during the initial stage of conversation setup. It must be able to deliver the initial conversation-setup message in the case where this agent initiates the conversation.

Specified by:
setMessageSystemAdapter in interface ConversationManager
Following copied from interface: com.ibm.conversation.ConversationManager
Parameters:
msa - The new MessageSystemAdapter.

setDecisionLogicAdapter

public void setDecisionLogicAdapter(DecisionLogicAdapter dla)
Description copied from interface: ConversationManager
Sets the DecisionLogicAdapter used by this ConversationManager.

The DecisionLogicAdapter is assigned to each newly created Conversation, regarless of whether this agent or another agent initiated it. Accordingly it must be able to support both the initiator and responder roles of this ConversationManager's initial policy.

Specified by:
setDecisionLogicAdapter in interface ConversationManager
Following copied from interface: com.ibm.conversation.ConversationManager
Parameters:
dla - The new DecisionLogicAdapter.

getConversationPolicyRepositoryPath

public java.lang.String getConversationPolicyRepositoryPath()
Returns the repository path used by this AbleConversationManager's AbleConversationPolicyHandlerFactory.

Returns:
The repository path, or null if not set.
See Also:
AbleConversationPolicyHandlerFactory.getRepositoryPathName()

setConversationPolicyRepositoryPath

public void setConversationPolicyRepositoryPath(java.lang.String newPath)
Sets the repository path used by this AbleConversationManager's AbleConversationPolicyHandlerFactory.

Parameters:
newPath - The new repository path.
See Also:
AbleConversationPolicyHandlerFactory.setRepositoryPathName(String)

getPolicyLayoutFile

public java.lang.String getPolicyLayoutFile(java.lang.String policyName)
Returns the graph-layout file for the given conversation policy, stored in this AbleConversationManager's AbleConversationPolicyHandlerFactory.

The graph-layout file gives the locations to assign to the graph's nodes when displaying the graoph.

Parameters:
policyName - The conversation policy name.
Returns:
The name of the graph-layout file, or null if not found.
See Also:
AbleConversationPolicyHandlerFactory.getLayoutFile(String)

createConversationId

protected java.lang.String createConversationId()
Creates a new conversation ID unique to this ConversationManager.

Returns:
The conversation ID just created.

newConversation

public Conversation newConversation(ConversationMetaData metaData,
                                    boolean isInitiator)
Description copied from interface: ConversationManager
Creates and initializes a new Conversation.

This creates a new Conversation object and gives it a unique conversation ID; assigns it the given ConversationMetaData (and copies the conversation ID into the meta-data); assigns its MessageSystemAdapter, DecisionLogicAdapter, MessageTransformFactory, and ConversationPolicyHandlerFactory; and sets the initial policy and role. If isInitiator is true, the role assigned to the new conversation is the one returned by getInitiatorRole(). Otherwise, the role is the one returned by getResponderRole().

This does not call Conversation.start() on the new Conversation, so the user must do so. This is to allow replacement of the defaults (the MessageSystemAdapter, the DecisionLogicAdapter, and the initial policy and role) before anything happens.

Specified by:
newConversation in interface ConversationManager
Following copied from interface: com.ibm.conversation.ConversationManager
Parameters:
metaData - The meta-data object to assign to the new Conversation.
isInitiator - Flag specifying whether this agent is initiating the conversation.
Returns:
The newly created Conversation

closeConversation

public void closeConversation(java.lang.String convId)
Description copied from interface: ConversationManager
Ends the conversation with the given ID.

Discards the Conversation with the given ID, which has presumably just ended. Called after the last message has been sent or received.

Specified by:
closeConversation in interface ConversationManager
Following copied from interface: com.ibm.conversation.ConversationManager
Parameters:
convId - The conversation ID of the Conversation to close.

process

public void process()
             throws AbleException
Do one step of processing. One step of processing consists of the following, in order:
  1. Calling super.process()
  2. Iterating over all currently active Conversations, dispatching the pending outputs of each (both messages and decision data).

Overrides:
process in class AbleObject
Throws:
AbleException - If the superclass method throws one.

getPropertyChangeSupport

protected java.beans.PropertyChangeSupport getPropertyChangeSupport()
Returns the PropertyChangeSupport object stored in the superclass. For use by this class, and by subclasses that need direct access to it.

Returns:
The PropertyChangeSupport object stored in the superclass.

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propName,
                                      java.beans.PropertyChangeListener listener)
Adds the given PropertyChangeListener under the given property name, to the superclass's PropertyChangeSupport object.

Parameters:
propName - The propertyName.
listener - The PropertyChangeListener to add.

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String propName,
                                         java.beans.PropertyChangeListener listener)
Removes the given PropertyChangeListener from the given property name in the superclass's PropertyChangeSupport object.

Parameters:
propName - The propertyName.
listener - The PropertyChangeListener to remove.

ABLE 2.0.0 07/02/2003 10:25:01

(C) Copyright IBM Corporation 1999, 2003