Package jade.core

Examples of jade.core.AID


        gui.disposeAsync();
        gui = null;
        break;
      }
      case DFGUIAdapter.REGISTER: {
        AID df = (AID) ev.getParameter(0);
        final DFAgentDescription dfd = (DFAgentDescription) ev.getParameter(1);
        DFService.checkIsValid(dfd, true);
       
        if (getAID().equals(df)) {
          // Register an agent with this DF
          DFRegister(dfd);
        }
        else {
          // Register an agent with another DF.
          gui.showStatusMsg("Processing your request & waiting for result...");
          Register r = new Register();
          r.setDescription(dfd);
          Behaviour b = new RemoteDFRequester(df, r) {
            public int onEnd() {
              Object result = getResult();
              if (!(result instanceof InternalError)) {
                gui.showStatusMsg("Registration request processed. Ready for new request");
                if(dfd.getName().equals(myAgent.getAID())) {
                  // The registered agent is the DF itself --> This is a federation
                  addParent(getRemoteDF(), dfd);
                }
              }
              else {
                gui.showStatusMsg("Error processing request. "+((InternalError) result).getMessage());
              }
              return 0;
            }
          };
          addBehaviour(b);
        }
        break;
      }
      case DFGUIAdapter.DEREGISTER: {
        AID df = (AID) ev.getParameter(0);
        final DFAgentDescription dfd = (DFAgentDescription) ev.getParameter(1);
        DFService.checkIsValid(dfd, false);
       
        if (getAID().equals(df)) {
          // Deregister an agent with this DF
          DFDeregister(dfd);
        }
        else {
          // Deregister an agent with another DF.
          gui.showStatusMsg("Processing your request & waiting for result...");
          Deregister d = new Deregister();
          d.setDescription(dfd);
          Behaviour b = new RemoteDFRequester(df, d) {
            public int onEnd() {
              Object result = getResult();
              if (!(result instanceof InternalError)) {
                gui.showStatusMsg("Deregistration request processed. Ready for new request");
                if(dfd.getName().equals(myAgent.getAID())) {
                  // The deregistered agent is the DF itself --> Remove a federation
                  removeParent(getRemoteDF());
                }
                else {
                  gui.removeSearchResult(dfd.getName());
                }
              }
              else {
                gui.showStatusMsg("Error processing request. "+((InternalError) result).getMessage());
              }
              return 0;
            }
          };
          addBehaviour(b);
        }
        break;
      }
      case DFGUIAdapter.MODIFY: {
        AID df = (AID) ev.getParameter(0);
        DFAgentDescription dfd = (DFAgentDescription) ev.getParameter(1);
        DFService.checkIsValid(dfd, true);
       
        if (getAID().equals(df)) {
          // Modify the description of an agent with this DF
          DFModify(dfd);
        }
        else {
          // Modify the description of an agent with another DF
          gui.showStatusMsg("Processing your request & waiting for result...");
          Modify m = new Modify();
          m.setDescription(dfd);
          Behaviour b = new RemoteDFRequester(df, m) {
            public int onEnd() {
              Object result = getResult();
              if (!(result instanceof InternalError)) {
                gui.showStatusMsg("Modification request processed. Ready for new request");
              }
              else {
                gui.showStatusMsg("Error processing request. "+((InternalError) result).getMessage());
              }
              return 0;
            }
          };
          addBehaviour(b);
        }
        break;
      }
      case DFGUIAdapter.SEARCH: {
        AID df = (AID) ev.getParameter(0);
        DFAgentDescription dfd = (DFAgentDescription) ev.getParameter(1);
        SearchConstraints sc = (SearchConstraints)ev.getParameter(2);
       
        // Note that we activate a RemoteDFBehaviour even if the DF to perform
        // the search on is the local DF. This allows handling recursive
        // search (if needed) correctly         
        gui.showStatusMsg("Processing your request & waiting for result...");
        Search s = new Search();
        s.setDescription(dfd);
        s.setConstraints(sc);
        Behaviour b = new RemoteDFRequester(df, s) {
          public int onEnd() {
            Object result = getResult();
            if (!(result instanceof InternalError)) {
              gui.showStatusMsg("Search request processed. Ready for new request");
              gui.refreshLastSearchResults((List) result, getRemoteDF());
            }
            else {
              gui.showStatusMsg("Error processing request. "+((InternalError) result).getMessage());
            }
            return 0;
          }
        };
        addBehaviour(b);
        break;
      }
      case DFGUIAdapter.FEDERATE: {
        AID df = (AID) ev.getParameter(0);
        final DFAgentDescription dfd = (DFAgentDescription) ev.getParameter(1);
       
        gui.showStatusMsg("Processing your request & waiting for result...");
        Register r = new Register();
        r.setDescription(dfd);
View Full Code Here


        }
      }
      try {
        getContentManager().fillContent(notification, ce);
        send(notification);
        AID receiver = (AID) notification.getAllReceiver().next();
        if(logger.isLoggable(Logger.FINE))
          logger.log(Logger.FINE,"Notification sent back to "+receiver.getName());
      }
      catch (Exception e) {
        // Should never happen
        if(logger.isLoggable(Logger.SEVERE))
          logger.log(Logger.SEVERE,"Error encoding pending notification content.");
View Full Code Here

   
    // Vertical command handler methods
   
    private void handleSendMessage(VerticalCommand cmd) {
      Object[] params = cmd.getParams();
      AID sender = (AID)params[0];
      GenericMessage msg = (GenericMessage)params[1];
      AID dest = (AID)params[2];
      // Since message delivery is asynchronous we use the GenericMessage
      // as a temporary holder for the sender principal and credentials
      msg.setSenderPrincipal(cmd.getPrincipal());
      msg.setSenderCredentials(cmd.getCredentials());
      msg.setSender(sender);
      checkTracing(msg);
      if (msg.getTraceID() != null) {
        myLogger.log(Logger.INFO, "MessagingService source sink handling message "+MessageManager.stringify(msg)+" for receiver "+dest.getName()+". TraceID = "+msg.getTraceID());
      }
      if (needSynchDelivery(msg)) {
        // Synchronous delivery: skip the MessageManager
        deliverNow(msg, dest);
      }
View Full Code Here

    }
   
    private void handleNotifyFailure(VerticalCommand cmd) {
      Object[] params = cmd.getParams();
      GenericMessage msg = (GenericMessage)params[0];
      AID receiver = (AID)params[1];
      InternalError ie = (InternalError)params[2];
     
      // The acl message contained inside the GenericMessage cannot be null; the notifyFailureToSender() method already checks that
      ACLMessage aclmsg = msg.getACLMessage();
      if((aclmsg.getSender()==null) || (aclmsg.getSender().equals(myContainer.getAMS()))) // sanity check to avoid infinite loops
        return;
     
      // Send back a failure message
      final ACLMessage failure = aclmsg.createReply();
      failure.setPerformative(ACLMessage.FAILURE);
      final AID theAMS = myContainer.getAMS();
      failure.setSender(theAMS);
      failure.setLanguage(FIPANames.ContentLanguage.FIPA_SL);
     
      // FIXME: the content is not completely correct, but that should
      // also avoid creating wrong content
View Full Code Here

     
    }
   
    private void handleSetPlatformAddresses(VerticalCommand cmd) {
      Object[] params = cmd.getParams();
      AID id = (AID)params[0];
      id.clearAllAddresses();
      addPlatformAddresses(id);
    }
View Full Code Here

          deadline = new Date(System.currentTimeMillis() + DEFAULTTIMEOUT);
        }
        requests = new Vector(children.size());
        Iterator it = children.iterator();
        while (it.hasNext()) {
          AID childDF = (AID) it.next();
          ACLMessage msg = DFService.createRequestMessage(myAgent, childDF, FIPAManagementVocabulary.SEARCH, template, constraints);
          msg.setReplyByDate(deadline);
          requests.addElement(msg);
        }
      }
