Package jade.core.behaviours
Class OntologyServer
- java.lang.Object
-
- jade.core.behaviours.Behaviour
-
- jade.core.behaviours.SimpleBehaviour
-
- jade.core.behaviours.CyclicBehaviour
-
- jade.core.behaviours.OntologyServer
-
- All Implemented Interfaces:
Serializable,Serializable
public class OntologyServer extends CyclicBehaviour
Ready made behaviour that for each incoming message automatically invokes a corresponding method of the form
public void serveCcccPppp(Cccc c, ACLMessage msg) throws Exception
where Cccc represents the key content-element referenced by the incoming message msg and Pppp represents the performative of the message.
ContentElement-s representing SL0 operatorsaction,doneandresultare automatically managed so that for instance if an incoming REQUEST message is received carrying a content of type
((action (actor ...) (Sell ...)))
a serving method with signature
public void serveSellRequest(Sell s, ACLMessage msg) throws Exception
will be searched.
Serving methods are responsible for sending back responses 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 LoggermyLoggerprotected MessageTemplatetemplate-
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 OntologyServer(Agent a, Ontology onto, int performative)OntologyServer(Agent a, Ontology onto, int[] performatives)OntologyServer(Agent a, Ontology onto, int[] performatives, Object serverDelegate)OntologyServer(Agent a, Ontology onto, int performative, Object serverDelegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaction()Runs the behaviour.voidaddPerformativeRequiringReply(int performative)If an unexpected error occurs in one of the serving methods or if a suitable serving method is not found for an incoming message, the OntologyServer automatically sends back a FAILURE or REFUSE message if the incoming performative was one of REQUEST, CFP, PROPOSE, QUERY, SUBSCRIBE, PROXY and PROPAGATE.voidconversationFinished(String convId)Notifies this OntologyServer that a given conversation is finished and therefore it must no longer ignore messages belonging to it.protected ObjectextractKeyContentElement(ContentElement ce)ConversationListgetIgnoredConversations()ContentElementgetReceivedContentElement()Allows subclasses to retrieve the actually received content element e.g.protected voidhandleMessage(ACLMessage msg)protected voidhandleNotUnderstood(ContentException ce, ACLMessage msg)protected voidhandleServingFailure(Throwable t, Object cel, ACLMessage msg)protected voidhandleUnsupported(Object keyCel, ACLMessage msg)voidignoreConversation(String convId)Makes this OntologyServer ignore all incoming messages belonging to a given conversation i.e.voidonStart()This method is just an empty placeholders for subclasses.voidremovePerformativeRequiringReply(int performative)voidsetIgnoredConversations(ConversationList l)Set theConversationListused by this OntologyServer to determine which conversations to ignore (if any).voidsetLanguage(Codec codec)voidsetMaxProcessedMessagesPerRun(int maxProcessedMessagesPerRun)Instruct the OntologyServer to process up to maxProcessedMessagesPerRun messages each time it is scheduled for execution.voidsetMessageTemplate(MessageTemplate template)voidsetPrintFullUnexpectedMessages(boolean printFullUnexpectedMessages)-
Methods inherited from class jade.core.behaviours.CyclicBehaviour
done
-
Methods inherited from class jade.core.behaviours.SimpleBehaviour
reset
-
Methods inherited from class jade.core.behaviours.Behaviour
actionWrapper, block, block, getAgent, getBehaviourName, getDataStore, getExecutionState, getParent, getRestartCounter, handle, handleBlockEvent, handleRestartEvent, isRunnable, onEnd, restart, root, setAgent, setBehaviourName, setDataStore, setExecutionState
-
-
-
-
Field Detail
-
template
protected MessageTemplate template
-
myLogger
protected Logger myLogger
-
-
Method Detail
-
setLanguage
public void setLanguage(Codec codec)
-
setMessageTemplate
public void setMessageTemplate(MessageTemplate template)
-
setMaxProcessedMessagesPerRun
public void setMaxProcessedMessagesPerRun(int maxProcessedMessagesPerRun)
Instruct the OntologyServer to process up to maxProcessedMessagesPerRun messages each time it is scheduled for execution. This can be useful for performance reasons when the agent executing this behaviour has to deal with a heavy load of messages- Parameters:
maxProcessedMessagesPerRun-
-
setIgnoredConversations
public void setIgnoredConversations(ConversationList l)
Set theConversationListused by this OntologyServer to determine which conversations to ignore (if any). Note: calling this method after the behaviour started has no effect- See Also:
ignoreConversation(java.lang.String)
-
getIgnoredConversations
public ConversationList getIgnoredConversations()
-
addPerformativeRequiringReply
public void addPerformativeRequiringReply(int performative)
If an unexpected error occurs in one of the serving methods or if a suitable serving method is not found for an incoming message, the OntologyServer automatically sends back a FAILURE or REFUSE message if the incoming performative was one of REQUEST, CFP, PROPOSE, QUERY, SUBSCRIBE, PROXY and PROPAGATE. In other cases the OntologyServer simply logs a suitable error message. The above list of performatives can be customized by means of this method as well as theaddPerformativeRequiringReply(int)one.- Parameters:
performative- The performative to be added
-
removePerformativeRequiringReply
public void removePerformativeRequiringReply(int performative)
- Parameters:
performative- The performative to be removed- See Also:
addPerformativeRequiringReply(int)
-
setPrintFullUnexpectedMessages
public void setPrintFullUnexpectedMessages(boolean printFullUnexpectedMessages)
-
onStart
public void onStart()
Description copied from class:BehaviourThis method is just an empty placeholders for subclasses. It is executed just once before starting behaviour execution. Therefore, it acts as a prolog to the task represented by thisBehaviour.
-
action
public final void action()
Description copied from class:BehaviourRuns the behaviour. This abstract method must be implemented byBehavioursubclasses to perform ordinary behaviour duty. An agent schedules its behaviours calling theiraction()method; since all the behaviours belonging to the same agent are scheduled cooperatively, this method must not enter in an endless loop and should return as soon as possible to preserve agent responsiveness. To split a long and slow task into smaller section, recursive behaviour aggregation may be used.- Specified by:
actionin classBehaviour- See Also:
CompositeBehaviour
-
handleMessage
protected void handleMessage(ACLMessage msg)
-
getReceivedContentElement
public final ContentElement getReceivedContentElement()
Allows subclasses to retrieve the actually received content element e.g. Action, Done, Result- Returns:
-
extractKeyContentElement
protected Object extractKeyContentElement(ContentElement ce)
-
handleUnsupported
protected void handleUnsupported(Object keyCel, ACLMessage msg)
-
handleServingFailure
protected void handleServingFailure(Throwable t, Object cel, ACLMessage msg)
-
handleNotUnderstood
protected void handleNotUnderstood(ContentException ce, ACLMessage msg)
-
ignoreConversation
public void ignoreConversation(String convId)
Makes this OntologyServer ignore all incoming messages belonging to a given conversation i.e. marked with the indicated conversation-id
-
conversationFinished
public void conversationFinished(String convId)
Notifies this OntologyServer that a given conversation is finished and therefore it must no longer ignore messages belonging to it.- See Also:
ignoreConversation(java.lang.String)
-
-