Package jade.core

Examples of jade.core.AID


    this.gui = gui;
  }
 
  public void actionPerformed(ActionEvent e)
  { 
    AID df;
    DFAgentDscDlg dlg = new DFAgentDscDlg((Frame) gui);
    DFAgentDescription editedDfd = dlg.ShowDFDGui(null,true,true);
 
    if (editedDfd != null)
    {
      int kind = gui.kindOfOperation();
   
      if ((kind == DFGUI.PARENT_VIEW) || (kind == DFGUI.CHILDREN_VIEW)) // selected a df from the the federation
      {
          AID name = gui.getSelectedAgentInTable();
          if (name != null)
            df = name;
          else 
            df = gui.myAgent.getDescriptionOfThisDF().getName();
       
View Full Code Here


      // Nothing to do here: INFORM_MOVED has no target-side action...
    }
   
    private void handleInformCloned(VerticalCommand cmd) throws JADESecurityException, NotFoundException, NameClashException {
      Object[] params = cmd.getParams();
      AID agentID = (AID)params[0];
      ContainerID cid = (ContainerID)params[1];
      Credentials creds = (Credentials)params[2];
     
      clonedAgent(agentID, cid, creds);
    }
View Full Code Here

  }
 
  public void actionPerformed(ActionEvent e)
  {
    DFAgentDescription dfd;
    AID df =null;
    AID name;
    int kind = gui.kindOfOperation();
   
    if ( kind == DFGUI.AGENT_VIEW || kind == DFGUI.CHILDREN_VIEW)
    {
      // Deregister an agent from the descriptor table   
View Full Code Here

    }
   
    private void handleInformKilled(VerticalCommand cmd) throws IMTPException, NotFoundException, ServiceException {
     
      Object[] params = cmd.getParams();
      AID target = (AID)params[0];

      //log("Source Sink consuming command INFORM_KILLED. Name is "+target.getName(), 3);
      if(myLogger.isLoggable(Logger.CONFIG))
        myLogger.log(Logger.CONFIG,"Outgoing Filer accepting command INFORM_KILLED. Name is "+target.getName());
     
      // Remove CodeLocator entry.
      String containerName = myContainer.getID().getName();
      Agent agent = myContainer.acquireLocalAgent(target);
      String codeContainerName = getClassSite(agent);
      myContainer.releaseLocalAgent(target);

      //Check if the agent have migrated or not.
      if (codeContainerName != null) {
   
        // Check if the code is in a remote container (if its local it has
        // been removed by the AgentManagementService).
        if (!containerName.equals(codeContainerName)) {

          //Send a REMOVE_CODE_LOCATOR_ENTRY command to the container with the agent code.
          AgentMobilitySlice codeSlice = (AgentMobilitySlice) getSlice(codeContainerName);
          // Note that the Code-Container can be exited in the meanwhile
          if (codeSlice != null) {
            try {
              try {
                codeSlice.removeCodeLocatorEntry(target);           
              } catch (IMTPException imtpe) {
                // Try to get a newer slice and repeat...
                codeSlice = (AgentMobilitySlice) getSlice(codeContainerName);
                codeSlice.removeCodeLocatorEntry(target);
              }
            }
            catch (Exception e) {
              // We can't notify the Code-Container --> print a warning, but do not stop the agent termination process
              myLogger.log(Logger.WARNING, "Error notifying home container "+codeContainerName+" of terminating agent "+target.getName(), e);
            }
          }
        }
      }
    }
View Full Code Here

    }

    private boolean handleNotifyFailure(VerticalCommand cmd) throws IMTPException, ServiceException {
      Object[] params = cmd.getParams();
      GenericMessage msg = (GenericMessage)params[0];//FIXME: check object type
      AID receiver = (AID)params[1];
      ACLMessage acl = msg.getACLMessage();

      if(myLogger.isLoggable(Logger.FINE))
        myLogger.log(Logger.FINE,"Processing failed message "+MessageManager.stringify(msg)+" for agent "+receiver.getName());


      // FIXME: We should check if the failure is due to a "not found receiver"

      // Ask all slices whether the failed message should be stored
      Service.Slice[] slices = getAllSlices();
      for(int i = 0; i < slices.length; i++) {
        PersistentDeliverySlice slice = (PersistentDeliverySlice)slices[i];
        try {
          boolean firstTime = (acl.getUserDefinedParameter(ACL_USERDEF_DUE_DATE) == null);
          boolean accepted = false;
          try {
            accepted = slice.storeMessage(null, msg, receiver);
          }
          catch(IMTPException imtpe) {
            // Try to get a fresh slice and repeat...
            slice = (PersistentDeliverySlice)getFreshSlice(slice.getNode().getName());
            accepted = slice.storeMessage(null, msg, receiver);
          }

          if(accepted) {
            myLogger.log((firstTime ? Logger.INFO : Logger.FINE) ,"Message "+MessageManager.stringify(msg)+" for agent "+receiver.getName()+" stored on node "+slice.getNode().getName());
            // The message was stored --> Veto the NOTIFY_FAILURE command
            return false;
          }
        }
        catch(Exception e) {
          myLogger.log(Logger.WARNING,"Error trying to store message "+MessageManager.stringify(msg)+" for agent "+receiver.getName()+" on node "+slice.getNode().getName());
          // Ignore it and try other slices...
        }
      }

      return true;
View Full Code Here

      }
    }

    private void handleInformCreated(VerticalCommand cmd) throws IMTPException, ServiceException {
      Object[] params = cmd.getParams();
      AID agentID = (AID)params[0];
      flushMessages(agentID);
    }
