Package jade.util.leap

Examples of jade.util.leap.Iterator


      List targets = (List)params[1];
     
      MainContainer impl = myContainer.getMain();
      if(impl != null) {
        // Activate debugging each element of the list
        Iterator it = targets.iterator();
        while(it.hasNext()) {
          AID target = (AID)it.next();
          ContainerID cid = impl.getContainerID(target);
         
          NotificationSlice slice = (NotificationSlice)getSlice(cid.getName());
          try {
            slice.debugOn(introspector, target);
View Full Code Here


      List targets = (List)params[1];
     
      MainContainer impl = myContainer.getMain();
      if(impl != null) {
        // Deactivate debugging each element of the list
        Iterator it = targets.iterator();
        while(it.hasNext()) {
          AID target = (AID)it.next();
          ContainerID cid = impl.getContainerID(target);
         
          NotificationSlice slice = (NotificationSlice)getSlice(cid.getName());
          try {
            slice.debugOff(introspector, target);
View Full Code Here

      myContainer.releaseLocalAgent(targetName);
     
      // Notify all the needed events 
      fireChangedAgentState(targetName, as, as);
     
      Iterator itReady = readyBehaviours.iterator();
      while(itReady.hasNext()) {
        BehaviourID bid = (BehaviourID)itReady.next();
        AgentEvent ev = new AgentEvent(AgentEvent.ADDED_BEHAVIOUR, targetName, bid, myContainer.getID());
        tn.addedBehaviour(ev);
      }
     
      Iterator itBlocked = blockedBehaviours.iterator();
      while(itBlocked.hasNext()) {
        BehaviourID bid = (BehaviourID)itBlocked.next();
        AgentEvent ev = new AgentEvent(AgentEvent.ADDED_BEHAVIOUR, targetName, bid, myContainer.getID());
        tn.addedBehaviour(ev);
        ev = new AgentEvent(AgentEvent.CHANGED_BEHAVIOUR_STATE, targetName, bid, Behaviour.STATE_READY, Behaviour.STATE_BLOCKED, myContainer.getID());
        tn.changedBehaviourState(ev);
      }
     
      Iterator itMessages = messages.iterator();
      while(itMessages.hasNext()) {
        ACLMessage msg = (ACLMessage)itMessages.next();
        MessageEvent ev = new MessageEvent(MessageEvent.POSTED_MESSAGE, msg, null, targetName, myContainer.getID());
        tn.postedMessage(ev);
      }
    }
View Full Code Here

    if (!propagated) {
      // Inform the new replica about existing nodes and their installed services...
      List infos = getAllNodesInfo();

      Iterator it = infos.iterator();
      while (it.hasNext()) {
        NodeInfo info = (NodeInfo) it.next();
        try {
          newReplica.addNode(info.getNodeDescriptor(), info.getServices(), true);
        } catch (JADESecurityException ae) {
          // Should never happen since this is a propagated info
          ae.printStackTrace();
View Full Code Here

    try {
      TransportAddressWrapper key = TransportAddressWrapper.getWrapper(address, myIMTPManager);
      if (replicas.remove(key) == null) {
        // The replica to remove is not among the known replicas --> Print a warning since this should never happen
        StringBuffer sb = new StringBuffer("Replica "+key.hashCode()+", "+key.getAddress()+"not found! Known replicas are: {");
        Iterator it = replicas.keySet().iterator();
        while (it.hasNext()) {
          TransportAddressWrapper taw = (TransportAddressWrapper) it.next();
          sb.append(""+taw.hashCode()+", "+taw.getAddress());
          if (it.hasNext()) {
            sb.append("; ");
          }
        }
        sb.append("}");
        myLogger.log(Logger.WARNING, sb.toString());
View Full Code Here

        v.addElement(new ServiceDescriptor(svc.getName(), svc));
      }
    }

    // Now fill the services in the list of NodeInfo
    Iterator it = infos.iterator();
    while (it.hasNext()) {
      NodeInfo ni = (NodeInfo) it.next();
      Vector v = (Vector) nodeServices.get(ni.getNodeDescriptor().getName());
      ni.setServices(v);
    }
    return infos;
  }
View Full Code Here

        return e.getSlice();
      }
    }

    public Vector getSlices() {
      Iterator sliceEntries = slices.values().iterator();
      Vector result = new Vector();

      while (sliceEntries.hasNext()) {
        SliceEntry e = (SliceEntry) sliceEntries.next();
        result.addElement(e.getSlice());
      }

      return result;
    }
View Full Code Here

  void restartReplicatedAgents(AgentContainer localContainer) throws IMTPException, NotFoundException, JADESecurityException {
    ContainerID cid = localContainer.getID();
    NodeDescriptor dsc = getDescriptor(cid.getName());
    // The owner of the replicated agents is the owner of the main container.
    JADEPrincipal cp = dsc.getOwnerPrincipal()
    Iterator it = replicatedAgents.keySet().iterator();
    while (it.hasNext()) {
      AID aid = (AID) it.next();
      try {
        String className = (String) replicatedAgents.get(aid);
        if (className != null) {
          myLogger.log(Logger.INFO, "Restarting replicated agent "+aid.getName());
          Agent agent = (Agent)Class.forName(className).newInstance();
View Full Code Here

      if((factName == null) || (!templateName.equalsIgnoreCase(factName)))
        return false;
    }
   
    // Match the address sequence. See 'FIPA Agent Management Specification, Sect. 6.4.2.1'
    Iterator itTemplate = template.getAllAddresses();
    Iterator itFact = fact.getAllAddresses();
   
    // All the elements in the template sequence must appear in the
    // fact sequence, in the same order
    while(itTemplate.hasNext()) {
      String templateAddr = (String)itTemplate.next();
     
      // Search 'templateAddr' into the remaining part of the fact sequence
      boolean found = false;
      while(!found && itFact.hasNext()) {
        String factAddr = (String)itFact.next();
        found = templateAddr.equalsIgnoreCase(factAddr);
      }
      if(!found) // An element of the template does not appear in the fact sequence
        return false;
    }
   
    // Match the resolvers sequence. See 'FIPA Agent Management Specification, Sect. 6.4.2.1'
    itTemplate = template.getAllResolvers();
    itFact = fact.getAllResolvers();
   
    while(itTemplate.hasNext()) {
      AID templateRes = (AID)itTemplate.next();
     
      // Search 'templateRes' into the remaining part of the fact sequence
      boolean found = false;
      while(!found && itFact.hasNext()) {
        AID factRes = (AID)itFact.next();
        found = matchAID(templateRes, factRes); // Recursive call
      }
      if(!found) // An element of the template does not appear in the fact sequence
        return false;
    }
View Full Code Here

        Date deadline = incomingRequest.getReplyByDate();
        if (deadline == null) {
          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

TOP

Related Classes of jade.util.leap.Iterator

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.