Esempio n. 1
0
  void replyNotUnderstood(ACLMessage msg) {
    // -----------------------------------------

    try {
      ContentElement content = getContentManager().extractContent(msg);
      ACLMessage reply = msg.createReply();
      reply.setPerformative(ACLMessage.NOT_UNDERSTOOD);
      getContentManager().fillContent(reply, content);
      send(reply);
      System.out.println("Not understood!");
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Esempio n. 2
0
    public void action() {

      try {
        ContentElement content = getContentManager().extractContent(query);
        Information info = (Information) ((Action) content).getAction();
        Object obj = processInformation(info);
        if (obj == null) replyNotUnderstood(query);
        else {
          ACLMessage reply = query.createReply();
          reply.setPerformative(ACLMessage.INFORM);
          Result result = new Result((Action) content, obj);
          getContentManager().fillContent(reply, result);
          send(reply);
          System.out.println("Information processed.");
        }
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
Esempio n. 3
0
    public void action() {

      try {
        ContentElement content = getContentManager().extractContent(request);
        CreateAccount ca = (CreateAccount) ((Action) content).getAction();
        Account acc = new Account();
        String id = generateId();
        acc.setId(id);
        acc.setName(ca.getName());
        Result result = new Result((Action) content, acc);
        ACLMessage reply = request.createReply();
        reply.setPerformative(ACLMessage.INFORM);
        getContentManager().fillContent(reply, result);
        send(reply);
        accounts.put(id, acc);
        operations.put(id, new ArrayList());
        System.out.println("Account [" + acc.getName() + " # " + acc.getId() + "] created!");
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }