Class 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 operators action, done and result are 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
    • Constructor Detail

      • OntologyServer

        public OntologyServer​(Agent a,
                              Ontology onto,
                              int performative)
      • OntologyServer

        public OntologyServer​(Agent a,
                              Ontology onto,
                              int[] performatives)
      • OntologyServer

        public OntologyServer​(Agent a,
                              Ontology onto,
                              int performative,
                              Object serverDelegate)
      • OntologyServer

        public OntologyServer​(Agent a,
                              Ontology onto,
                              int[] performatives,
                              Object serverDelegate)
    • 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 the ConversationList used 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)
      • 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 the addPerformativeRequiringReply(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: Behaviour
        This 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 this Behaviour.
        Overrides:
        onStart in class Behaviour
      • action

        public final void action()
        Description copied from class: Behaviour
        Runs the behaviour. This abstract method must be implemented by Behavioursubclasses to perform ordinary behaviour duty. An agent schedules its behaviours calling their action() 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:
        action in class Behaviour
        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:
      • handleUnsupported

        protected void handleUnsupported​(Object keyCel,
                                         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)