Package jade.core

Examples of jade.core.Agent$Interrupted


     
      try {
        //#J2ME_EXCLUDE_BEGIN 
        //Register the clone in the Code Locator in the case its father is a jar agent
        String containerName = myContainer.getID().getName();
        Agent agent = myContainer.acquireLocalAgent(agentID);
        String codeContainerName = getClassSite(agent);
        myContainer.releaseLocalAgent(agentID);

        //Check if the code is in the same container or in a remote one.
        AgentManagementService amSrv = (AgentManagementService) myFinder.findService(AgentManagementService.NAME);
        CodeLocator codeLocator = amSrv.getCodeLocator();
       
        if (codeContainerName == null) codeContainerName = containerName;
        if (containerName.equals(codeContainerName)) {
          if (codeLocator.isRegistered(agentID)) {
            if(myLogger.isLoggable(Logger.FINE)) {
              myLogger.log(Logger.FINE," adding clone " + newName  + " to code locator.");
            }
           
            codeLocator.cloneAgent(agentID, new AID(newName,AID.ISLOCALNAME));
         
        } else {
          //Send a CLONE_CODE_LOCATOR_ENTRY command to the container with the agent code.
          AgentMobilitySlice codeSlice = (AgentMobilitySlice) getSlice(codeContainerName);
          try {
            codeSlice.cloneCodeLocatorEntry(agentID, new AID(newName,AID.ISLOCALNAME));
          } catch (IMTPException imtpe) {
            // Try to get a newer slice and repeat...
            codeSlice = (AgentMobilitySlice) getSlice(codeContainerName);
            codeSlice.cloneCodeLocatorEntry(agentID, new AID(newName,AID.ISLOCALNAME));
          }
        }
        //#J2ME_EXCLUDE_END 
       
        //log("Cloning agent " + agentID + " on container " + where.getName(), 1);
        if(myLogger.isLoggable(Logger.CONFIG))
          myLogger.log(Logger.CONFIG,"Cloning agent " + agentID + " on container " + where.getName());
       
        Agent a = myContainer.acquireLocalAgent(agentID);
        if (a == null) {
          //System.out.println("Internal error: handleClone() called with a wrong name (" + agentID + ") !!!");
          if(myLogger.isLoggable(Logger.SEVERE))
            myLogger.log(Logger.SEVERE,"Internal error: handleClone() called with a wrong name (" + agentID + ") !!!");
          return;
View Full Code Here


        throw new ControllerException("JADE startup failed.");
      }
    }
    if (myAgent == null) {
      try {
        Agent a = (Agent) Class.forName(agentType).newInstance();
        if (a instanceof GatewayAgent) {
          //#DOTNET_EXCLUDE_BEGIN
          ((GatewayAgent) a).setListener(new GatewayListenerImpl());
          //#DOTNET_EXCLUDE_END
         
          // We are able to detect the GatewayAgent state only if the internal agent is a GatewayAgent instance
          gatewayAgentState = NOT_ACTIVE;
        }
        a.setArguments(agentArguments);
        myAgent = myContainer.acceptNewAgent("Control"+myContainer.getContainerName(), a);
       
        if (gatewayAgentState == NOT_ACTIVE) {
          // Set the ACTIVE state synchronously so that when checkJADE() completes isGatewayActive() certainly returns true
          gatewayAgentState = ACTIVE;
View Full Code Here

      }
    }
    //#J2ME_EXCLUDE_END
   
    // Connect the new instance to the local container
    Agent old = myContainer.addLocalAgent(target, instance);
    if (instance == old) {
      // This is a re-addition of an existing agent to a recovered main container (FaultRecoveryService)
      old = null;
    }
   
View Full Code Here

    }
   
    private void handleInformCreated(VerticalCommand cmd) throws IMTPException, NotFoundException, NameClashException, JADESecurityException, ServiceException {
      Object[] params = cmd.getParams();
      AID target = (AID)params[0];
      Agent instance = (Agent)params[1];
     
      if(myLogger.isLoggable(Logger.CONFIG)) {
        myLogger.log(Logger.CONFIG,"Source Sink consuming command INFORM_CREATED. Name is "+target.getName());
      }
     
View Full Code Here

      }
      exitContainer();
    }
   
    private void createAgent(AID agentID, String className, Object arguments[], JADEPrincipal owner, Credentials initialCredentials, boolean startIt) throws IMTPException, NotFoundException, NameClashException, JADESecurityException {
      Agent agent = null;
      try {
        //#J2ME_EXCLUDE_BEGIN
        // Try to load the agent using an agent loader
        agent = (Agent) ObjectManager.load(className, ObjectManager.AGENT_TYPE);
        //#J2ME_EXCLUDE_END
       
        if (agent == null) {
          agent = (Agent)Class.forName(className).newInstance();
        }
       
        agent.setArguments(arguments);
       
        myContainer.initAgent(agentID, agent, owner, initialCredentials);   
       
        if (startIt) {
          myContainer.powerUpLocalAgent(agentID);
View Full Code Here

    }
   
   
    private void killAgent(AID agentID) throws IMTPException, NotFoundException {
     
      Agent a = myContainer.acquireLocalAgent(agentID);
     
      if(a == null)
        throw new NotFoundException("Kill-Agent failed to find " + agentID);
      a.doDelete();
     
      myContainer.releaseLocalAgent(agentID);
    }
View Full Code Here

     
      myContainer.releaseLocalAgent(agentID);
    }
   
    private void changeAgentState(AID agentID, int newState) throws IMTPException, NotFoundException {
      Agent a = myContainer.acquireLocalAgent(agentID);
     
      if(a == null)
        throw new NotFoundException("Change-Agent-State failed to find " + agentID);
     
      if(newState == Agent.AP_SUSPENDED) {
        a.doSuspend();
      }
      else if(newState == Agent.AP_WAITING) {
        a.doWait();
      }
      else if(newState == Agent.AP_ACTIVE) {
        int oldState = a.getState();
        if(oldState == Agent.AP_SUSPENDED) {
          a.doActivate();
        }
        else {
          a.doWake();
        }
      }
     
      myContainer.releaseLocalAgent(agentID);
    }
View Full Code Here

    private void handleInformCreated(VerticalCommand cmd) throws IMTPException, NotFoundException, NameClashException, JADESecurityException, ServiceException {
      Object[] params = cmd.getParams();
      AID agentID = (AID)params[0];

      boolean startedOnBE = false;
      Agent previous = null;
      // If an actual agent instance was passed as second argument, then this agent
      // is started within the Back-End container
      if((params.length > 1) && (params[1] instanceof Agent))  {
        Agent instance = (Agent)params[1];
        // If the instance is an AgentImage, this is a re-addition of an agent
        // living in the FE --> just do nothing
        if (!(instance instanceof BackEndContainer.AgentImage)) {
          // Add the new agent in the LADT
          previous = myContainer.addLocalAgent(agentID, instance);
View Full Code Here

TOP

Related Classes of jade.core.Agent$Interrupted

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.