public abstract class AMSSubscriber extends SimpleBehaviour
installHandlers
method must be redefined to define the handlers for events the
agent executing this behaviour is interested in.Modifier and Type | Class and Description |
---|---|
static interface |
AMSSubscriber.EventHandler
This interface must be implemented by concrete event handlers
installed by this AMSSubscriber.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AMS_CANCELLATION |
static java.lang.String |
AMS_SUBSCRIPTION |
static java.lang.String |
PLATFORM_EVENTS |
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
void |
action()
Runs the behaviour.
|
void |
cancel() |
boolean |
done()
Check if this behaviour is done.
|
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.
|
reset
block, block, getAgent, getBehaviourName, getDataStore, getParent, isRunnable, onEnd, restart, root, setAgent, setBehaviourName, setDataStore
public static final java.lang.String AMS_SUBSCRIPTION
public static final java.lang.String AMS_CANCELLATION
public static final java.lang.String PLATFORM_EVENTS
public AMSSubscriber()
public AMSSubscriber(AID ams)
ams
- The AID of the remote platform AMSpublic void onStart()
Behaviour
Behaviour
.protected abstract void installHandlers(java.util.Map handlersTable)
Map
passed as parameter with
implementations of the EventHandler
interface,
using the name of the event as key (see the Event
interface.handlersTable
- The table that associates each event name
with a proper handler.public final void action()
Behaviour
Behaviour
subclasses 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.action
in class Behaviour
CompositeBehaviour
public final boolean done()
Behaviour
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.public void cancel()
public final ACLMessage getSubscribe()
subscribe
ACL message used to subscribe
to the AMS.
This message is automatically sent when this behaviour is added to an
Agent.public final ACLMessage getCancel()
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.