|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjade.core.behaviours.Behaviour
jade.core.behaviours.CompositeBehaviour
jade.core.behaviours.SerialBehaviour
jade.core.behaviours.FSMBehaviour
jade.proto.TwoPh2Initiator
public class TwoPh2Initiator
Class description
| Nested Class Summary | |
|---|---|
protected static interface |
Initiator.ProtocolSession
Inner interface Session |
| Nested classes/interfaces inherited from class jade.core.behaviours.Behaviour |
|---|
Behaviour.RunnableChangedEvent |
| Field Summary | |
|---|---|
java.lang.String |
ACCEPTANCE_KEY
key to retrieve from the DataStore of the behaviour the ACLMessage object passed in the constructor of the class. |
java.lang.String |
ALL_ACCEPTANCES_KEY
key to retrieve from the DataStore of the behaviour the vector of ACCEPT_PROPOSAL or REJECT_PROPOSAL messages that have to be sent. |
java.lang.String |
ALL_INFORMS_KEY
key to retrieve from the DataStore of the behaviour the vector of INFORM messages that have been received as response. |
protected java.lang.String |
ALL_INITIATIONS_K
|
java.lang.String |
ALL_PENDINGS_KEY
key to retrieve from the DataStore of the behaviour the vector of ACCEPT_PROPOSAL or REJECT_PROPOSAL messages for which a response has not been received yet. |
java.lang.String |
ALL_RESPONSES_KEY
key to retrieve from the DataStore of the behaviour the Vector of all messages that have been received as response. |
protected static java.lang.String |
CHECK_IN_SEQ
|
protected static java.lang.String |
CHECK_SESSIONS
|
protected static java.lang.String |
DUMMY_FINAL
|
protected static java.lang.String |
HANDLE_FAILURE
|
protected static java.lang.String |
HANDLE_NOT_UNDERSTOOD
|
protected static java.lang.String |
HANDLE_OUT_OF_SEQ
|
protected java.lang.String |
INITIATION_K
|
protected static java.lang.String |
PREPARE_INITIATIONS
|
protected static java.lang.String |
RECEIVE_REPLY
|
protected java.lang.String |
REPLY_K
|
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). |
protected jade.proto.states.MsgReceiver |
replyReceiver
|
protected MessageTemplate |
replyTemplate
|
protected static java.lang.String |
SEND_INITIATIONS
|
protected Map |
sessions
|
| Fields inherited from class jade.core.behaviours.FSMBehaviour |
|---|
currentName, lastStates |
| 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 | |
|---|---|
TwoPh2Initiator(Agent a,
ACLMessage acceptance)
Constructs a TwoPh2Initiator behaviour. |
|
TwoPh2Initiator(Agent a,
ACLMessage acceptance,
DataStore store)
Constructs a TwoPh2Initiator behaviour. |
|
| Method Summary | |
|---|---|
protected void |
adjustReplyTemplate(ACLMessage msg)
|
protected boolean |
checkInSequence(ACLMessage reply)
Check whether a reply is in-sequence and than update the appropriate Session and removes corresponding accept/reject-proposal from vector of pendings. |
protected int |
checkSessions(ACLMessage reply)
Check if there are still active sessions or if timeout is expired. |
protected java.lang.String |
createConvId(java.util.Vector msgs)
Create a new conversation identifier to begin a new interaction. |
protected Initiator.ProtocolSession |
getSession(ACLMessage msg,
int sessionIndex)
Return a ProtocolSession object to manage replies to a given initiation message |
protected java.lang.String[] |
getToBeReset()
Return the states that must be reset before they are visited again. |
protected void |
handleAllResponses(java.util.Vector responses)
This method is called when all the responses 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 |
handleOldResponse(ACLMessage old)
This method is called every time a failure, a disconfirm
or an inform 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 |
initializeDataStore(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 java.util.Vector |
prepareAcceptances(ACLMessage acceptance)
This method must return the vector of ACLMessage objects to be sent. |
protected java.util.Vector |
prepareInitiations(ACLMessage initiation)
Returns vector of accept/reject-proposal stored in the data store at key inputKey from previouse phase. |
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 |
registerHandleOldResponse(Behaviour b)
This method allows to register a user defined Behaviour in the
HANDLE_OLD_RESPONSE state. |
void |
registerHandleOutOfSequence(Behaviour b)
This method allows to register a user defined Behaviour
in the HANDLE_OUT_OF_SEQ state. |
protected void |
registerPrepareInitiations(Behaviour b)
Attach a behaviour to the Prepare-initiations
protocol state. |
void |
registerPrepareProposals(Behaviour b)
This method allows to register a user-defined Behaviour in the
PREPARE_ACCEPTANCES 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(ACLMessage msg)
reset this behaviour |
protected void |
sendInitiations(java.util.Vector initiations)
This method sets for all prepared accept/reject-proposal conversation-id slot (with value passed in the constructor),
protocol slot and reply-with slot with a unique
value constructed by concatenating receiver's agent name and phase number
(i.e. 2). |
void |
setDataStore(DataStore ds)
Override the setDataStore() method to propagate this setting to all children. |
| Methods inherited from class jade.core.behaviours.SerialBehaviour |
|---|
handle |
| Methods inherited from class jade.core.behaviours.CompositeBehaviour |
|---|
action, done, handleBlockEvent, handleRestartEvent, registerAsChild, resetChildren, setAgent |
| Methods inherited from class jade.core.behaviours.Behaviour |
|---|
actionWrapper, block, block, 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 |
| Field Detail |
|---|
public final java.lang.String ACCEPTANCE_KEY
public final java.lang.String ALL_ACCEPTANCES_KEY
public final java.lang.String REPLY_KEY
public final java.lang.String ALL_RESPONSES_KEY
public final java.lang.String ALL_INFORMS_KEY
public final java.lang.String ALL_PENDINGS_KEY
protected final java.lang.String INITIATION_K
protected final java.lang.String ALL_INITIATIONS_K
protected final java.lang.String REPLY_K
protected static final java.lang.String PREPARE_INITIATIONS
protected static final java.lang.String SEND_INITIATIONS
protected static final java.lang.String RECEIVE_REPLY
protected static final java.lang.String CHECK_IN_SEQ
protected static final java.lang.String HANDLE_NOT_UNDERSTOOD
protected static final java.lang.String HANDLE_FAILURE
protected static final java.lang.String HANDLE_OUT_OF_SEQ
protected static final java.lang.String CHECK_SESSIONS
protected static final java.lang.String DUMMY_FINAL
protected Map sessions
protected jade.proto.states.MsgReceiver replyReceiver
protected MessageTemplate replyTemplate
| Constructor Detail |
|---|
public TwoPh2Initiator(Agent a,
ACLMessage acceptance)
TwoPh2Initiator behaviour.
a - The agent performing the protocol.conversationId - Conversation-id slot used for all the
duration of phase2's protocol.inputKey - Data store key where behaviour can get accept-proposal or
reject-proposal messages prepared in the previous phase.
public TwoPh2Initiator(Agent a,
ACLMessage acceptance,
DataStore store)
TwoPh2Initiator behaviour.
a - The agent performing the protocol.conversationId - Conversation-id slot used for all the
duration of phase2's protocol.inputKey - Data store key where behaviour can get accept-proposal or
reject-proposal messages prepared in the previous phase.store - DataStore that will be used by this TwoPh2Initiator.| Method Detail |
|---|
protected java.util.Vector prepareAcceptances(ACLMessage acceptance)
acceptance - the ACLMessage object passed in the constructor
reply-with
slot is ignored and regenerated automatically by this
class. Instead user can specify the reply-by slot representing phase2
timeout.protected 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 propose messageprotected void handleOldResponse(ACLMessage old)
failure, a disconfirm
or an 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.
old - the received propose messageprotected void handleAllResponses(java.util.Vector responses)
inform (phase 2), failure
(phase 0), disconfirm (phase 1) and inform (phase 1)
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.
responses - all responses receivedpublic void registerPrepareProposals(Behaviour b)
Behaviour in the
PREPARE_ACCEPTANCES 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_ACCEPTANCES_KEY key.
b - the Behaviour that will handle this statepublic void registerHandleInform(Behaviour b)
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.
b - the Behaviour that will handle this statepublic void registerHandleOldResponse(Behaviour b)
Behaviour in the
HANDLE_OLD_RESPONSE 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, disconfirm or inform 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 received from the datastore at
ALL_RESPONSES_RECEIVED_KEY.
b - the Behaviour that will handle this stateprotected java.lang.String[] getToBeReset()
protected final java.util.Vector prepareInitiations(ACLMessage initiation)
inputKey from previouse phase.
initiation - ignored
protected final void sendInitiations(java.util.Vector initiations)
conversation-id slot (with value passed in the constructor),
protocol slot and reply-with slot with a unique
value constructed by concatenating receiver's agent name and phase number
(i.e. 2). After that it sends all accept/reject-proposal.
initiations - vector prepared in PREPARE_ACCEPTANCES stateprotected final boolean checkInSequence(ACLMessage reply)
reply - message received
protected final int checkSessions(ACLMessage reply)
reply - last message received
protected void initializeDataStore(ACLMessage msg)
msg - Ignored
protected Initiator.ProtocolSession getSession(ACLMessage msg,
int sessionIndex)
protected 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 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 registerPrepareInitiations(Behaviour b)
Prepare-initiations
protocol state.
b - The behaviour object to be executed in the
Prepare-initiations state.public void registerHandleNotUnderstood(Behaviour b)
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.
b - the Behaviour that will handle this statepublic void registerHandleFailure(Behaviour b)
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.
b - the Behaviour that will handle this statepublic void registerHandleOutOfSequence(Behaviour b)
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.
b - the Behaviour that will handle this statepublic void reset()
reset in class FSMBehaviourpublic void reset(ACLMessage msg)
msg - is the ACLMessage to be sentprotected void reinit()
public void onStart()
onStart in class Behaviourpublic void setDataStore(DataStore ds)
setDataStore in class Behaviourds - the DataStore that this Behaviour
will use as its private data storeprotected java.lang.String createConvId(java.util.Vector msgs)
msgs - A vector of ACL messages. If the first one has a
non-empty :conversation-id slot, its value is
used, else a new conversation identifier is generated.protected void adjustReplyTemplate(ACLMessage msg)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||