Class BaseInitiator

    • Constructor Detail

      • BaseInitiator

        public BaseInitiator()
    • Method Detail

      • setActiveConversations

        public void setActiveConversations​(ConversationList conversations)
      • checkLanguage

        protected void checkLanguage​(String languageName)
      • checkOntology

        protected void checkOntology​(Ontology onto)
      • getExitCode

        public int getExitCode()
        Shortcut method for getOutcome().getExitCode()
      • getErrorMsg

        public String getErrorMsg()
        Shortcut method for getOutcome().getErrorMsg()
      • createInitiation

        protected abstract ACLMessage createInitiation()
        Concrete subclasses are expected to implement this method to create the initiation message.
        Returns:
        The initiation message used by this behaviour
      • getTargetDescription

        protected String getTargetDescription()
        Concrete subclasses can redefine this method to provide a human readable description of the target agent of this behaviour. Such description will be used in all default error messages.
        Returns:
        A human readable description of the target agent of this behaviour
      • prepareRequests

        public Vector prepareRequests​(ACLMessage msg)
        Description copied from class: AchieveREInitiator
        This method must return the vector of ACLMessage objects to be sent. It is called in the first state of this protocol. This default implementation just returns the ACLMessage object passed in the constructor. Programmers might prefer to override this method in order to return a vector of objects for 1:N conversations or also to prepare the messages during the execution of the behaviour.
        Overrides:
        prepareRequests in class AchieveREInitiator
        Parameters:
        msg - the ACLMessage object passed in the constructor
        Returns:
        a Vector of ACLMessage objects. The values of the slot reply-with is ignored and a different value is assigned automatically by this class for each receiver.
      • handleRefuse

        public void handleRefuse​(ACLMessage refuse)
        Description copied from class: AchieveREInitiator
        This method is called every time a refuse message is received, which is not out-of-sequence according to the protocol rules. This default implementation does nothing; programmers might wish to override the method in case they need to react to this event.
        Overrides:
        handleRefuse in class AchieveREInitiator
        Parameters:
        refuse - the received refuse message
      • handleNotUnderstood

        public void handleNotUnderstood​(ACLMessage notUnderstood)
        This method is called every time a not-understood message is received, which is not out-of-sequence according to the protocol rules. This default implementation does nothing; programmers might wish to override the method in case they need to react to this event.
        Parameters:
        notUnderstood - the received not-understood message
      • handleFailure

        public void handleFailure​(ACLMessage failure)
        This method is called every time a failure message is received, which is not out-of-sequence according to the protocol rules. This default implementation does nothing; programmers might wish to override the method in case they need to react to this event.
        Parameters:
        failure - the received failure message
      • handleAllResultNotifications

        public void handleAllResultNotifications​(Vector notifications)
        Description copied from class: AchieveREInitiator
        This method is called when all the result notification messages have been collected. By result notification message we intend here all the inform, failure received messages, which are not not out-of-sequence according to the protocol rules. This default implementation does nothing; programmers might wish to override the method in case they need to react to this event by analysing all the messages in just one call.
        Overrides:
        handleAllResultNotifications in class AchieveREInitiator
      • handleTimeout

        public void handleTimeout()
      • onEnd

        public int onEnd()
        Description copied from class: FSMBehaviour
        Override the onEnd() method to return the exit value of the last executed state.
        Overrides:
        onEnd in class FSMBehaviour
        Returns:
        an integer code representing the termination value of the behaviour.
      • sendInitiations

        protected void sendInitiations​(Vector initiations)
        Create and initialize the Sessions and sends the initiation messages
      • handleOutOfSequence

        protected void handleOutOfSequence​(ACLMessage msg)
        This method is called every time a message is received, which is out-of-sequence according to the protocol rules. This default implementation does nothing; programmers might wish to override the method in case they need to react to this event.
        Parameters:
        msg - the received message
      • registerPrepareInitiations

        protected void registerPrepareInitiations​(Behaviour b)
        Attach a behaviour to the Prepare-initiations protocol state.
        Parameters:
        b - The behaviour object to be executed in the Prepare-initiations state.
      • registerHandleNotUnderstood

        public void registerHandleNotUnderstood​(Behaviour b)
        This method allows to register a user defined Behaviour in the HANDLE_NOT_UNDERSTOOD state. This behaviour would override the homonymous method. This method also set the data store of the registered Behaviour to the DataStore of this current behaviour. The registered behaviour can retrieve the not-understood ACLMessage object received from the datastore at the REPLY_KEY key.
        Parameters:
        b - the Behaviour that will handle this state
      • registerHandleFailure

        public void registerHandleFailure​(Behaviour b)
        This method allows to register a user defined Behaviour in the HANDLE_FAILURE state. This behaviour would override the homonymous method. This method also set the data store of the registered Behaviour to the DataStore of this current behaviour. The registered behaviour can retrieve the failure ACLMessage object received from the datastore at the REPLY_KEY key.
        Parameters:
        b - the Behaviour that will handle this state
      • registerHandleOutOfSequence

        public void registerHandleOutOfSequence​(Behaviour b)
        This method allows to register a user defined Behaviour in the HANDLE_OUT_OF_SEQ state. This behaviour would override the homonymous method. This method also set the data store of the registered Behaviour to the DataStore of this current behaviour. The registered behaviour can retrieve the out of sequence ACLMessage object received from the datastore at the REPLY_KEY key.
        Parameters:
        b - the Behaviour that will handle this state
      • reset

        public void reset()
        reset this behaviour by putting a null ACLMessage as message to be sent
        Overrides:
        reset in class FSMBehaviour
      • reset

        public void reset​(ACLMessage msg)
        reset this behaviour
        Parameters:
        msg - is the ACLMessage to be sent
      • onStart

        public void onStart()
        Override the onStart() method to initialize the vectors that will keep all the replies in the data store.
        Overrides:
        onStart in class Behaviour
      • setDataStore

        public void setDataStore​(DataStore ds)
        Override the setDataStore() method to propagate this setting to all children.
        Overrides:
        setDataStore in class Behaviour
        Parameters:
        ds - the DataStore that this Behaviour will use as its private data store
      • createConvId

        protected String createConvId​(Vector msgs)
        Create a new conversation identifier to begin a new interaction.
        Parameters:
        msgs - A vector of ACL messages. If the first one has a non-empty :conversation-id slot, its value is used, else a new conversation identifier is generated.
      • adjustReplyTemplate

        protected void adjustReplyTemplate​(ACLMessage msg)