|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jade.core.behaviours.Behaviour | +--jade.core.behaviours.CompositeBehaviour | +--jade.core.behaviours.SerialBehaviour | +--jade.core.behaviours.FSMBehaviour | +--jade.proto.ProposeResponder
Behaviour class for 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 FormField Summary | |
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
|
Fields inherited from class jade.core.behaviours.FSMBehaviour |
currentName, lastStates, previousName |
Fields inherited from class jade.core.behaviours.Behaviour |
myAgent |
Fields inherited from interface jade.domain.FIPANames.InteractionProtocol |
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 |
Constructor Summary | |
ProposeResponder(Agent a,
MessageTemplate mt)
Constructor of the behaviour that creates a new empty DataStore |
|
ProposeResponder(Agent a,
MessageTemplate mt,
DataStore store)
Constructor. |
Method Summary | |
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. |
Methods inherited from class jade.core.behaviours.FSMBehaviour |
checkTermination, deregisterState, forceTransitionTo, getChildren, getCurrent, getLastExitValue, getName, getPrevious, getState, handleInconsistentFSM, handleStateEntered, onEnd, registerDefaultTransition, registerDefaultTransition, registerFirstState, registerLastState, registerState, registerTransition, registerTransition, resetStates, scheduleFirst, scheduleNext |
Methods inherited from class jade.core.behaviours.CompositeBehaviour |
action, block, done, resetChildren, restart, setAgent |
Methods inherited from class jade.core.behaviours.Behaviour |
block, getBehaviourName, getDataStore, getParent, isRunnable, onStart, root, setBehaviourName, setDataStore |
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 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
Constructor Detail |
public ProposeResponder(Agent a, MessageTemplate mt)
ProposeResponder(Agent a, MessageTemplate mt, DataStore store)
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 protocolMethod Detail |
public 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 message
accept_proposal, reject_proposal, not-understood
.
Remind to use the method createReply of the class ACLMessage
in order to create a good reply message
NotUnderstoodException
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
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |