Class AMSSubscriber

  • All Implemented Interfaces:
    Serializable, Serializable
    Direct Known Subclasses:
    ToolAgent.AMSListenerBehaviour

    public abstract class AMSSubscriber
    extends SimpleBehaviour
    This behaviour subscribes to the AMS to receive notifications about platform-wide events. The installHandlers method must be redefined to define the handlers for events the agent executing this behaviour is interested in.
    Author:
    Giovanni Caire - TILAB, Giovanni Rimassa - Universita' di Parma
    See Also:
    Serialized Form
    • Constructor Detail

      • AMSSubscriber

        public AMSSubscriber()
        Construct an AMSSubscriber behaviour to receive notifications about platform events from the local AMS
      • AMSSubscriber

        public AMSSubscriber​(AID ams)
        Construct an AMSSubscriber behaviour to receive notifications about platform events from the AMS of a remote platform.
        Parameters:
        ams - The AID of the remote platform AMS
    • Method Detail

      • 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
      • installHandlers

        protected abstract void installHandlers​(Map handlersTable)
        This method has to be implemented by concrete subclasses, filling the Map passed as parameter with implementations of the EventHandler interface, using the name of the event as key (see the Event interface.
        Parameters:
        handlersTable - The table that associates each event name with a proper handler.
      • 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
      • done

        public final boolean done()
        Description copied from class: Behaviour
        Check if this behaviour is done. The agent scheduler calls this method to see whether a Behaviour still need to be run or it has completed its task. Concrete behaviours must implement this method to return their completion state. Finished behaviours are removed from the scheduling queue, while others are kept within to be run again when their turn comes again.
        Specified by:
        done in class Behaviour
        Returns:
        true if the behaviour has completely executed.
      • cancel

        public void cancel()
      • getSubscribe

        public final ACLMessage getSubscribe()
        Retrieve the subscribe ACL message used to subscribe to the AMS. This message is automatically sent when this behaviour is added to an Agent.
        Returns:
        The subscription ACL message.
      • getCancel

        public final ACLMessage getCancel()
        Retrieve the cancel ACL message used to cancel the subscription to the AMS. Since this behaviour is cyclic (never ends) it is the responsibility of the agent executing this behaviour to send the cancel message to the AMS when notifications are no longer required.
        Returns:
        The cancellation ACL message.