jade.domain.introspection
Class AMSSubscriber

java.lang.Object
  |
  +--jade.core.behaviours.Behaviour
        |
        +--jade.core.behaviours.SimpleBehaviour
              |
              +--jade.core.behaviours.CyclicBehaviour
                    |
                    +--jade.domain.introspection.AMSSubscriber
All Implemented Interfaces:
java.io.Serializable, Serializable

public abstract class AMSSubscriber
extends CyclicBehaviour

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

Nested Class Summary
static interface AMSSubscriber.EventHandler
          This interface must be implemented by concrete event handlers installed by this AMSSubscriber.
 
Field Summary
static java.lang.String AMS_CANCELLATION
           
static java.lang.String AMS_SUBSCRIPTION
           
static java.lang.String PLATFORM_EVENTS
           
 
Fields inherited from class jade.core.behaviours.Behaviour
myAgent
 
Constructor Summary
AMSSubscriber()
          Construct an AMSSubscriber behaviour to receive notifications about platform events from the local AMS
AMSSubscriber(AID ams)
          Construct an AMSSubscriber behaviour to receive notifications about platform events from the AMS of a remote platform.
 
Method Summary
 void action()
          Runs the behaviour.
 ACLMessage getCancel()
          Retrieve the cancel ACL message used to cancel the subscription to the AMS.
 ACLMessage getSubscribe()
          Retrieve the subscribe ACL message used to subscribe to the AMS.
protected abstract  void installHandlers(java.util.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.
 void onStart()
          This method is just an empty placeholders for subclasses.
 
Methods inherited from class jade.core.behaviours.CyclicBehaviour
done
 
Methods inherited from class jade.core.behaviours.SimpleBehaviour
reset
 
Methods inherited from class jade.core.behaviours.Behaviour
block, block, getBehaviourName, getDataStore, getParent, isRunnable, onEnd, restart, root, setAgent, setBehaviourName, setDataStore
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AMS_SUBSCRIPTION

public static final java.lang.String AMS_SUBSCRIPTION
See Also:
Constant Field Values

AMS_CANCELLATION

public static final java.lang.String AMS_CANCELLATION
See Also:
Constant Field Values

PLATFORM_EVENTS

public static final java.lang.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: 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(java.util.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

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.


JADE