Package jade.core.behaviours
Class ActionExecutor<ActionT extends AgentAction,ResultT>
- java.lang.Object
-
- jade.core.behaviours.Behaviour
-
- jade.core.behaviours.CompositeBehaviour
-
- jade.core.behaviours.SerialBehaviour
-
- jade.core.behaviours.FSMBehaviour
-
- jade.proto.AchieveREInitiator
-
- jade.core.behaviours.BaseInitiator
-
- jade.core.behaviours.ActionExecutor<ActionT,ResultT>
-
- Type Parameters:
ActionT- The class of the action to be executedResultT- The class of the result or Void if the action is not expected to return any result
- All Implemented Interfaces:
Serializable,Serializable
public class ActionExecutor<ActionT extends AgentAction,ResultT> extends BaseInitiator
Base class for behaviours intended to request the execution of an action to a given actor and get back the result (if any)- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jade.core.behaviours.Behaviour
Behaviour.RunnableChangedEvent
-
-
Field Summary
Fields Modifier and Type Field Description protected ActionTactionprotected AIDactorprotected StringALL_INITIATIONS_Kprotected static StringCHECK_IN_SEQprotected static StringCHECK_SESSIONSprotected StringconversationIdprotected static StringDUMMY_FINALprotected static StringHANDLE_FAILUREprotected static StringHANDLE_NOT_UNDERSTOODprotected static StringHANDLE_OUT_OF_SEQprotected StringINITIATION_Kprotected Stringlanguageprotected Ontologyontologyprotected static StringPREPARE_INITIATIONSprotected static StringRECEIVE_REPLYprotected StringREPLY_Kprotected MsgReceiverreplyReceiverprotected MessageTemplatereplyTemplateprotected ResultTresultprotected static StringSEND_INITIATIONSprotected Mapsessionsprotected longtimeout-
Fields inherited from class jade.core.behaviours.BaseInitiator
conversations, myLogger, outcome
-
Fields inherited from class jade.proto.AchieveREInitiator
ALL_REQUESTS_KEY, ALL_RESPONSES_KEY, ALL_RESULT_NOTIFICATIONS_KEY, CHECK_AGAIN, HANDLE_AGREE, HANDLE_ALL_RESPONSES, HANDLE_ALL_RESULT_NOTIFICATIONS, HANDLE_INFORM, HANDLE_REFUSE, REPLY_KEY, REQUEST_KEY
-
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
Constructors Constructor Description ActionExecutor(ActionT action, Ontology ontology, AID actor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidadjustReplyTemplate(ACLMessage msg)protected StringcreateConvId(Vector msgs)Create a new conversation identifier to begin a new interaction.protected ACLMessagecreateInitiation()Concrete subclasses are expected to implement this method to create the initiation message.protected ResultTextractResult(Result r)AIDgetActualActor()ResultTgetResult()voidhandleInform(ACLMessage inform)This method is called every time ainformmessage is received, which is not out-of-sequence according to the protocol rules.protected voidhandleOutOfSequence(ACLMessage msg)This method is called every time a message is received, which is out-of-sequence according to the protocol rules.voidonStart()Override the onStart() method to initialize the vectors that will keep all the replies in the data store.voidregisterHandleFailure(Behaviour b)This method allows to register a user definedBehaviourin the HANDLE_FAILURE state.voidregisterHandleNotUnderstood(Behaviour b)This method allows to register a user definedBehaviourin the HANDLE_NOT_UNDERSTOOD state.voidregisterHandleOutOfSequence(Behaviour b)This method allows to register a user definedBehaviourin the HANDLE_OUT_OF_SEQ state.protected voidregisterPrepareInitiations(Behaviour b)Attach a behaviour to thePrepare-initiationsprotocol state.voidreset()reset this behaviour by putting a null ACLMessage as message to be sentvoidreset(ACLMessage msg)reset this behaviourprotected AIDretrieveActor()protected voidsendInitiations(Vector initiations)Create and initialize the Sessions and sends the initiation messagesvoidsetAction(ActionT action)voidsetActor(AID actor)voidsetConversationId(String conversationId)voidsetDataStore(DataStore ds)Override the setDataStore() method to propagate this setting to all children.voidsetLanguage(String language)voidsetOntology(Ontology ontology)voidsetTimeout(long timeout)-
Methods inherited from class jade.core.behaviours.BaseInitiator
checkLanguage, checkOntology, getErrorMsg, getExitCode, getOutcome, getTargetDescription, handleAllResultNotifications, handleFailure, handleNotUnderstood, handleRefuse, handleTimeout, onEnd, prepareRequests, setActiveConversations
-
Methods inherited from class jade.proto.AchieveREInitiator
checkInSequence, checkSessions, getSession, getToBeReset, handleAgree, handleAllResponses, initializeDataStore, prepareInitiations, registerHandleAgree, registerHandleAllResponses, registerHandleAllResultNotifications, registerHandleInform, registerHandleRefuse, registerPrepareRequests, reinit
-
Methods inherited from class jade.core.behaviours.FSMBehaviour
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
-
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, getAgent, getBehaviourName, getDataStore, getExecutionState, getParent, getRestartCounter, isRunnable, restart, root, setBehaviourName, setExecutionState
-
-
-
-
Field Detail
-
action
protected ActionT extends AgentAction action
-
result
protected ResultT result
-
actor
protected AID actor
-
language
protected String language
-
ontology
protected Ontology ontology
-
timeout
protected long timeout
-
conversationId
protected String conversationId
-
INITIATION_K
protected final String INITIATION_K
-
ALL_INITIATIONS_K
protected final String ALL_INITIATIONS_K
-
REPLY_K
protected final String REPLY_K
-
PREPARE_INITIATIONS
protected static final String PREPARE_INITIATIONS
- See Also:
- Constant Field Values
-
SEND_INITIATIONS
protected static final String SEND_INITIATIONS
- See Also:
- Constant Field Values
-
RECEIVE_REPLY
protected static final String RECEIVE_REPLY
- See Also:
- Constant Field Values
-
CHECK_IN_SEQ
protected static final String CHECK_IN_SEQ
- See Also:
- Constant Field Values
-
HANDLE_NOT_UNDERSTOOD
protected static final String HANDLE_NOT_UNDERSTOOD
- See Also:
- Constant Field Values
-
HANDLE_FAILURE
protected static final String HANDLE_FAILURE
- See Also:
- Constant Field Values
-
HANDLE_OUT_OF_SEQ
protected static final String HANDLE_OUT_OF_SEQ
- See Also:
- Constant Field Values
-
CHECK_SESSIONS
protected static final String CHECK_SESSIONS
- See Also:
- Constant Field Values
-
DUMMY_FINAL
protected static final String DUMMY_FINAL
- See Also:
- Constant Field Values
-
sessions
protected Map sessions
-
replyReceiver
protected MsgReceiver replyReceiver
-
replyTemplate
protected MessageTemplate replyTemplate
-
-
Method Detail
-
setAction
public void setAction(ActionT action)
-
setActor
public void setActor(AID actor)
-
setOntology
public void setOntology(Ontology ontology)
-
setLanguage
public void setLanguage(String language)
-
setTimeout
public void setTimeout(long timeout)
-
setConversationId
public void setConversationId(String conversationId)
-
getResult
public ResultT getResult()
-
getActualActor
public AID getActualActor()
-
retrieveActor
protected AID retrieveActor() throws FIPAException
- Throws:
FIPAException
-
createInitiation
protected ACLMessage createInitiation()
Description copied from class:BaseInitiatorConcrete subclasses are expected to implement this method to create the initiation message.- Specified by:
createInitiationin classBaseInitiator- Returns:
- The initiation message used by this behaviour
-
handleInform
public void handleInform(ACLMessage inform)
Description copied from class:AchieveREInitiatorThis method is called every time ainformmessage 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.- Overrides:
handleInformin classAchieveREInitiator- Parameters:
inform- the received inform message
-
sendInitiations
protected void sendInitiations(Vector initiations)
Create and initialize the Sessions and sends the initiation messages
-
handleOutOfSequence
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. This default implementation does nothing; programmers might wish to override the method in case they need to react to this event.- Parameters:
msg- the received message
-
registerPrepareInitiations
protected void registerPrepareInitiations(Behaviour b)
Attach a behaviour to thePrepare-initiationsprotocol state.- Parameters:
b- The behaviour object to be executed in thePrepare-initiationsstate.
-
registerHandleNotUnderstood
public void registerHandleNotUnderstood(Behaviour b)
This method allows to register a user definedBehaviourin the HANDLE_NOT_UNDERSTOOD state. This behaviour would override the homonymous method. This method also set the data store of the registeredBehaviourto the DataStore of this current behaviour. The registered behaviour can retrieve thenot-understoodACLMessage object received from the datastore at theREPLY_KEYkey.- Parameters:
b- the Behaviour that will handle this state
-
registerHandleFailure
public void registerHandleFailure(Behaviour b)
This method allows to register a user definedBehaviourin the HANDLE_FAILURE state. This behaviour would override the homonymous method. This method also set the data store of the registeredBehaviourto the DataStore of this current behaviour. The registered behaviour can retrieve thefailureACLMessage object received from the datastore at theREPLY_KEYkey.- Parameters:
b- the Behaviour that will handle this state
-
registerHandleOutOfSequence
public void registerHandleOutOfSequence(Behaviour b)
This method allows to register a user definedBehaviourin the HANDLE_OUT_OF_SEQ state. This behaviour would override the homonymous method. This method also set the data store of the registeredBehaviourto the DataStore of this current behaviour. The registered behaviour can retrieve theout of sequenceACLMessage object received from the datastore at theREPLY_KEYkey.- Parameters:
b- the Behaviour that will handle this state
-
reset
public void reset()
reset this behaviour by putting a null ACLMessage as message to be sent- Overrides:
resetin classFSMBehaviour
-
reset
public void reset(ACLMessage msg)
reset this behaviour- Parameters:
msg- is the ACLMessage to be sent
-
onStart
public void onStart()
Override the onStart() method to initialize the vectors that will keep all the replies in the data store.
-
setDataStore
public void setDataStore(DataStore ds)
Override the setDataStore() method to propagate this setting to all children.- Overrides:
setDataStorein classBehaviour- Parameters:
ds- theDataStorethat thisBehaviourwill use as its private data store
-
createConvId
protected String createConvId(Vector msgs)
Create a new conversation identifier to begin a new interaction.- Parameters:
msgs- A vector of ACL messages. If the first one has a non-empty:conversation-idslot, its value is used, else a new conversation identifier is generated.
-
adjustReplyTemplate
protected void adjustReplyTemplate(ACLMessage msg)
-
-