public class ProposeResponder extends FSMBehaviour implements FIPANames.InteractionProtocol
fipa-propose
Responder role. This behaviour implements the
fipa-propose
interaction protocol from the point
of view of a responder to a propose (propose
)
message.
The API of this class is similar and homogeneous to the
AchieveREResponder
.
When a message arrives
that matches the message template passed to the constructor,
the callback method prepareResponse
is executed
that must return the wished response, for instance the
ACCEPT_PROPOSAL
reply message. Any other type of returned communicative act
is sent and then closes the
protocol.
If a message were received, with the same value of this
conversation-id
, but that does not comply with the FIPA
protocol, than the method handleOutOfSequence
would be called.
This class can be extended by the programmer by overriding all the needed
handle methods or, in alternative, appropriate behaviours can be
registered for each handle via the registerHandle
-type
of methods. This last case is more difficult to use and proper
care must be taken to properly use the DataStore
of the
Behaviour
as a shared memory mechanism with the
registered behaviour.
Read carefully the section of the JADE programmer's guide that describes the usage of this class.
ProposeInitiator
,
AchieveREResponder
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected static java.lang.String |
PREPARE_RESPONSE |
java.lang.String |
PROPOSE_KEY
key to retrieve from the DataStore of the behaviour the ACLMessage
object sent by the initiator.
|
protected static java.lang.String |
RECEIVE_PROPOSE |
java.lang.String |
RESPONSE_KEY
key to retrieve from the DataStore of the behaviour the ACLMessage
object sent as a response to the initiator.
|
protected static java.lang.String |
SEND_RESPONSE |
currentName, lastStates
FIPA_BROKERING, FIPA_CONTRACT_NET, FIPA_DUTCH_AUCTION, FIPA_ENGLISH_AUCTION, FIPA_ITERATED_CONTRACT_NET, FIPA_PROPOSE, FIPA_QUERY, FIPA_RECRUITING, FIPA_REQUEST, FIPA_REQUEST_WHEN, FIPA_SUBSCRIBE, ITERATED_FIPA_REQUEST
Constructor and Description |
---|
ProposeResponder(Agent a,
MessageTemplate mt)
Constructor of the behaviour that creates a new empty DataStore
|
ProposeResponder(Agent a,
MessageTemplate mt,
DataStore store)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static MessageTemplate |
createMessageTemplate(java.lang.String iprotocol)
This static method can be used
to set the proper message template (based on the interaction protocol
and the performative)
into the constructor of this behaviour.
|
protected ACLMessage |
prepareResponse(ACLMessage propose)
This method is called when the initiator's
message is received that matches the message template
passed in the constructor.
|
void |
registerPrepareResponse(Behaviour b)
This method allows to register a user defined
Behaviour
in the PREPARE_RESPONSE state. |
void |
reset()
Reset this behaviour.
|
void |
reset(MessageTemplate mt)
This method allows to change the
MessageTemplate
that defines what messages this ProposeResponder will react to
and reset the protocol. |
checkTermination, deregisterDefaultTransition, deregisterState, deregisterTransition, forceTransitionTo, getChildren, getCurrent, getLastExitValue, getName, getPrevious, getState, handleInconsistentFSM, handleStateEntered, hasDefaultTransition, onEnd, registerDefaultTransition, registerDefaultTransition, registerFirstState, registerLastState, registerState, registerTransition, registerTransition, resetStates, scheduleFirst, scheduleNext, stringifyTransitionTable
action, done, resetChildren, setAgent
block, block, getAgent, getBehaviourName, getDataStore, getParent, isRunnable, onStart, restart, root, setBehaviourName, setDataStore
public final java.lang.String PROPOSE_KEY
public final java.lang.String RESPONSE_KEY
protected static final java.lang.String RECEIVE_PROPOSE
protected static final java.lang.String PREPARE_RESPONSE
protected static final java.lang.String SEND_RESPONSE
public ProposeResponder(Agent a, MessageTemplate mt)
public ProposeResponder(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.store
- the DataStore for this protocolpublic static MessageTemplate createMessageTemplate(java.lang.String iprotocol)
FIPANames.InteractionProtocol
public void reset()
reset
in class FSMBehaviour
public void reset(MessageTemplate mt)
MessageTemplate
that defines what messages this ProposeResponder will react to
and reset the protocol.protected ACLMessage prepareResponse(ACLMessage propose) throws NotUnderstoodException, RefuseException
propose
- the received messageaccept_proposal, reject_proposal, not-understood
.
Remind to use the method createReply of the class ACLMessage
in order to create a good reply messageNotUnderstoodException
RefuseException
ACLMessage.createReply()
public void registerPrepareResponse(Behaviour b)
Behaviour
in the PREPARE_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.
It is responsibility of the registered behaviour to put the
response to be sent into the datastore at the RESPONSE_KEY
key.b
- the Behaviour that will handle this state