View Full Code Here

    }

    int i = 0;
    aclModel.insertNodeInto(new DefaultMutableTreeNode(":act " + theACL.getPerformative(theACL.getPerformative())), messageNode, i++);

    AID sender = theACL.getSender();
    if (sender != null) {
      aclModel.insertNodeInto(new DefaultMutableTreeNode(":sender " + sender.toString()), messageNode, i++);
    }

    AID aid = new AID();
    Iterator it = theACL.getAllReceiver();
    while (it.hasNext()) {
      aid = (AID)it.next();
      aclModel.insertNodeInto(new DefaultMutableTreeNode(":receiver " + aid.toString()), messageNode, i++);
    }

    //reply-to
    Iterator replyItor = theACL.getAllReplyTo();
    while (replyItor.hasNext()) {
      aid = (AID)replyItor.next();
      aclModel.insertNodeInto(new DefaultMutableTreeNode(":reply-to " + aid.toString()), messageNode, i++);
    }

    aclModel.insertNodeInto(new DefaultMutableTreeNode("--- Description of Content ---"), messageNode, i++);
    aclModel.insertNodeInto(contentNode, messageNode, i++);
View Full Code Here

  /**
   *  Description of the Method
   */
  void doShowSender() {
    ACLAIDDialog aidGui = new ACLAIDDialog(agent);
    AID currentAID = itsMsg.getSender();
    AID editAID = (AID)currentAID.clone();
    aidGui.setItsAID(editAID);
    aidGui.setLocation((int)getLocationOnScreen().getX(), (int)getLocationOnScreen().getY());
    aidGui.setTitle(editable ? "edit ACL: " + editAID.getName() : "view ACL: " + editAID.getName());
    aidGui.setEditable(editable);
    aidGui.setVisible(true);
    if (aidGui.getOK()) {
      itsMsg.setSender(aidGui.getItsAID());
      senderTextField.setText(itsMsg.getSender().getName());
View Full Code Here

  }


  void doShowFrom() {
    ACLAIDDialog aidGui = new ACLAIDDialog(agent);
    AID currentAID = (itsMsg.getEnvelope().getFrom() != null ? itsMsg.getEnvelope().getFrom() : new AID());
    AID editAID = (AID)currentAID.clone();
    aidGui.setLocation((int)getLocationOnScreen().getX(), (int)getLocationOnScreen().getY());
    aidGui.setItsAID(editAID);
    aidGui.setTitle(editable ? "edit ACL: " + editAID.getName() : "view ACL: " + editAID.getName());
    aidGui.setEditable(editable);
    aidGui.setVisible(true);
    if (aidGui.getOK()) {
      itsMsg.getEnvelope().setFrom(aidGui.getItsAID());
      this.envFromTextField.setText(itsMsg.getEnvelope().getFrom().getName());
View Full Code Here

            try {
                String cmdName = cmd.getName();
                Object[] params = cmd.getParams();

                if (cmdName.equals(MessagingSlice.H_DISPATCHLOCALLY)) {
                    AID senderID = (AID) params[0];
                    GenericMessage msg = (GenericMessage) params[1];
                    AID receiverID = (AID) params[2];
                    dispatchLocally(senderID, msg, receiverID);
                } else if (cmdName.equals(MessagingSlice.H_ROUTEOUT)) {
                    Envelope env = (Envelope) params[0];
                    byte[] payload = (byte[]) params[1];
                    AID receiverID = (AID) params[2];
                    String address = (String) params[3];

                    routeOut(env, payload, receiverID, address);
                } else if (cmdName.equals(MessagingSlice.H_GETAGENTLOCATION)) {
                    AID agentID = (AID) params[0];

                    cmd.setReturnValue(getAgentLocation(agentID));
                } else if (cmdName.equals(MessagingSlice.H_INSTALLMTP)) {
                    String address = (String) params[0];
                    String className = (String) params[1];
View Full Code Here

TOP

Related Classes of jade.core.AID

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.