View Full Code Here

          String traceId = (String) params[5];
          GenericMessage msg = new GenericMessage();
          msg.update(acl, env, payload);
          msg.setTraceID(traceId);
          msg.setForeignReceiver(foreignRecv.booleanValue());
          AID receiver = (AID)params[6];

          boolean stored = storeMessage(storeName, msg, receiver);
          cmd.setReturnValue(new Boolean(stored));
        }
        else if(cmdName.equals(PersistentDeliverySlice.H_FLUSHMESSAGES)) {
          AID receiver = (AID)params[0];

          flushMessages(receiver);
        }
      }
      catch(Throwable t) {
View Full Code Here

 
  public void actionPerformed(ActionEvent e)
  {
    int kind = gui.kindOfOperation();
   
    AID name = gui.getSelectedAgentInTable();
    DFAgentDescription dfd = null;
    AID df = gui.myAgent.getDescriptionOfThisDF().getName();;

    if (name != null) //something was selected
    {
        if ( kind == DFGUI.AGENT_VIEW)
        try{
View Full Code Here

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

        if(cmdName.equals(AgentMobilitySlice.H_CREATEAGENT)) {
          AID agentID = (AID)params[0];
          byte[] serializedInstance = (byte[])params[1];
          String classSiteName = (String)params[2];
          boolean isCloned = ((Boolean)params[3]).booleanValue();
          boolean startIt = ((Boolean)params[4]).booleanValue();
         
          createAgent(agentID, serializedInstance, classSiteName, isCloned, startIt);
        }
        else if(cmdName.equals(AgentMobilitySlice.H_FETCHCLASSFILE)) {
          String className = (String)params[0];
          String agentName = (String)params[1];
         
          cmd.setReturnValue(fetchClassFile(className, agentName));
        }
        else if(cmdName.equals(AgentMobilitySlice.H_MOVEAGENT)) {
          GenericCommand gCmd = new GenericCommand(AgentMobilityHelper.REQUEST_MOVE, AgentMobilitySlice.NAME, null);
          AID agentID = (AID)params[0];
          Location where = (Location)params[1];
          gCmd.addParam(agentID);
          gCmd.addParam(where);
         
          result = gCmd;
        }
        else if(cmdName.equals(AgentMobilitySlice.H_COPYAGENT)) {
          GenericCommand gCmd = new GenericCommand(AgentMobilityHelper.REQUEST_CLONE, AgentMobilitySlice.NAME, null);
          AID agentID = (AID)params[0];
          Location where = (Location)params[1];
          String newName = (String)params[2];
          gCmd.addParam(agentID);
          gCmd.addParam(where);
          gCmd.addParam(newName);
         
          result = gCmd;
        }
        else if(cmdName.equals(AgentMobilitySlice.H_PREPARE)) {
         
          cmd.setReturnValue(new Boolean(prepare()));
        }
        else if(cmdName.equals(AgentMobilitySlice.H_TRANSFERIDENTITY)) {
          AID agentID = (AID)params[0];
          Location src = (Location)params[1];
          Location dest = (Location)params[2];
         
          cmd.setReturnValue(new Boolean(transferIdentity(agentID, src, dest)));
        }
        else if(cmdName.equals(AgentMobilitySlice.H_HANDLETRANSFERRESULT)) {
          AID agentID = (AID)params[0];
          boolean transferResult = ((Boolean)params[1]).booleanValue();
          List messages = (List)params[2];
         
          handleTransferResult(agentID, transferResult, messages);
        }
        else if(cmdName.equals(AgentMobilitySlice.H_CLONEDAGENT)) {
          GenericCommand gCmd = new GenericCommand(AgentMobilityHelper.INFORM_CLONED, AgentMobilitySlice.NAME, null);
          AID agentID = (AID)params[0];
          ContainerID cid = (ContainerID)params[1];
          Credentials creds = (Credentials)params[2];
          gCmd.addParam(agentID);
          gCmd.addParam(cid);
          gCmd.addParam(creds);
         
          result = gCmd;
        }
        //#J2ME_EXCLUDE_BEGIN
        else if(cmdName.equals(AgentMobilitySlice.H_CLONECODELOCATORENTRY)) {
          AID oldAgentID = (AID)params[0];
          AID newAgentID = (AID)params[1];
         
          handleCloneCodeLocatorEntry(oldAgentID, newAgentID);
        }
        else if(cmdName.equals(AgentMobilitySlice.H_REMOVECODELOCATORENTRY)) {
          AID agentID = (AID)params[0];

          handleRemoveCodeLocatorEntry(agentID);
        }
        //#J2ME_EXCLUDE_END
      }
View Full Code Here

      //#J2ME_EXCLUDE_BEGIN
      if (classStream == null && agentName != null) {
        // Maybe the class belongs to a separate Jar file --> Try with the CodeLocator
        try {
          AgentManagementService amSrv = (AgentManagementService) myFinder.findService(AgentManagementService.NAME);
          ClassLoader cLoader = amSrv.getCodeLocator().getAgentClassLoader(new AID(agentName, AID.ISGUID));
          classStream = cLoader.getResourceAsStream(fileName);
        }
        catch (NullPointerException npe) {
          // No jarfile or class not found in jarfile. Ignore
        }
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.