Package jade.util.leap

Examples of jade.util.leap.List


     Call the proper method of the ams and prepare the notification
     message
   */
  protected ACLMessage performAction(Action slAction, ACLMessage request) throws JADESecurityException, FIPAException {
    Concept action = slAction.getAction();
    List resultItems = null;
   
    // REGISTER
    if (action instanceof Register) {
      theAMS.registerAction((Register) action, request.getSender());
    }
    // DEREGISTER
    else if (action instanceof Deregister) {
      theAMS.deregisterAction((Deregister) action, request.getSender());
    }
    // MODIFY
    else if (action instanceof Modify) {
      theAMS.modifyAction((Modify) action, request.getSender());
    }
    // SEARCH
    else if (action instanceof Search) {
      resultItems = theAMS.searchAction((Search) action, request.getSender());
    }
    // GET_DESCRIPTION
    else if (action instanceof GetDescription) {
      APDescription dsc = theAMS.getDescriptionAction(request.getSender());
      resultItems = new ArrayList();
      resultItems.add(dsc);
    }
    else {
      throw new UnsupportedFunction();
    }
   
View Full Code Here


    // Search for DFDs that already match the specified template.
    // Note that we ignore the SearchConstraint.maxResult here
    // FIXME: Getting all DFDs matching a template may cause out-of-memory.
    // We should use an iterated search and send back possibly more than one
    // notification.
    List results = kBase.search(dfdTemplate, -1);
   
    // If some DFD matches the template, notify the subscribed agent
    if(results.size() > 0){
      notify(sub, results, absIota);
      return true;
    }
    return false;
  }
View Full Code Here

    for (int i = 0; i < subscriptions.length; ++i) {
      SubscriptionInfo info = subscriptions[i];
      DFAgentDescription template = info.getTemplate();
      if ( DFMemKB.compare(template, dfd) || ((oldDfd!=null) && DFMemKB.compare(template, oldDfd))) {
        // This subscriber must be notified
        List results = new ArrayList();
        results.add(dfd);
        if (myLogger.isLoggable(Logger.FINE)) {
          ACLMessage subMessage = info.getSubscription().getMessage();
          myLogger.log(Logger.FINE, "Notifying subscribed agent "+subMessage.getSender().getName()+" ["+subMessage.getConversationId()+"] ");
        }
        notify(info.getSubscription(), results, info.getAbsIota());
View Full Code Here

    platformID = p.getParameter(Profile.PLATFORM_ID, null);
    if (platformID == null || platformID.equals("")) {
      try {
        // Build the PlatformID using the local host and port
        List l = myIMTPManager.getLocalAddresses();
        TransportAddress localAddr = (TransportAddress) l.get(0);
        platformID = localAddr.getHost() + ":" + localAddr.getPort() + "/JADE";
      } catch (Exception e) {
        throw new ProfileException("Can't set PlatformID", e);
      }
    }
View Full Code Here

      myLogger.log(Logger.INFO, "Adding replica <" + newReplica.getLocalAddress() + "> to the platform");
    }

    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) {
View Full Code Here

  }

  private List getAllNodesInfo() {
    // Get all node descriptors and build the list of NodeInfo
    Object[] allNodes = nodes.values().toArray();
    List infos = new ArrayList(allNodes.length);
    for (int i = 0; i < allNodes.length; ++i) {
      NodeDescriptor nodeDsc = (NodeDescriptor) allNodes[i];
      infos.add(new NodeInfo(nodeDsc));
    }

    // Build the map of services for each node
    Map nodeServices = new HashMap();
    // Avoid concurrent modification exception
    Object[] allServices = services.values().toArray();
    for (int j = 0; j < allServices.length; ++j) {
      ServiceEntry e = (ServiceEntry) allServices[j];
      Node[] serviceNodes = e.getNodes();

      for (int i = 0; i < serviceNodes.length; i++) {
        String nodeName = serviceNodes[i].getName();

        Vector v = (Vector) nodeServices.get(nodeName);
        if (v == null) {
          v = new Vector();
          nodeServices.put(nodeName, v);
        }
        Service svc = e.getService();
        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);
    }
View Full Code Here

    }
    return infos;
  }

  private Node[] getChildren(String name) {
    List children = new ArrayList();
    Object[] allNodes = nodes.values().toArray();
    for (int i = 0; i < allNodes.length; i++) {
      NodeDescriptor dsc = (NodeDescriptor) allNodes[i];
      Node parent = dsc.getParentNode();
      if (parent != null && name.equals(parent.getName())) {
        children.add(dsc.getNode());
      }
    }
    Node[] childrenArray = new Node[children.size()];
    for (int i = 0; i < childrenArray.length; ++i) {
      childrenArray[i] = (Node) children.get(i);
    }
    return childrenArray;
  }
View Full Code Here

        myLogger.log(Logger.SEVERE,"Internal error: handleMove() called with a wrong name (" + agentID.getName() + ") !!!");
        return;
      }
     
      int transferState = 0;
      List messages = new ArrayList();
      AgentMobilitySlice dest = null;
      try {
        // If the destination container is the same as this one, there is nothing to do
        if (CaseInsensitiveString.equalsIgnoreCase(where.getName(), myContainer.here().getName())) {
          return;
View Full Code Here

        // DEBUG ON
        DebugOn requestDebugOn = (DebugOn) aa;
        // Start debugging existing agents.
        // Put non existing agents in the preload map. We will start
        // debug them as soon as they start.
        List agentsToDebug = requestDebugOn.getCloneOfDebuggedAgents();                     
        for (int i=0;i<agentsToDebug.size();i++) {
          AID aid = (AID)agentsToDebug.get(i);
          if (allAgents.contains(aid)) {
            addAgent(aid);
          }
          else {
            //not alive -> put it into preload
            int performativeCount = ACLMessage.getAllPerformativeNames().length;
            boolean[] filter = new boolean[performativeCount];
            for (int j=0; j<performativeCount;j++) {
              filter[j] = true;
            }
            preload.put(aid.getName(), filter);                 
          }
        }                                   
      }
      else {
        // DEBUG OFF
        DebugOff requestDebugOff = (DebugOff) aa;
        List agentsToDebug = requestDebugOff.getCloneOfDebuggedAgents();                     
        for (int i=0;i<agentsToDebug.size();i++) {
          AID aid = (AID)agentsToDebug.get(i);
          removeAgent(aid);
        }
      }
     
      // Send back the notification
View Full Code Here

        queue.setMaxSize(msgQueueMaxSize);
        // Copy messages (if any) from the old message queue to the new one
        synchronized (msgQueue) {
          int size = msgQueue.size();
          if (size > 0) {
            List l = new ArrayList(size);
            msgQueue.copyTo(l);
            Iterator it = l.iterator();
            while (it.hasNext()) {
              queue.addLast((ACLMessage) it.next());
            }
          }
          msgQueue = queue;
View Full Code Here

TOP

Related Classes of jade.util.leap.List

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.