public class TwoPh1Initiator extends FSMBehaviour
Modifier and Type | Field and Description |
---|---|
java.lang.String |
ALL_CONFIRMS_KEY
key to retrieve from the DataStore of the behaviour the Vector of
CONFIRM messages that have been received as response.
|
java.lang.String |
ALL_DISCONFIRMS_KEY
key to retrieve from the DataStore of the behaviour the Vector of
DISCONFIRM messages that have been received as response.
|
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.
|
java.lang.String |
ALL_PENDINGS_KEY
key to retrieve from the DataStore of the behaviour the Vector of
QUERY_IF messages for which a response has not been received yet.
|
java.lang.String |
ALL_QUERYIFS_KEY
key to retrieve from the DataStore of the behaviour the Vector of
QUERY_IF messages that have to be sent.
|
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.
|
java.lang.String |
QUERYIF_KEY
key to retrieve from the DataStore of the behaviour the ACLMessage
object passed in the constructor of the class.
|
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).
|
currentName, lastStates
Constructor and Description |
---|
TwoPh1Initiator(Agent a,
ACLMessage queryIf,
java.lang.String outputKey)
Constructs a
TwoPh1Initiator behaviour. |
TwoPh1Initiator(Agent a,
ACLMessage queryIf,
java.lang.String outputKey,
DataStore store)
Constructs a
TwoPh1Initiator behaviour. |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
createConvId(java.util.Vector msgs)
Create a new conversation identifier to begin a new
interaction.
|
protected ProtocolSession |
getSession(ACLMessage msg,
int sessionIndex) |
protected void |
handleAllResponses(java.util.Vector responses,
java.util.Vector confirms,
java.util.Vector disconfirms,
java.util.Vector informs,
java.util.Vector pendings,
java.util.Vector nextPhMsgs)
This method is called when all the responses have been collected or when
the timeout is expired.
|
protected void |
handleConfirm(ACLMessage confirm)
This method is called every time a
confirm message is received,
which is not out-of-sequence according to the protocol rules. |
protected void |
handleDisconfirm(ACLMessage disconfirm)
This method is called every time a
disconfirm message is received,
which is not out-of-sequence according to the protocol rules. |
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.
|
int |
onEnd()
Override the onEnd() method to return the exit value of the
last executed state.
|
void |
onStart()
Override the onStart() method to initialize the vectors that
will keep all the replies in the data store.
|
protected java.util.Vector |
prepareQueryIfs(ACLMessage queryIf)
This method must return the vector of ACLMessage objects to be sent.
|
void |
registerHandleAllResponses(Behaviour b)
This method allows to register a user defined
Behaviour in the
HANDLE_ALL_RESPONSES state. |
void |
registerHandleConfirm(Behaviour b)
This method allows to register a user defined
Behaviour in the
HANDLE_CONFIRM state. |
void |
registerHandleDisconfirm(Behaviour b)
This method allows to register a user defined
Behaviour in the
HANDLE_DISCONFIRM 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 |
registerPrepareQueryIfs(Behaviour b)
This method allows to register a user-defined
Behaviour in the
PREPARE_QUERYIFS 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
|
void |
setDataStore(DataStore ds)
Override the setDataStore() method to propagate this
setting to all children.
|
checkTermination, deregisterDefaultTransition, deregisterState, deregisterTransition, forceTransitionTo, getChildren, getCurrent, getLastExitValue, getName, getPrevious, getState, handleInconsistentFSM, handleStateEntered, hasDefaultTransition, registerDefaultTransition, registerDefaultTransition, registerFirstState, registerLastState, registerState, registerTransition, registerTransition, resetStates, scheduleFirst, scheduleNext, stringifyTransitionTable
action, done, resetChildren, setAgent
block, block, getAgent, getBehaviourName, getDataStore, getParent, isRunnable, restart, root, setBehaviourName
public final java.lang.String QUERYIF_KEY
public final java.lang.String ALL_QUERYIFS_KEY
public final java.lang.String REPLY_KEY
public final java.lang.String ALL_RESPONSES_KEY
public final java.lang.String ALL_CONFIRMS_KEY
public final java.lang.String ALL_DISCONFIRMS_KEY
public final java.lang.String ALL_INFORMS_KEY
public final java.lang.String ALL_PENDINGS_KEY
public TwoPh1Initiator(Agent a, ACLMessage queryIf, java.lang.String outputKey)
TwoPh1Initiator
behaviour.a
- The agent performing the protocol.conversationId
- Conversation-id
slot used for all the
duration of phase1's protocol.inputKey
- Data store key where behaviour can get queryIf messages
prepared in the previous phase.outputKey
- Data store key where the behaviour prepares a vector of
messages which will be send by a TwoPh2Initiator
behaviour.
If phase 1 ends with all confirm or inform than messages prepared are
accept-proposal
, otherwise they are reject-proposal
.public TwoPh1Initiator(Agent a, ACLMessage queryIf, java.lang.String outputKey, DataStore store)
TwoPh1Initiator
behaviour.a
- The agent performing the protocol.conversationId
- Conversation-id
slot used for all the
duration of phase1's protocol.inputKey
- Data store key where behaviour can get queryIf messages
prepared in the previous phase.outputKey
- Data store key where the behaviour prepares a vector of
messages which will be send by a TwoPh2Initiator
behaviour.
If phase 1 ends with all confirm or inform than messages prepared are
accept-proposal
, otherwise they are reject-proposal
.store
- DataStore
that will be used by this TwoPh1Initiator
.public int onEnd()
FSMBehaviour
onEnd
in class FSMBehaviour
protected java.util.Vector prepareQueryIfs(ACLMessage queryIf)
queryIf
- the ACLMessage object passed in the constructorreply-with
slot is ignored and regenerated automatically by this
class. Instead user can specify reply-by
slot representing phase0
timeout.protected void handleConfirm(ACLMessage confirm)
confirm
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.confirm
- the received propose messageprotected void handleDisconfirm(ACLMessage disconfirm)
disconfirm
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.disconfirm
- the received propose 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 propose messageprotected void handleAllResponses(java.util.Vector responses, java.util.Vector confirms, java.util.Vector disconfirms, java.util.Vector informs, java.util.Vector pendings, java.util.Vector nextPhMsgs)
reply-By
of all the sent messages. By response message we
intend here all the disconfirm, confirm, inform
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.confirms
- all confirms receiveddisconfirms
- all disconfirms receivedpendings
- all queryIfs still pendingresponses
- prepared responses for next phase: accept-proposal
or reject-proposal
public void registerPrepareQueryIfs(Behaviour b)
Behaviour
in the
PREPARE_QUERYIFS 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_QUERYIFS_KEY
key.b
- the Behaviour that will handle this statepublic void registerHandleConfirm(Behaviour b)
Behaviour
in the
HANDLE_CONFIRM 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 confirm
ACLMessage object received from the datastore at the
REPLY_KEY
key.b
- the Behaviour that will handle this statepublic void registerHandleDisconfirm(Behaviour b)
Behaviour
in the
HANDLE_DISCONFIRM 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 disconfirm
ACLMessage object received from the datastore at the
REPLY_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 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 confirms, disconfirms, informs, pending and responses
from the datastore at ALL_CONFIRMS_KEY
, ALL_DISCONFIRMS_KEY
,
ALL_INFORMS_KEY
, ALL_PH1_PENDINGS_KEY
and
output
field.b
- the Behaviour that will handle this stateprotected 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 messagepublic 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 FSMBehaviour
public void reset(ACLMessage msg)
msg
- is the ACLMessage to be sentprotected void reinit()
public void onStart()
public void setDataStore(DataStore ds)
setDataStore
in class Behaviour
ds
- 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.