Package jade.proto

Class SSIteratedAchieveREResponder

  • All Implemented Interfaces:
    Serializable, Serializable

    public class SSIteratedAchieveREResponder
    extends FSMBehaviour
    Single Session version of the Responder role in the Iterated-Fipa-Request protocol.
    Author:
    Giovanni Caire - TILAB
    See Also:
    Serialized Form
    • Field Detail

      • REQUEST_KEY

        public final String REQUEST_KEY
        Key to retrieve from the DataStore of the behaviour the last received REQUEST ACLMessage
      • CANCEL_KEY

        public final String CANCEL_KEY
        Key to retrieve from the DataStore of the behaviour the last received CANCEL ACLMessage
      • INITIATION_KEY

        public final String INITIATION_KEY
        Key to retrieve from the DataStore of the behaviour the initiation ACLMessage that triggered this responder session
      • RECEIVED_KEY

        public final String RECEIVED_KEY
        Key to retrieve from the DataStore of the behaviour the last received ACLMessage
      • REPLY_KEY

        public final String REPLY_KEY
        Key to set into the DataStore of the behaviour the new ACLMessage to be sent back to the initiator as a reply.
    • Constructor Detail

      • SSIteratedAchieveREResponder

        public SSIteratedAchieveREResponder​(Agent a,
                                            ACLMessage request)
        Construct a SSIteratedAchieveREResponder that is activated by the reception of a given initiation REQUEST message.
      • SSIteratedAchieveREResponder

        public SSIteratedAchieveREResponder​(Agent a,
                                            ACLMessage request,
                                            DataStore store)
        Construct a SSIteratedAchieveREResponder that is activated by the reception of a given initiation REQUEST message and uses a given DataStore.
    • Method Detail

      • handleRequest

        protected ACLMessage handleRequest​(ACLMessage request)
                                    throws RefuseException,
                                           FailureException,
                                           NotUnderstoodException
        This method is called to handle the initial REQUEST message and then again whenever a REQUEST message is received. This default implementation does nothing and returns null. Programmers have to override it to react to this event.
        Parameters:
        request - the REQUEST message to handle.
        Returns:
        the reply message to be sent back to the initiator. Returning a message defferent from INFORM (or returning null) terminates the protocol. An optional AGREE message can be sent back to the initiator by calling the sendAgree() method.
        Throws:
        RefuseException - if the REQUEST is refused. Throwing a RefuseException has the same effect as returning a REFUSE message, but automatically manages the :content slot.
        FailureException - if there is an error serving the REQUEST. Throwing a FailureException has the same effect as returning a FAILURE message, but automatically manages the :content slot.
        NotUnderstoodException - if the REQUEST content is not undrerstood. Throwing a NotUnderstoodException has the same effect as returning a NOT_UNDERSTOOD message, but automatically manages the :content slot.
      • handleCancel

        protected void handleCancel​(ACLMessage cancel)
        This method is called when a CANCEL message is received from the initiator. This default implementation does nothing. Programmers may override it to react to this event.
        Parameters:
        cancel - the received CANCEL message or null if no further REQUEST message is received from the initiator within the timeout specified in the :reply-by slot of the last INFORM message.
      • registerHandleRequest

        public void registerHandleRequest​(Behaviour b)
        This method allows to register a user defined Behaviour in the HANDLE_REQUEST state. This behaviour would override the homonymous method. This method also sets the data store of the registered Behaviour to the DataStore of this current behaviour.
        The registered behaviour can retrieve the received REQUEST message from the datastore at the REQUEST_KEY key.
        It is responsibility of the registered behaviour to put the reply to be sent back to the initiator into the datastore at the REPLY_KEY key. Putting a message defferent from INFORM (or null) terminates the protocol. An optional AGREE message can be sent back to the initiator by calling the sendAgree() method.
        Parameters:
        b - the Behaviour that will handle this state
      • registerHandleCancel

        public void registerHandleCancel​(Behaviour b)
        This method allows to register a user defined Behaviour in the HANDLE_CANCEL state. This behaviour would override the homonymous method. This method also sets the data store of the registered Behaviour to the DataStore of this current behaviour.
        The registered behaviour can retrieve the CANCEL message received from the datastore at the CANCEL_KEY key.
        Parameters:
        b - the Behaviour that will handle this state
      • sendAgree

        public void sendAgree​(ACLMessage agree)
        Utility method to send an optional AGREE message back to the initiator ensuring that all protocol fields are properly set.
      • closeSessionOnNextReply

        public void closeSessionOnNextReply()
        Close the ongoing session, as soon as the next INFORM will be sent back to the initiator without the need for an explicit CANCEL message. The initiator will be able to detect that the session has been closed by calling the isSessionTerminated() method of the SSIteratedAchieveREInitiator class.
      • reset

        public void reset()
        Reset this protocol behaviour
      • checkInSequence

        protected boolean checkInSequence​(ACLMessage received)
        Check whether a received message complies with the protocol rules.
      • beforeReply

        protected void beforeReply​(ACLMessage reply)
        This method can be redefined by protocol specific implementations to customize a reply that is going to be sent back to the initiator. This default implementation does nothing.
      • onStart

        public void onStart()
        Description copied from class: Behaviour
        This method is just an empty placeholders for subclasses. It is executed just once before starting behaviour execution. Therefore, it acts as a prolog to the task represented by this Behaviour.
        Overrides:
        onStart in class Behaviour
      • handleOutOfSequence

        protected void handleOutOfSequence​(ACLMessage msg)
        This method is called whenever a message is received that does not comply to the protocol rules. This default implementation does nothing. Programmers may override it in case they need to react to this event.
        Parameters:
        msg - the received out-of-sequence message.
      • 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 sets 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 RECEIVED_KEY key.
        Parameters:
        b - the Behaviour that will handle this state
      • reinit

        protected void reinit()
        Re-initialize the internal state without performing a complete reset.
      • afterReply

        protected void afterReply​(ACLMessage reply)
        This method can be redefined by protocol specific implementations to update the status of the protocol just after a reply has been sent. This default implementation does nothing.
      • sessionTerminated

        protected void sessionTerminated()
        This method can be redefined by protocol specific implementations to take proper actions after the completion of the current protocol session.
      • registerDSState

        protected void registerDSState​(Behaviour b,
                                       String name)
        Utility method to register a behaviour in a state of the protocol and set the DataStore appropriately