Package jade.domain.introspection
Class AMSSubscriber
- java.lang.Object
-
- jade.core.behaviours.Behaviour
-
- jade.core.behaviours.SimpleBehaviour
-
- jade.domain.introspection.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. TheinstallHandlersmethod 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceAMSSubscriber.EventHandlerThis interface must be implemented by concrete event handlers installed by this AMSSubscriber.-
Nested classes/interfaces inherited from class jade.core.behaviours.Behaviour
Behaviour.RunnableChangedEvent
-
-
Field Summary
Fields Modifier and Type Field Description static StringAMS_CANCELLATIONstatic StringAMS_SUBSCRIPTIONstatic StringPLATFORM_EVENTS-
Fields inherited from class jade.core.behaviours.Behaviour
myAgent, myEvent, NOTIFY_DOWN, NOTIFY_UP, parent, STATE_BLOCKED, STATE_READY, STATE_RUNNING
-
-
Constructor Summary
Constructors Constructor Description AMSSubscriber()Construct an AMSSubscriber behaviour to receive notifications about platform events from the local AMSAMSSubscriber(AID ams)Construct an AMSSubscriber behaviour to receive notifications about platform events from the AMS of a remote platform.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaction()Runs the behaviour.voidcancel()booleandone()Check if this behaviour is done.ACLMessagegetCancel()Retrieve thecancelACL message used to cancel the subscription to the AMS.ACLMessagegetSubscribe()Retrieve thesubscribeACL message used to subscribe to the AMS.protected abstract voidinstallHandlers(Map handlersTable)This method has to be implemented by concrete subclasses, filling theMappassed as parameter with implementations of theEventHandlerinterface, using the name of the event as key (see theEventinterface.voidonStart()This method is just an empty placeholders for subclasses.-
Methods inherited from class jade.core.behaviours.SimpleBehaviour
reset
-
Methods inherited from class jade.core.behaviours.Behaviour
actionWrapper, block, block, getAgent, getBehaviourName, getDataStore, getExecutionState, getParent, getRestartCounter, handle, handleBlockEvent, handleRestartEvent, isRunnable, onEnd, restart, root, setAgent, setBehaviourName, setDataStore, setExecutionState
-
-
-
-
Field Detail
-
AMS_SUBSCRIPTION
public static final String AMS_SUBSCRIPTION
- See Also:
- Constant Field Values
-
AMS_CANCELLATION
public static final String AMS_CANCELLATION
- See Also:
- Constant Field Values
-
PLATFORM_EVENTS
public static final String PLATFORM_EVENTS
- See Also:
- Constant Field Values
-
-
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:BehaviourThis 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 thisBehaviour.
-
installHandlers
protected abstract void installHandlers(Map handlersTable)
This method has to be implemented by concrete subclasses, filling theMappassed as parameter with implementations of theEventHandlerinterface, using the name of the event as key (see theEventinterface.- Parameters:
handlersTable- The table that associates each event name with a proper handler.
-
action
public final void action()
Description copied from class:BehaviourRuns the behaviour. This abstract method must be implemented byBehavioursubclasses to perform ordinary behaviour duty. An agent schedules its behaviours calling theiraction()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:
actionin classBehaviour- See Also:
CompositeBehaviour
-
done
public final boolean done()
Description copied from class:BehaviourCheck if this behaviour is done. The agent scheduler calls this method to see whether aBehaviourstill 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.
-
cancel
public void cancel()
-
getSubscribe
public final ACLMessage getSubscribe()
Retrieve thesubscribeACL 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 thecancelACL 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 thecancelmessage to the AMS when notifications are no longer required.- Returns:
- The cancellation ACL message.
-
-