|
||||||||||
| 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.TwoPhResponder
public class TwoPhResponder
Class description
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class jade.core.behaviours.Behaviour |
|---|
Behaviour.RunnableChangedEvent |
| Field Summary | |
|---|---|
protected static java.lang.String |
CHECK_IN_SEQ
|
protected static java.lang.String |
HANDLE_OUT_OF_SEQUENCE
|
protected static java.lang.String |
RECEIVE_INITIATION
|
protected static java.lang.String |
RECEIVE_NEXT
|
java.lang.String |
RECEIVED_KEY
Key to retrieve from the DataStore of the behaviour the last received ACLMessage |
java.lang.String |
REPLY_KEY
Key to set into the DataStore of the behaviour the new ACLMessage to be sent back to the initiator as a reply. |
protected static java.lang.String |
SEND_REPLY
|
| 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 | |
|---|---|
TwoPhResponder(Agent a,
MessageTemplate mt)
Constructor of the behaviour that creates a new empty DataStore |
|
TwoPhResponder(Agent a,
MessageTemplate mt,
DataStore store)
Constructor of the behaviour. |
|
| Method Summary | |
|---|---|
protected boolean |
checkInSequence(ACLMessage received)
Check whether a received message complies with the protocol rules. |
static MessageTemplate |
createMessageTemplate()
This static method can be used to set the proper message Template (based on the interaction protocol and the performative) to be passed to the constructor of this behaviour. |
protected ACLMessage |
handleAcceptProposal(ACLMessage accept)
This method is called after the ACCEPT-PROPOSAL has been received. |
protected ACLMessage |
handleCfp(ACLMessage cfp)
This method is called when the initiator's message is received that matches the message template passed in the constructor. |
protected void |
handleOutOfSequence(ACLMessage msg)
This method is called whenever a message is received that does not comply to the protocol rules. |
protected ACLMessage |
handleQueryIf(ACLMessage queryIf)
This method is called after the QUERY-IF has been received. |
protected ACLMessage |
handleRejectProposal(ACLMessage reject)
This method is called after the REJECT-PROPOSAL has been received. |
protected void |
registerDSState(Behaviour b,
java.lang.String name)
Utility method to register a behaviour in a state of the protocol and set the DataStore appropriately |
void |
registerHandleAcceptProposal(Behaviour b)
This method allows to register a user defined Behaviour
in the HANDLE_ACCEPTANCE state. |
void |
registerHandleCfp(Behaviour b)
This method allows to register a user defined Behaviour
in the PREPARE_PROPOSE state. |
void |
registerHandleOutOfSequence(Behaviour b)
This method allows to register a user defined Behaviour
in the HANDLE_OUT_OF_SEQ state. |
void |
registerHandleQueryIf(Behaviour b)
This method allows to register a user defined Behaviour
in the HANDLE_QUERY_IF state. |
void |
registerHandleRejectProposal(Behaviour b)
This method allows to register a user defined Behaviour
in the HANDLE_REJECT state. |
protected void |
replySent(int exitValue)
This method can be redefined by protocol specific implementations to update the status of the protocol after a reply has been sent. |
void |
reset()
Reset this behaviour. |
| 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, onStart, restart, root, setBehaviourName, setDataStore, 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 RECEIVED_KEY
public final java.lang.String REPLY_KEY
protected static final java.lang.String RECEIVE_INITIATION
protected static final java.lang.String RECEIVE_NEXT
protected static final java.lang.String HANDLE_OUT_OF_SEQUENCE
protected static final java.lang.String CHECK_IN_SEQ
protected static final java.lang.String SEND_REPLY
| Constructor Detail |
|---|
public TwoPhResponder(Agent a,
MessageTemplate mt)
TwoPhResponder(Agent a, MessageTemplate mt, DataStore store)
public TwoPhResponder(Agent a,
MessageTemplate mt,
DataStore store)
a - is the reference to the Agent objectmt - is the MessageTemplate that must be used to match
the initiator message. Take care that if mt is null every message is
consumed by this protocol.
The best practice is to have a MessageTemplate that matches
the protocol slot; the static method createMessageTemplate
might be usefull.store - the DataStore for this protocol behaviour| Method Detail |
|---|
protected ACLMessage handleCfp(ACLMessage cfp)
cfp - the received message
PROPOSE, FAILURE. Remind to
use the method createReply of the class ACLMessage in order
to create a valid reply messageACLMessage.createReply()protected ACLMessage handleQueryIf(ACLMessage queryIf)
QUERY-IF has been received.
This default implementation return null which has
the effect of sending no result notification. Programmers should
override the method in case they need to react to this event.
queryIf - the received message
CONFIRM, INFORM, DISCONFIRM. Remind to
use the method createReply of the class ACLMessage in order
to create a valid reply messageACLMessage.createReply()protected ACLMessage handleRejectProposal(ACLMessage reject)
REJECT-PROPOSAL has been received.
This default implementation do nothing.
Programmers should override the method in case they need to react to this event.
reject - the received message
INFORM. Remind to
use the method createReply of the class ACLMessage in order
to create a valid reply messageACLMessage.createReply()protected ACLMessage handleAcceptProposal(ACLMessage accept)
ACCEPT-PROPOSAL has been received.
This default implementation return null which has
the effect of sending no result notification. Programmers should
override the method in case they need to react to this event.
accept - the received message
INFORM. Remind to use the method createReply of
the class ACLMessage in order to create a valid reply messageACLMessage.createReply()public void registerHandleCfp(Behaviour b)
Behaviour
in the PREPARE_PROPOSE 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 response
to be sent into the datastore at the PROPOSE_KEY key.
b - the Behaviour that will handle this statepublic void registerHandleQueryIf(Behaviour b)
Behaviour
in the HANDLE_QUERY_IF 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 response
to be sent into the datastore at the REPLY_KEY key.
b - the Behaviour that will handle this statepublic void registerHandleRejectProposal(Behaviour b)
Behaviour
in the HANDLE_REJECT 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 response
to be sent into the datastore at the REPLY_KEY key.
b - the Behaviour that will handle this statepublic void registerHandleAcceptProposal(Behaviour b)
Behaviour
in the HANDLE_ACCEPTANCE 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 response
to be sent into the datastore at the REPLY_KEY key.
b - the Behaviour that will handle this statepublic static MessageTemplate createMessageTemplate()
FIPANames.InteractionProtocolpublic void reset()
protected boolean checkInSequence(ACLMessage received)
protected void replySent(int exitValue)
protected void handleOutOfSequence(ACLMessage msg)
msg - the received out-of-sequence message.public void registerHandleOutOfSequence(Behaviour b)
Behaviour
in the HANDLE_OUT_OF_SEQ 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 out of sequence ACLMessage object received
from the datastore at the RECEIVED_KEY
key.
b - the Behaviour that will handle this state
protected void registerDSState(Behaviour b,
java.lang.String name)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||