Пример #1
0
  public void onStart() {
    if (ignoredConversations == null) {
      ignoredConversations = new ConversationList(myAgent);
    }

    // Unless a template is explicitly set, we get messages matching the ontology, the served
    // performatives.
    if (template == null) {
      if (servedPerformatives != null) {
        template =
            MessageTemplate.and(
                MessageTemplate.MatchOntology(onto.getName()),
                new MessageTemplate(
                    new MatchExpression() {
                      public boolean match(ACLMessage msg) {
                        int perf = msg.getPerformative();
                        for (int p : servedPerformatives) {
                          if (p == perf) {
                            return true;
                          }
                        }
                        return false;
                      }
                    }));
      } else {
        // No performative specified --> Match all
        template = MessageTemplate.MatchOntology(onto.getName());
      }
    }
    // Whatever template is used we avoid intercepting messages belonging to external conversations
    template = MessageTemplate.and(template, ignoredConversations.getMessageTemplate());

    // Register Ontology and Language
    ContentManager cm = myAgent.getContentManager();
    if (cm.lookupOntology(onto.getName()) == null) {
      cm.registerOntology(onto);
    }
    this.codec = (codec != null ? codec : new SLCodec());
    if (cm.lookupLanguage(codec.getName()) == null) {
      cm.registerLanguage(codec);
    }
  }
Пример #2
0
 /**
  * Notifies this OntologyServer that a given conversation is finished and therefore it must no
  * longer ignore messages belonging to it.
  *
  * @see ignoreConversation(String)
  */
 public void conversationFinished(String convId) {
   ignoredConversations.deregisterConversation(convId);
 }
Пример #3
0
 /**
  * Makes this OntologyServer ignore all incoming messages belonging to a given conversation i.e.
  * marked with the indicated conversation-id
  */
 public void ignoreConversation(String convId) {
   ignoredConversations.registerConversation(convId);
 }