Package jade.core.behaviours
Class BaseInitiator
-
- All Implemented Interfaces:
Serializable,Serializable
- Direct Known Subclasses:
ActionExecutor
public abstract class BaseInitiator extends AchieveREInitiator
Base class for behaviours implementing a FIPA-request like pattern with a single target agent.- 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 StringALL_INITIATIONS_Kprotected static StringCHECK_IN_SEQprotected static StringCHECK_SESSIONSprotected ConversationListconversationsprotected static StringDUMMY_FINALprotected static StringHANDLE_FAILUREprotected static StringHANDLE_NOT_UNDERSTOODprotected static StringHANDLE_OUT_OF_SEQprotected StringINITIATION_Kprotected LoggermyLoggerprotected OutcomeManageroutcomeprotected static StringPREPARE_INITIATIONSprotected static StringRECEIVE_REPLYprotected StringREPLY_Kprotected MsgReceiverreplyReceiverprotected MessageTemplatereplyTemplateprotected static StringSEND_INITIATIONSprotected Mapsessions-
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 BaseInitiator()BaseInitiator(OutcomeManager om)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidadjustReplyTemplate(ACLMessage msg)protected voidcheckLanguage(String languageName)protected voidcheckOntology(Ontology onto)protected StringcreateConvId(Vector msgs)Create a new conversation identifier to begin a new interaction.protected abstract ACLMessagecreateInitiation()Concrete subclasses are expected to implement this method to create the initiation message.StringgetErrorMsg()Shortcut method for getOutcome().getErrorMsg()intgetExitCode()Shortcut method for getOutcome().getExitCode()OutcomeManagergetOutcome()protected StringgetTargetDescription()Concrete subclasses can redefine this method to provide a human readable description of the target agent of this behaviour.voidhandleAllResultNotifications(Vector notifications)This method is called when all the result notification messages have been collected.voidhandleFailure(ACLMessage failure)This method is called every time afailuremessage is received, which is not out-of-sequence according to the protocol rules.voidhandleNotUnderstood(ACLMessage notUnderstood)This method is called every time anot-understoodmessage 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.voidhandleRefuse(ACLMessage refuse)This method is called every time arefusemessage is received, which is not out-of-sequence according to the protocol rules.voidhandleTimeout()intonEnd()Override the onEnd() method to return the exit value of the last executed state.voidonStart()Override the onStart() method to initialize the vectors that will keep all the replies in the data store.VectorprepareRequests(ACLMessage msg)This method must return the vector of ACLMessage objects to be sent.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 voidsendInitiations(Vector initiations)Create and initialize the Sessions and sends the initiation messagesvoidsetActiveConversations(ConversationList conversations)voidsetDataStore(DataStore ds)Override the setDataStore() method to propagate this setting to all children.-
Methods inherited from class jade.proto.AchieveREInitiator
checkInSequence, checkSessions, getSession, getToBeReset, handleAgree, handleAllResponses, handleInform, 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
-
outcome
protected OutcomeManager outcome
-
conversations
protected ConversationList conversations
-
myLogger
protected Logger myLogger
-
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
-
-
Constructor Detail
-
BaseInitiator
public BaseInitiator()
-
BaseInitiator
public BaseInitiator(OutcomeManager om)
-
-
Method Detail
-
setActiveConversations
public void setActiveConversations(ConversationList conversations)
-
checkLanguage
protected void checkLanguage(String languageName)
-
checkOntology
protected void checkOntology(Ontology onto)
-
getOutcome
public OutcomeManager getOutcome()
-
getExitCode
public int getExitCode()
Shortcut method for getOutcome().getExitCode()
-
getErrorMsg
public String getErrorMsg()
Shortcut method for getOutcome().getErrorMsg()
-
createInitiation
protected abstract ACLMessage createInitiation()
Concrete subclasses are expected to implement this method to create the initiation message.- Returns:
- The initiation message used by this behaviour
-
getTargetDescription
protected String getTargetDescription()
Concrete subclasses can redefine this method to provide a human readable description of the target agent of this behaviour. Such description will be used in all default error messages.- Returns:
- A human readable description of the target agent of this behaviour
-
prepareRequests
public Vector prepareRequests(ACLMessage msg)
Description copied from class:AchieveREInitiatorThis method must return the vector of ACLMessage objects to be sent. It is called in the first state of this protocol. This default implementation just returns the ACLMessage object passed in the constructor. Programmers might prefer to override this method in order to return a vector of objects for 1:N conversations or also to prepare the messages during the execution of the behaviour.- Overrides:
prepareRequestsin classAchieveREInitiator- Parameters:
msg- the ACLMessage object passed in the constructor- Returns:
- a Vector of ACLMessage objects.
The values of the slot
reply-withis ignored and a different value is assigned automatically by this class for each receiver.
-
handleRefuse
public void handleRefuse(ACLMessage refuse)
Description copied from class:AchieveREInitiatorThis method is called every time arefusemessage 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:
handleRefusein classAchieveREInitiator- Parameters:
refuse- the received refuse message
-
handleNotUnderstood
public void handleNotUnderstood(ACLMessage notUnderstood)
This method is called every time anot-understoodmessage 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.- Parameters:
notUnderstood- the received not-understood message
-
handleFailure
public void handleFailure(ACLMessage failure)
This method is called every time afailuremessage 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.- Parameters:
failure- the received failure message
-
handleAllResultNotifications
public void handleAllResultNotifications(Vector notifications)
Description copied from class:AchieveREInitiatorThis method is called when all the result notification messages have been collected. By result notification message we intend here all theinform, failurereceived messages, which are not 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.- Overrides:
handleAllResultNotificationsin classAchieveREInitiator
-
handleTimeout
public void handleTimeout()
-
onEnd
public int onEnd()
Description copied from class:FSMBehaviourOverride the onEnd() method to return the exit value of the last executed state.- Overrides:
onEndin classFSMBehaviour- Returns:
- an integer code representing the termination value of the behaviour.
-
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)
-
-