Package jade.util.leap

Examples of jade.util.leap.ArrayList


  /**
   Return a list of all MTPs in the platform
   */
  private List platformMTPs() {
    List mtps = new ArrayList();
    ContainerID[] cc = myPlatform.containerIDs();
    for (int i = 0; i < cc.length; ++i) {
      try {
        List l = myPlatform.containerMTPs(cc[i]);
        Iterator it = l.iterator();
        while (it.hasNext()) {
          mtps.add(it.next());
        }
      } catch (NotFoundException nfe) {
        // The container has died while we were looping --> ignore it
      }
    }
View Full Code Here


  /**
   Add the node to the platform with the basic services
   */
  protected void startNode() throws IMTPException, ProfileException, ServiceException, JADESecurityException, NotFoundException {
    // Initialize all services (without activating them)
    List services = new ArrayList();
   
    initMandatoryServices(services);

    List l = myProfile.getSpecifiers(Profile.SERVICES);
    myProfile.setSpecifiers(Profile.SERVICES, l); // Avoid parsing services twice
    initAdditionalServices(l.iterator(), services);

    // Register with the platform (pass only global services to the Main)
    ServiceDescriptor[] descriptors = new ServiceDescriptor[services.size()];
    for (int i = 0; i < descriptors.length; ++i) {
      descriptors[i] = (ServiceDescriptor) services.get(i);
    }
    // This call performs the real connection to the platform and can modify the
    // name of this container
    myServiceManager.addNode(myNodeDescriptor, descriptors);
    creationTime = System.currentTimeMillis();
View Full Code Here

  }
 
 
  protected void startNode() throws IMTPException, ProfileException, ServiceException, JADESecurityException, NotFoundException {
    // Initialize all services (without activating them)
    List services = new ArrayList();
    initMandatoryServices(services);
   
    List l = myProfile.getSpecifiers(Profile.SERVICES);
    myProfile.setSpecifiers(Profile.SERVICES, l); // Avoid parsing services twice
    initAdditionalServices(l.iterator(), services);
     
    // Register with the platform
    ServiceDescriptor[] descriptors = new ServiceDescriptor[services.size()];
    for (int i = 0; i < descriptors.length; ++i) {
      descriptors[i] = (ServiceDescriptor) services.get(i);
    }
    if (theBEManager != null) {
      myNodeDescriptor.setParentNode(theBEManager.getNode());
    }
    // Actually join the platform (this call can modify the name of this container)
View Full Code Here

 
 
  private String[] parseAddressList(String toParse) {
   
    StringTokenizer lexer = new StringTokenizer(toParse, ADDR_LIST_DELIMITERS);
    List addresses = new ArrayList();
    while(lexer.hasMoreTokens()) {
      String tok = lexer.nextToken();
      addresses.add(tok);
    }
   
    Object[] objs = addresses.toArray();
    String[] result = new String[objs.length];
    for(int i = 0; i < result.length; i++) {
      result[i] = (String)objs[i];
    }
   
View Full Code Here

    if(lastMsg.getPerformative() != ACLMessage.INFORM)
      throw new FIPAException(lastMsg);

    Result r = AppletRequestProto.extractContent(lastMsg.getContent(),(SLCodec)c,o);
    Iterator i = r.getItems().iterator(); //this is the set of DFAgentDescription
    List l = new ArrayList();
    while (i.hasNext())
     l.add(i.next());
    return l;

  }
View Full Code Here

   * @param loader The <code>Loader</code> instance.
   */
  public synchronized static void addLoader(String type, Loader loader) {
    List l = (List) loaders.get(type);
    if (l == null) {
      l = new ArrayList();
      loaders.put(type, l);
    }
    l.add(loader);
  }
View Full Code Here

  try{
   
    FIPAAppletRequestProto arp = new FIPAAppletRequestProto(this,df,FIPAManagementVocabulary.SEARCH,dfd,sc);
    arp.doProto();
    Iterator result = arp.getSearchResult().iterator();
    ArrayList listOfAID = new ArrayList();
    ArrayList listOfChildren = new ArrayList();
    while(result.hasNext())
      {
        DFAgentDescription next = (DFAgentDescription)result.next();
        listOfAID.add(next.getName());
        if(isADF(next))
          listOfChildren.add(next.getName());
      }
 
    //second request the df the parent
    JADEAppletRequestProto getParent = new JADEAppletRequestProto(this,getDescriptionOfThisDF().getName(), DFAppletVocabulary.GETPARENTS,null,null);
    getParent.doProto();
    Iterator parents = getParent.getResult().iterator();
 
    gui.refresh(listOfAID.iterator(), parents, listOfChildren.iterator());
  }catch(FIPAAppletRequestProto.NotYetReady nyr){
    nyr.printStackTrace();
  }catch(JADEAppletRequestProto.NotYetReady ex){
   ex.printStackTrace()
  }
View Full Code Here

      throw new NotYetReady();
    if(lastMsg.getPerformative() != ACLMessage.INFORM)
      throw new FIPAException(lastMsg);
    Result r = AppletRequestProto.extractContent(lastMsg.getContent(),(SLCodec)c,o);
        Iterator i = r.getItems().iterator(); //this is the set of DFAgentDescription
        List l = new ArrayList();
        while (i.hasNext())
          l.add(i.next());
        return l;
  }
View Full Code Here

    }   
  }

  private ArrayList deserializeArrayList() throws LEAPSerializationException {
    try {
      ArrayList l = new ArrayList();
      int size = readInt();
      for (int i = 0; i < size; ++i) {
        l.add(readObject());
      }
      return l;
    }
    catch (IOException ioe) {
      throw new LEAPSerializationException("Error deserializing ArrayList");
View Full Code Here

      profileProp.setProperty(Profile.MAIN, "true");
    }
    else {
      profileProp.setProperty(Profile.MAIN, "false");
      // Since the value is false, we cancel the default done in ProfileImpl's constructor
      setSpecifiers(Profile.MTPS, new ArrayList(0)); // remove default MTP
    }

    String sm = argProp.getProperty(LOCAL_SERVICE_MANAGER);
    if(sm != null) {
      profileProp.setProperty(Profile.LOCAL_SERVICE_MANAGER, sm);
    }

    /* PER IL DF
        value = argProp.getProperty(df.KBDF_MAX_RESULTS);
        if (value != null) {
            profileProp.setProperty(df.KBDF_MAX_RESULTS, value);
        }
        value = argProp.getProperty(df.DBDF_DRIVER);
        if (value != null) {
            profileProp.setProperty(df.DBDF_DRIVER, value);
        }
        value = argProp.getProperty(df.DBDF_URL);
        if (value != null) {
            profileProp.setProperty(df.DBDF_URL, value);
        }*/

    /*
        value = argProp.getProperty(PASSWD_KEY);
        if (value != null) {
            //profileProp.setProperty(Profile.PASSWD_FILE, value);
        }
     */

    value = argProp.getProperty(IMTP);
    if (value != null) {
      profileProp.setProperty(Profile.IMTP, value);
    }

    String host = argProp.getProperty(MAIN_HOST);
    if (host != null) {
      profileProp.setProperty(Profile.MAIN_HOST, host);
    } else {
      host = profileProp.getProperty(Profile.MAIN_HOST);
      if (host == null) {
        host = getDefaultNetworkName();
        profileProp.setProperty(Profile.MAIN_HOST, host);
      }
    }

    String port = argProp.getProperty(MAIN_PORT);
    if (port == null) {
      // Default for a sole main container: use the local port, or
      // the default port if also the local port is null.
      if(isMasterMain()) {
        port = argProp.getProperty(LOCAL_PORT);
      }
      if(port == null) {
        // All other cases: use the default port.
        port = Integer.toString(DEFAULT_PORT);
      }
    }
    profileProp.setProperty(Profile.MAIN_PORT, port);

    String localHost = argProp.getProperty(LOCAL_HOST);
    if(localHost == null) {
      // Default for a sole main container: use the MAIN_HOST property
      if(isMasterMain()) {
        localHost = host;
      }
      else {
        // Default for a peripheral container or an added main container: use the local host
        localHost = getDefaultNetworkName();
      }
    }
    profileProp.setProperty(Profile.LOCAL_HOST, localHost);

    String localPort = argProp.getProperty(LOCAL_PORT);
    if(localPort == null) {
      // Default for a sole main container: use the MAIN_PORT property
      if(isMasterMain()) {
        localPort = port;
      }
      else {
        // Default for a peripheral container or an added main container: use the default port
        localPort = Integer.toString(DEFAULT_PORT);
      }
    }
    profileProp.setProperty(Profile.LOCAL_PORT, localPort);

    value = argProp.getProperty(REMOTE_SERVICE_MANAGER_ADDRESSES);
    if (value != null) {
      try {
        Vector v = Specifier.parseSpecifierList(value);
        // Convert the Vector into a List
        List l = new ArrayList(v.size());
        Enumeration e = v.elements();
        while (e.hasMoreElements()) {
          l.add(e.nextElement());
        }
        setSpecifiers(Profile.REMOTE_SERVICE_MANAGER_ADDRESSES, l);
      }
      catch(Exception e) {
        e.printStackTrace();
      }
    }

    value = argProp.getProperty(NAME_KEY);
    if (value != null) {
      profileProp.setProperty(Profile.PLATFORM_ID, value);
   

    value = argProp.getProperty(LOGIN_KEY);
    if (value != null) {
      profileProp.setProperty(Profile.USERAUTH_KEY, value);
   

    value = argProp.getProperty(MTP_KEY);
    if (value != null) {
      setSpecifiers(Profile.MTPS, parseSpecifiers(value));
    }

    //NOMTP
    flag = fetchAndVerifyBoolean(NOMTP_KEY);
    if (flag) {
      // Since the value was set to true, cancel the MTP settings
      setSpecifiers(Profile.MTPS, new ArrayList(0));
    }

    value = argProp.getProperty(ACLCODEC_KEY);
    if (value != null) {
      setSpecifiers(Profile.ACLCODECS, parseSpecifiers(value));
    }

    // Get agent list (if any)
    value = argProp.getProperty(AGENTS);


    flag = fetchAndVerifyBoolean(GUI_KEY);
    if (flag) {
      // need to run RMA agent
      if (value != null) {
        value = "RMA:jade.tools.rma.rma " + value;  // put before other agents
      } else {
        value = "RMA:jade.tools.rma.rma"// only one
      }
    }

    if (value != null) {
      Vector agentVector = helper.T2(value, false);
      List agents = new ArrayList();

      for (Enumeration e = helper.getCommandLineAgentSpecifiers(agentVector);
      e.hasMoreElements(); ) {
        agents.add((Specifier) e.nextElement());
      }

      setSpecifiers(Profile.AGENTS, agents);
    }

    // Get service list (if any)
    value = argProp.getProperty(SERVICES);
    if(value == null) {
      // Remove mobility service from the list if '-nomobility' was specified
      flag = fetchAndVerifyBoolean(NOMOBILITY_KEY);
      if (flag) {
        value = DEFAULT_SERVICES_NOMOBILITY;
      }
      else {
        value = DEFAULT_SERVICES;
      }
    }

    setSpecifiers(Profile.SERVICES, parseSpecifiers(value));


    // finally, copy into profileProp all the properties that
    // were present in argProp AND were not already present in profileProp.
    // The fact that we do not copy those properties that were already
    // present in profileProp is a sanity check to avoid modification
    // of properties that were set in the code above
    for (Enumeration e=argProp.keys(); e.hasMoreElements(); ) {
      String key = (String)e.nextElement();
      if (getParameter(key,null) == null)
        setParameter(key, argProp.get(key).toString());
    }

    // The following is for debugging only. Probably should not document the "dumpProfile" attribute.
    // Note All the jade.util.leap.ArrayList structures will only print their type unless a
    // toString() method were added to them.
    if (argProp.getBooleanProperty("dumpProfile", false)) {
      ArrayList aList = new ArrayList();
      System.out.println("---------- Jade Boot profile property values ----------");
      for (Enumeration e = profileProp.sortedKeys(); e.hasMoreElements(); ) {
        String key = (String) e.nextElement();
        Object o = profileProp.get(key);
        if (o.getClass().isAssignableFrom(aList.getClass())) {
          System.out.print(key + "=");
          ArrayList al = (ArrayList)o;
          Iterator itor = al.iterator();
          if (!itor.hasNext()) {
            System.out.println("<empty>");
          } else {
            StringBuffer sb = new StringBuffer();
            while (itor.hasNext()) {
View Full Code Here

TOP

Related Classes of jade.util.leap.ArrayList

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.