Class ActionExecutor<ActionT extends AgentAction,​ResultT>

  • Type Parameters:
    ActionT - The class of the action to be executed
    ResultT - The class of the result or Void if the action is not expected to return any result
    All Implemented Interfaces:
    Serializable, Serializable

    public class ActionExecutor<ActionT extends AgentAction,​ResultT>
    extends BaseInitiator
    Base class for behaviours intended to request the execution of an action to a given actor and get back the result (if any)
    See Also:
    Serialized Form
    • Constructor Detail

      • ActionExecutor

        public ActionExecutor​(ActionT action,
                              Ontology ontology,
                              AID actor)
    • Method Detail

      • setAction

        public void setAction​(ActionT action)
      • setActor

        public void setActor​(AID actor)
      • setOntology

        public void setOntology​(Ontology ontology)
      • setLanguage

        public void setLanguage​(String language)
      • setTimeout

        public void setTimeout​(long timeout)
      • setConversationId

        public void setConversationId​(String conversationId)
      • getResult

        public ResultT getResult()
      • getActualActor

        public AID getActualActor()
      • createInitiation

        protected ACLMessage createInitiation()
        Description copied from class: BaseInitiator
        Concrete subclasses are expected to implement this method to create the initiation message.
        Specified by:
        createInitiation in class BaseInitiator
        Returns:
        The initiation message used by this behaviour
      • handleInform

        public void handleInform​(ACLMessage inform)
        Description copied from class: AchieveREInitiator
        This method is called every time a inform 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:
        handleInform in class AchieveREInitiator
        Parameters:
        inform - the received inform message
      • 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)