Package jade.proto

Class SimpleAchieveREResponder

    • Constructor Detail

      • SimpleAchieveREResponder

        public SimpleAchieveREResponder​(Agent a,
                                        MessageTemplate mt)
        Constructor of the behaviour that creates a new empty DataStore
      • SimpleAchieveREResponder

        public SimpleAchieveREResponder​(Agent a,
                                        MessageTemplate mt,
                                        DataStore store)
        Constructor.
        Parameters:
        a - is the reference to the Agent object
        mt - is the MessageTemplate that must be used to match the initiator message. Take care that if mt is null every message is consumed by this protocol.
        store - the DataStore for this protocol
    • Method Detail

      • createMessageTemplate

        public static MessageTemplate createMessageTemplate​(String iprotocol)
        This static method can be used to set the proper message Template (based on the interaction protocol and the performative) into the constructor of this behaviour.
        See Also:
        FIPANames.InteractionProtocol
      • action

        public final void action()
        Description copied from class: Behaviour
        Runs the behaviour. This abstract method must be implemented by Behavioursubclasses to perform ordinary behaviour duty. An agent schedules its behaviours calling their action() method; since all the behaviours belonging to the same agent are scheduled cooperatively, this method must not enter in an endless loop and should return as soon as possible to preserve agent responsiveness. To split a long and slow task into smaller section, recursive behaviour aggregation may be used.
        Specified by:
        action in class Behaviour
        See Also:
        CompositeBehaviour
      • prepareResponse

        protected ACLMessage prepareResponse​(ACLMessage request)
                                      throws NotUnderstoodException,
                                             RefuseException
        This method is called when the initiator's message is received that matches the message template passed in the constructor. This default implementation return null which has the effect of sending no reponse. Programmers should override the method in case they need to react to this event.
        Parameters:
        request - the received message
        Returns:
        the ACLMessage to be sent as a response (i.e. one of agree, refuse, not-understood, inform. Remind to use the method createReply of the class ACLMessage in order to create a good reply message
        Throws:
        NotUnderstoodException
        RefuseException
        See Also:
        ACLMessage.createReply()
      • prepareResultNotification

        protected ACLMessage prepareResultNotification​(ACLMessage request,
                                                       ACLMessage response)
                                                throws FailureException
        This method is called after the response has been sent and only when one of the folliwing two cases arise: the response was an agree message OR no response message was sent. This default implementation return null which has the effect of sending no result notification. Programmers should override the method in case they need to react to this event.
        Parameters:
        request - the received message
        response - the previously sent response message
        Returns:
        the ACLMessage to be sent as a result notification (i.e. one of inform, failure. Remind to use the method createReply of the class ACLMessage in order to create a good reply message
        Throws:
        FailureException
        See Also:
        ACLMessage.createReply(), prepareResponse(ACLMessage)
      • reset

        public void reset()
        Reset this behaviour using the same MessageTemplate.
        Overrides:
        reset in class SimpleBehaviour
      • reset

        public void reset​(MessageTemplate mt)
        This method allows to change the MessageTemplate that defines what messages this FIPARequestResponder will react to and reset the protocol.
      • done

        public boolean done()
        This method checks whether this behaviour has finished or not.
        Specified by:
        done in class Behaviour
        Returns:
        true if this behaviour has completed its task, false otherwise.