|
Nested classes/interfaces inherited from class sajas.core.behaviours.Behaviour |
Behaviour.RunnableChangedEvent |
Field Summary | ||
protected String |
ALL_INITIATIONS_K | |
String |
ALL_RESPONSES_KEY key to retrieve from the DataStore of the behaviour the vector of ACLMessage objects that have been received as responses. |
|
String |
ALL_SUBSCRIPTIONS_KEY key to retrieve from the DataStore of the behaviour the vector of subscription ACLMessage objects that have been sent. |
|
protected static String |
CHECK_IN_SEQ | |
protected static String |
CHECK_SESSIONS | |
protected static String |
DUMMY_FINAL | |
protected static String |
HANDLE_FAILURE | |
protected static String |
HANDLE_NOT_UNDERSTOOD | |
protected static String |
HANDLE_OUT_OF_SEQ | |
protected String |
INITIATION_K | |
protected static String |
PREPARE_INITIATIONS | |
protected static String |
RECEIVE_REPLY | |
protected String |
REPLY_K | |
String |
REPLY_KEY key to retrieve from the DataStore of the behaviour the last ACLMessage object that has been received (null if the timeout expired). |
|
protected MsgReceiver |
replyReceiver | |
protected jade.lang.acl.MessageTemplate |
replyTemplate | |
protected static String |
SEND_INITIATIONS | |
protected jade.util.leap.Map |
sessions | |
String |
SUBSCRIPTION_KEY key to retrieve from the DataStore of the behaviour the subscription ACLMessage object passed in the constructor of the class. |
Fields inherited from class sajas.core.behaviours.FSMBehaviour |
currentName, lastStates |
Fields inherited from class sajas.core.behaviours.CompositeBehaviour |
currentExecuted |
Fields inherited from class sajas.core.behaviours.Behaviour |
myAgent, myEvent, NOTIFY_DOWN, NOTIFY_UP, parent, STATE_BLOCKED, STATE_READY, STATE_RUNNING |
Constructor Summary | ||
SubscriptionInitiator(Agent a, jade.lang.acl.ACLMessage msg) Construct a SubscriptionInitiator with an empty DataStore |
||
SubscriptionInitiator(Agent a, jade.lang.acl.ACLMessage msg, DataStore store) Construct a SubscriptionInitiator with a given DataStore |
Method Summary | ||
protected void |
adjustReplyTemplate(jade.lang.acl.ACLMessage msg) | |
void |
cancel(AID receiver, boolean ignoreResponse) Cancel the subscription to agent receiver . |
|
void |
cancellationCompleted(AID receiver) This method should be called when the notification of a successful subscription cancellation is received from agent receiver to terminate the session with him. |
|
protected boolean |
checkInSequence(jade.lang.acl.ACLMessage reply) Check whether a reply is in-sequence and update the appropriate Session. |
|
protected int |
checkSessions(jade.lang.acl.ACLMessage reply) Check the status of the sessions after the reception of the last reply or the expiration of the timeout. |
|
protected String |
createConvId(Vector msgs) Create a new conversation identifier to begin a new interaction. |
|
protected void |
fillCancelContent(jade.lang.acl.ACLMessage subscription, jade.lang.acl.ACLMessage cancel) This method is used to fill the :content slot of the CANCEL message that is being sent to an agent to cancel the subscription previously activated by means of the subscription message. |
|
protected sajas.proto.Initiator.ProtocolSession |
getSession(jade.lang.acl.ACLMessage msg, int sessionIndex) Return a ProtocolSession object to manage replies to a given initiation message |
|
protected String[] |
getToBeReset() Return the states that must be reset before they are visited again. |
|
protected void |
handleAgree(jade.lang.acl.ACLMessage agree) This method is called every time an agree message is received, which is not out-of-sequence according to the protocol rules. |
|
protected void |
handleAllResponses(Vector responses) This method is called when all the responses have been collected or when the timeout is expired. |
|
protected void |
handleFailure(jade.lang.acl.ACLMessage failure) This method is called every time a failure message is received, which is not out-of-sequence according to the protocol rules. |
|
protected void |
handleInform(jade.lang.acl.ACLMessage inform) This method is called every time a inform message is received, which is not out-of-sequence according to the protocol rules. |
|
protected void |
handleNotUnderstood(jade.lang.acl.ACLMessage notUnderstood) This method is called every time a not-understood message is received, which is not out-of-sequence according to the protocol rules. |
|
protected void |
handleOutOfSequence(jade.lang.acl.ACLMessage msg) This method is called every time a message is received, which is out-of-sequence according to the protocol rules. |
|
protected void |
handleRefuse(jade.lang.acl.ACLMessage refuse) This method is called every time a refuse message is received, which is not out-of-sequence according to the protocol rules. |
|
protected void |
initializeDataStore(jade.lang.acl.ACLMessage msg) Initialize the data store. |
|
void |
onStart() Override the onStart() method to initialize the vectors that will keep all the replies in the data store. |
|
protected Vector |
prepareInitiations(jade.lang.acl.ACLMessage initiation) This method is called internally by the framework and is not intended to be called by the user |
|
protected Vector |
prepareSubscriptions(jade.lang.acl.ACLMessage subscription) This method must return the vector of subscription ACLMessage objects to be sent. |
|
void |
registerHandleAgree(Behaviour b) This method allows to register a user defined Behaviour in the HANDLE_AGREE state. |
|
void |
registerHandleAllResponses(Behaviour b) This method allows to register a user defined Behaviour in the HANDLE_ALL_RESPONSES state. |
|
void |
registerHandleFailure(Behaviour b) This method allows to register a user defined Behaviour in the HANDLE_FAILURE state. |
|
void |
registerHandleInform(Behaviour b) This method allows to register a user defined Behaviour in the HANDLE_INFORM state. |
|
void |
registerHandleNotUnderstood(Behaviour b) This method allows to register a user defined Behaviour in the HANDLE_NOT_UNDERSTOOD state. |
|
void |
registerHandleOutOfSequence(Behaviour b) This method allows to register a user defined Behaviour in the HANDLE_OUT_OF_SEQ state. |
|
void |
registerHandleRefuse(Behaviour b) This method allows to register a user defined Behaviour in the HANDLE_REFUSE state. |
|
protected void |
registerPrepareInitiations(Behaviour b) Attach a behaviour to the Prepare-initiations protocol state. |
|
void |
registerPrepareSubscriptions(Behaviour b) This method allows to register a user defined Behaviour in the PREPARE_SUBSCRIPTIONS state. |
|
protected void |
reinit() Re-initialize the internal state without performing a complete reset. |
|
void |
reset() reset this behaviour by putting a null ACLMessage as message to be sent |
|
void |
reset(jade.lang.acl.ACLMessage msg) reset this behaviour |
|
protected void |
sendInitiations(Vector initiations) Create and initialize the Sessions and sends the initiation messages |
|
void |
setDataStore(DataStore ds) Override the setDataStore() method to propagate this setting to all children. |
Methods inherited from class sajas.core.behaviours.SerialBehaviour |
handle |
Methods inherited from class sajas.core.behaviours.CompositeBehaviour |
action, done, handleBlockEvent, handleRestartEvent, registerAsChild, resetChildren, setAgent |
Methods inherited from class sajas.core.behaviours.Behaviour |
actionWrapper, block, block, getAgent, getBehaviourName, getDataStore, getExecutionState, getParent, getRestartCounter, isRunnable, restart, root, setBehaviourName, setExecutionState |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SubscriptionInitiator
with an empty DataStoreSubscriptionInitiator
with a given DataStoreprepareSubscription()
method returns
an array composed of only this message.
The values of the slot
reply-with
is ignored and a different value is assigned
automatically by this class for each receiver.DataStore
that will be used by this
SubscriptionInitiator
reply-with
is ignored and a different value is assigned
automatically by this class for each receiver.agree
message is received, which is not out-of-sequence according
to the protocol rules.
This default implementation does nothing; programmers might
wish to override the method in case they need to react to this event.refuse
message is received, which is not out-of-sequence according
to the protocol rules.
This default implementation does nothing; programmers might
wish to override the method in case they need to react to this event.inform
message is received, which is not out-of-sequence according
to the protocol rules.
This default implementation does nothing; programmers might
wish to override the method in case they need to react to this event.replyBy
of all the sent messages.
By response message we intend here all the agree, not-understood,
refuse, failure
received messages, which are
not out-of-sequence according
to the protocol rules.
This default implementation does nothing; programmers might
wish to override the method in case they need to react to this event
by analysing all the messages in just one call.Behaviour
in the PREPARE_SUBSCRIPTIONS 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.
It is responsibility of the registered behaviour to put the
Vector of ACLMessage objects to be sent
into the datastore at the ALL_SUBSCRIPTIONS_KEY
key.
The values of the slot
reply-with
is ignored and a different value is assigned
automatically by this class for each receiver.Behaviour
in the HANDLE_AGREE 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 agree
ACLMessage object received
from the datastore at the REPLY_KEY
key.Behaviour
in the HANDLE_INFORM state.
This behaviour would override the homonymous method.
This method also set the
data store of the registered Behaviour
to the
DataStore of this current behaviour.
The registered behaviour can retrieve
the inform
ACLMessage object received
from the datastore at the REPLY_KEY
key.Behaviour
in the HANDLE_REFUSE state.
This behaviour would override the homonymous method.
This method also set the
data store of the registered Behaviour
to the
DataStore of this current behaviour.
The registered behaviour can retrieve
the refuse
ACLMessage object received
from the datastore at the REPLY_KEY
key.Behaviour
in the HANDLE_ALL_RESPONSES 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 vector of ACLMessage objects, received as a response,
from the datastore at the ALL_RESPONSES_KEY
key.receiver
.
This method retrieves the subscription message sent to
receiver
and sends a suitable CANCEL message with
the conversationID and all other protocol fields appropriately set.
The :content
slot of this CANCEL message is filled
in by means of the fillCancelContent()
method. The way the CANCEL content is set in fact is application
specific.true
this response is ignored and the session with
agent receiver
is immediately terminated. When
ignoreResponse
is set to false
, on the
other hand, the session with agent receiver
remains
active and the INFORM or FAILURE massage (if any) will be handled by the
HANDLE_INFORM
and HANDLE_FAILURE
states
as if they were normal notifications. It is responsibility of
the programmer to distinguish them and actually terminate the
session with agent receiver
by calling the
cancellationCompleted()
method.:content
slot
of the CANCEL message that is being sent to an agent to cancel
the subscription previously activated by means of the
subscription
message. Note that all other relevant
fields of the cancel
message have already been
set appropriately and the programmer should not modify them.
The default implementation just sets a null content (the responder
should be able to identify the subscription that has to be
cancelled on the basis of the sender and conversationID fields
of the CANCEL message). Programmers may override this method to
create an appropriate content as exemplified in the code below.
try { AID receiver = (AID) cancel.getAllReceiver().next(); Action a = new Action(receiver, OntoACLMessage.wrap(subscription)); getContentManager.fillContent(cancel, a); } catch (Exception e) { e.printStackTrace(); }
receiver
to terminate the session with him.
This method has some effect only if a cancellation for
agent receiver
was previously activated by
means of the cancel()
method.not-understood
message is received, which is not out-of-sequence according
to the protocol rules.
This default implementation does nothing; programmers might
wish to override the method in case they need to react to this event.failure
message is received, which is not out-of-sequence according
to the protocol rules.
This default implementation does nothing; programmers might
wish to override the method in case they need to react to this event.Prepare-initiations
protocol state.Prepare-initiations
state.Behaviour
in the HANDLE_NOT_UNDERSTOOD state.
This behaviour would override the homonymous method.
This method also set the
data store of the registered Behaviour
to the
DataStore of this current behaviour.
The registered behaviour can retrieve
the not-understood
ACLMessage object received
from the datastore at the REPLY_KEY
key.Behaviour
in the HANDLE_FAILURE state.
This behaviour would override the homonymous method.
This method also set the
data store of the registered Behaviour
to the
DataStore of this current behaviour.
The registered behaviour can retrieve
the failure
ACLMessage object received
from the datastore at the REPLY_KEY
key.Behaviour
in the HANDLE_OUT_OF_SEQ state.
This behaviour would override the homonymous method.
This method also set 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 REPLY_KEY
key.DataStore
that this Behaviour
will use as its private data store:conversation-id
slot, its value is
used, else a new conversation identifier is generated.
|