|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jade.core.behaviours.Behaviour | +--jade.core.behaviours.CompositeBehaviour | +--jade.core.behaviours.FSMBehaviour | +--jade.proto.Initiator | +--jade.proto.AchieveREInitiator
This is a single homogeneous and effective implementation of all the FIPA-Request-like interaction protocols defined by FIPA, that is all those protocols where the initiator sends a single message (i.e. it performs a single communicative act) within the scope of an interaction protocol in order to verify if the RE (Rational Effect) of the communicative act has been achieved or not. This implementation works both for 1:1 and 1:N conversation.
FIPA has already specified a number of these interaction protocols, like FIPA-Request, FIPA-query, FIPA-propose, FIPA-Request-When, FIPA-recruiting, FIPA-brokering, that allows the initiator to verify if the expected rational effect of a single communicative act has been achieved.
The structure of these protocols is equal. The initiator sends a message (in general it performs a communicative act).
The responder can then reply by sending a not-understood
, or a
refuse
to
achieve the rational effect of the communicative act, or also
an agree
message to communicate the agreement to perform
(possibly in the future) the communicative act. This first category
of reply messages has been here identified as a response.
The responder performs the action and, finally, must respond with an
inform
of the result of the action (eventually just that the
action has been done) or with a failure
if anything went wrong.
This second category of reply messages has been here identified as a
result notification.
Notice that we have extended the protocol to make optional the transmission of the agree message. Infact, in most cases performing the action takes so short time that sending the agree message is just an useless and uneffective overhead; in such cases, the agree to perform the communicative act is subsumed by the reception of the following message in the protocol.
Read carefully the section of the JADE programmer's guide that describes the usage of this class.
Known bugs:
The handler handleAllResponses
is not called if the
agree
message is skipped and the inform
message
is received instead.
One message for every receiver is sent instead of a single
message for all the receivers.
Inner classes inherited from class jade.core.behaviours.Behaviour |
Behaviour.RunnableChangedEvent |
Field Summary | |
java.lang.String |
ALL_REQUESTS_KEY
key to retrieve from the DataStore of the behaviour the vector of ACLMessage objects that have been sent. |
java.lang.String |
ALL_RESPONSES_KEY
key to retrieve from the DataStore of the behaviour the vector of ACLMessage objects that have been received as response. |
java.lang.String |
ALL_RESULT_NOTIFICATIONS_KEY
key to retrieve from the DataStore of the behaviour the vector of ACLMessage objects that have been received as result notifications. |
java.lang.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). |
java.lang.String |
REQUEST_KEY
key to retrieve from the DataStore of the behaviour the ACLMessage object passed in the constructor of the class. |
Fields inherited from class jade.proto.Initiator |
ALL_INITIATIONS_K,
CHECK_IN_SEQ,
CHECK_SESSIONS,
DUMMY_FINAL,
HANDLE_FAILURE,
HANDLE_INFORM,
HANDLE_NOT_UNDERSTOOD,
HANDLE_OUT_OF_SEQ,
HANDLE_POSITIVE_RESPONSE,
HANDLE_REFUSE,
INITIATION_K,
PREPARE_INITIATIONS,
RECEIVE_REPLY,
REPLY_K,
replyReceiver,
replyTemplate,
SEND_INITIATIONS,
sessions,
toBeReset |
Fields inherited from class jade.core.behaviours.CompositeBehaviour |
currentExecuted |
Fields inherited from class jade.core.behaviours.Behaviour |
myAgent,
myEvent,
NOTIFY_DOWN,
NOTIFY_UP,
parent,
STATE_BLOCKED,
STATE_READY,
STATE_RUNNING |
Constructor Summary | |
AchieveREInitiator(Agent a,
ACLMessage msg)
Construct an AchieveREInitiator with an empty DataStore |
|
AchieveREInitiator(Agent a,
ACLMessage msg,
DataStore store)
Construct an AchieveREInitiator with a given DataStore |
Method Summary | |
protected boolean |
checkInSequence(ACLMessage reply)
Check whether a reply is in-sequence and update the appropriate Session |
protected int |
checkSessions(ACLMessage reply)
Check the status of the sessions after the reception of the last reply or the expiration of the timeout |
protected void |
handleAgree(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(java.util.Vector responses)
This method is called when all the responses have been collected or when the timeout is expired. |
protected void |
handleAllResultNotifications(java.util.Vector resultNotifications)
This method is called when all the result notification messages have been collected. |
protected void |
handleFailure(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(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(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(ACLMessage msg)
This method is called every time a message is received, which is out-of-sequence according to the protocol rules. |
protected void |
handlePositiveResponse(ACLMessage positiveResp)
|
protected void |
handleRefuse(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(ACLMessage msg)
Initialize the data store. |
protected java.util.Vector |
prepareInitiations(ACLMessage initiation)
|
protected java.util.Vector |
prepareRequests(ACLMessage request)
This method must return the vector of 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 |
registerHandleAllResultNotifications(Behaviour b)
This method allows to register a user defined Behaviour
in the HANDLE_ALL_RESULT_NOTIFICATIONS state.
|
void |
registerPrepareRequests(Behaviour b)
This method allows to register a user defined Behaviour
in the PREPARE_REQUESTS state.
|
void |
reset(ACLMessage msg)
reset this behaviour |
protected void |
sendInitiations(java.util.Vector initiations)
Create and initialize the Sessions and sends the initiation messages |
Methods inherited from class jade.proto.Initiator |
adjustReplyTemplate,
createConvId,
onStart,
registerHandleFailure,
registerHandleInform,
registerHandleNotUnderstood,
registerHandleOutOfSequence,
registerHandlePositiveResponse,
registerHandleRefuse,
registerPrepareInitiations,
reset,
setDataStore |
Methods inherited from class jade.core.behaviours.FSMBehaviour |
checkTermination,
forceTransitionTo,
getChildren,
getCurrent,
getLastExitValue,
getName,
getState,
handle,
onEnd,
registerDefaultTransition,
registerDefaultTransition,
registerFirstState,
registerLastState,
registerState,
registerTransition,
registerTransition,
resetStates,
scheduleFirst,
scheduleNext |
Methods inherited from class jade.core.behaviours.CompositeBehaviour |
action,
block,
done,
restart,
setAgent |
Methods inherited from class jade.core.behaviours.Behaviour |
actionWrapper,
block,
getBehaviourName,
getDataStore,
isRunnable,
root,
setBehaviourName |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public final java.lang.String REQUEST_KEY
public final java.lang.String ALL_REQUESTS_KEY
public final java.lang.String REPLY_KEY
public final java.lang.String ALL_RESPONSES_KEY
public final java.lang.String ALL_RESULT_NOTIFICATIONS_KEY
Constructor Detail |
public AchieveREInitiator(Agent a, ACLMessage msg)
AchieveREInitiator
with an empty DataStoreAchieveREInitiator(Agent, ACLMessage, DataStore)
public AchieveREInitiator(Agent a, ACLMessage msg, DataStore store)
AchieveREInitiator
with a given DataStorea
- The agent performing the protocolmsg
- The message that must be used to initiate the protocol.
Notice that the default implementation of the
prepareRequest()
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.store
- The DataStore
that will be used by this
AchieveREInitiator
Method Detail |
protected java.util.Vector prepareInitiations(ACLMessage initiation)
protected void sendInitiations(java.util.Vector initiations)
protected boolean checkInSequence(ACLMessage reply)
protected void handlePositiveResponse(ACLMessage positiveResp)
protected int checkSessions(ACLMessage reply)
protected java.util.Vector prepareRequests(ACLMessage request)
request
- the ACLMessage object passed in the constructorreply-with
is ignored and a different value is assigned
automatically by this class for each receiver.protected void handleAgree(ACLMessage agree)
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.agree
- the received agree messageprotected void handleRefuse(ACLMessage refuse)
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.refuse
- the received refuse messageprotected void handleNotUnderstood(ACLMessage notUnderstood)
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.notUnderstood
- the received not-understood messageprotected void handleInform(ACLMessage inform)
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.inform
- the received inform messageprotected void handleFailure(ACLMessage failure)
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.failure
- the received failure messageprotected void handleOutOfSequence(ACLMessage msg)
msg
- the received messageprotected void handleAllResponses(java.util.Vector responses)
replyBy
of all the sent messages.
By response message we intend here all the agree, not-understood,
refuse
received messages, which are not
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.responses
- the Vector of ACLMessage objects that have been receivedprotected void handleAllResultNotifications(java.util.Vector resultNotifications)
inform,
failure
received messages, which are not
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.resultNodifications
- the Vector of ACLMessage object receivedpublic void registerPrepareRequests(Behaviour b)
Behaviour
in the PREPARE_REQUESTS 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.
It is responsibility of the registered behaviour to put the
Vector of ACLMessage objects to be sent
into the datastore at the ALL_REQUESTS_KEY
key.
The values of the slot
reply-with
is ignored and a different value is assigned
automatically by this class for each receiver.b
- the Behaviour that will handle this statepublic void registerHandleAgree(Behaviour b)
Behaviour
in the HANDLE_AGREE 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 agree
ACLMessage object received
from the datastore at the REPLY_KEY
key.b
- the Behaviour that will handle this statepublic void registerHandleAllResponses(Behaviour b)
Behaviour
in the HANDLE_ALL_RESPONSES 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 vector of ACLMessage objects, received as a response,
from the datastore at the ALL_RESPONSES_KEY
key.b
- the Behaviour that will handle this statepublic void registerHandleAllResultNotifications(Behaviour b)
Behaviour
in the HANDLE_ALL_RESULT_NOTIFICATIONS 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 Vector of ACLMessage objects, received as a result notification,
from the datastore at the ALL_RESULT_NOTIFICATIONS_KEY
key.b
- the Behaviour that will handle this statepublic void reset(ACLMessage msg)
msg
- is the ACLMessage to be sentprotected void initializeDataStore(ACLMessage msg)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |