Package jade.util.leap

Examples of jade.util.leap.Properties


    catch (IOException ioe) {
    }
  }
 
  private static Properties parseArguments(String[] args) {
    Properties props = new Properties();
    int i = 0;
    while (i < args.length) {
      if (args[i].startsWith("-")) {
        // Parse next option
        String name = args[i].substring(1);
        if (++i < args.length) {
          props.setProperty(name, args[i]);
        }
        else {
          throw new IllegalArgumentException("No value specified for property \""+name+"\"");
        }
        ++i;
View Full Code Here


    if (measure == RTT_MEASURE) {
      senderClass = "jade.core.ScalabilityTest$RTTSenderAgent";
      receiverClass = "jade.core.ScalabilityTest$RTTReceiverAgent";
    }
   
    Properties pp = new Properties();
    if (host != null) {
      pp.setProperty(MicroRuntime.HOST_KEY, host);
    }
    if (port != null) {
      pp.setProperty(MicroRuntime.PORT_KEY, port);
    }
    if (connectionManager != null) {
      pp.setProperty(MicroRuntime.CONN_MGR_CLASS_KEY, connectionManager);
    }
    if (mediatorClass != null) {
      pp.setProperty(JICPProtocol.MEDIATOR_CLASS_KEY, mediatorClass);
    }
    if (maxDiscTime != null) {
      pp.setProperty(JICPProtocol.MAX_DISCONNECTION_TIME_KEY, maxDiscTime);
    }
    String sName = "S-"+prefix+"-"+index;
    pp.setProperty(PDPContextManager.MSISDN, sName);
    String rName = "R-"+prefix+"-"+index;
    String prop = sName+":"+senderClass+"("+rName+")";
    pp.setProperty(MicroRuntime.AGENTS_KEY, prop);
    pp.setProperty(JICPProtocol.KEEP_ALIVE_TIME_KEY, "-1");
    FrontEndContainer fes = new FrontEndContainer();
    fes.start(pp);
   
    pp = new Properties();
    if (host != null) {
      pp.setProperty(MicroRuntime.HOST_KEY, host);
    }
    if (port != null) {
      pp.setProperty(MicroRuntime.PORT_KEY, port);
    }
    if (connectionManager != null) {
      pp.setProperty(MicroRuntime.CONN_MGR_CLASS_KEY, connectionManager);
    }
    if (mediatorClass != null) {
      pp.setProperty(JICPProtocol.MEDIATOR_CLASS_KEY, mediatorClass);
    }
    if (maxDiscTime != null) {
      pp.setProperty(JICPProtocol.MAX_DISCONNECTION_TIME_KEY, maxDiscTime);
    }
    pp.setProperty(PDPContextManager.MSISDN, rName);
    prop = rName+":"+receiverClass;
    pp.setProperty(MicroRuntime.AGENTS_KEY, prop);
    pp.setProperty(JICPProtocol.KEEP_ALIVE_TIME_KEY, "-1");
    FrontEndContainer fer = new FrontEndContainer();
    fer.start(pp);
  }
View Full Code Here

  /**
   * Convert a class-name, possibly with attached properties, into a Properties object
   * The actual class-name will be available as the value of the <code>CLASS_NAME</code> property
   */
  private static Properties getClassProperties(String str) {
    Properties pp = new Properties();
    int index = str.indexOf('[');
    if (index < 0) {
      pp.setProperty(CLASS_NAME, str);
    }
    else {
      pp.setProperty(CLASS_NAME, str.substring(0, index));
      int index1 = str.indexOf(']');
      String propsStr = str.substring(index+1, index1);
      Vector propsList = Specifier.parseList(propsStr, ';');
      for (int i = 0; i < propsList.size(); ++i) {
        String ps = (String) propsList.get(i);
        int k = ps.indexOf('=');
        if (k > 0) {
          String name = ps.substring(0, k);
          String value = ps.substring(k+1);
          pp.setProperty(name, value);
        }
      }
    }
    return pp;
  }
View Full Code Here

      throw new IllegalArgumentException("Null class name");
    }
    List l = (List) loaders.get(type);
    if (l != null && !l.isEmpty()) {
      // If we have loaders for this type of object, try to use them
      Properties pp = getClassProperties(extendedClassName);
      String className = pp.getProperty(ObjectManager.CLASS_NAME);
      Iterator it = l.iterator();
      while (it.hasNext()) {
        Loader loader = (Loader) it.next();
        Object obj = loader.load(className, pp);
        if (obj != null) {
View Full Code Here

    }   
  }

  private Properties deserializeProperties() throws LEAPSerializationException {
    try {
      Properties p = new Properties();
      int size = readInt();
      for (int i = 0; i < size; i++) {
        p.setProperty((String) readObject(), (String) readObject());
      }
      return p;
    }
    catch (IOException ioe) {
      throw new LEAPSerializationException("Error deserializing Properties");
View Full Code Here

        str.append(PROTOCOL + " " + tmp + "\n");
      }

      appendACLExpression(str, CONVERSATION_ID, msg.getConversationId());

      Properties userDefProps = msg.getAllUserDefinedParameters();
      if (userDefProps != null) {
          Enumeration e = userDefProps.propertyNames();
          while (e.hasMoreElements()) {
              String key = ((String)e.nextElement());
              if (key.indexOf(' ') == -1) {
                  if ( (!key.startsWith("X-")) && (!key.startsWith("x-")) )
                      appendACLExpression(str, ":X-"+key, userDefProps.getProperty(key));
                  else
                      appendACLExpression(str, ":"+key, userDefProps.getProperty(key));
              } else
                  System.err.println("WARNING: The slotName of user-defined parameters cannot contain blanks inside. Therefore "+key+" is not being encoded");
          }
      }
      str.append(")");
View Full Code Here

      // Create the Profile
      ProfileImpl p = null;
      if (args.length > 0) {
        if (args[0].startsWith("-")) {
          // Settings specified as command line arguments
          Properties pp = parseCmdLineArgs(args);
          if (pp != null) {
            p = new ProfileImpl(pp);
          }
          else {
            // One of the "exit-immediately" options was specified!
View Full Code Here

  public Boot() {
  }


  public static Properties parseCmdLineArgs(String[] args) throws IllegalArgumentException {
    Properties props = new ExtendedProperties();

    int i = 0;
    while (i < args.length) {
      if (args[i].startsWith("-")) {
        // Parse next option

        // Switch options require special handling
        if (args[i].equalsIgnoreCase("-version")) {
          logger.log(Logger.INFO, "----------------------------------\n"+Runtime.getCopyrightNotice()+"----------------------------------------");
          return null;
        }
        if (args[i].equalsIgnoreCase("-help")) {
          printUsage();
          return null;
        }
        if (args[i].equalsIgnoreCase("-container")) {
          props.setProperty(Profile.MAIN, "false");
        }
        else if(args[i].equalsIgnoreCase("-"+Profile.LOCAL_SERVICE_MANAGER)) {
          props.setProperty(Profile.LOCAL_SERVICE_MANAGER, "true");
        }
        else if (args[i].equalsIgnoreCase("-"+Profile.GUI)) {
          props.setProperty(Profile.GUI, "true");
        }
        else if (args[i].equalsIgnoreCase("-"+Profile.NO_MTP)) {
          props.setProperty(Profile.NO_MTP, "true");
        }       
        // Options that can be specified in different ways require special handling
        else if (args[i].equalsIgnoreCase("-name")) {
          if (++i < args.length) {
            props.setProperty(Profile.PLATFORM_ID, args[i]);
          }
          else {
            throw new IllegalArgumentException("No platform name specified after \"-name\" option");
          }
        }
        else if (args[i].equalsIgnoreCase("-mtp")) {
          if (++i < args.length) {
            props.setProperty(Profile.MTPS, args[i]);
          }
          else {
            throw new IllegalArgumentException("No mtps specified after \"-mtp\" option");
          }
        }
        // The -conf option requires special handling
        else if (args[i].equalsIgnoreCase("-conf")) {
          if (++i < args.length) {
            // Some parameters are specified in a properties file
            try {
              props.load(args[i]);
            }
            catch (Exception e) {
              if(logger.isLoggable(Logger.SEVERE))
                logger.log(Logger.SEVERE, "WARNING: error loading properties from file "+args[i]+". "+e);
           
          }
          else {
            throw new IllegalArgumentException("No configuration file name specified after \"-conf\" option");
          }
        }
        // Default handling for all other properties
        else {
          String name = args[i].substring(1);
          if (++i < args.length) {
            props.setProperty(name, args[i]);
          }
          else {
            throw new IllegalArgumentException("No value specified for property \""+name+"\"");
          }
        }
        ++i;
      }
      else {
        // Get agents at the end of command line
        if (props.getProperty(Profile.AGENTS) != null) {
          if(logger.isLoggable(Logger.WARNING))
            logger.log(Logger.WARNING,"WARNING: overriding agents specification set with the \"-agents\" option");
        }
        String agents = args[i];
        props.setProperty(Profile.AGENTS, args[i]);
        if (++i < args.length) {
          if(logger.isLoggable(Logger.WARNING))
            logger.log(Logger.WARNING,"WARNING: ignoring command line argument "+args[i]+" occurring after agents specification");
          if (agents != null && agents.indexOf('(') != -1 && !agents.endsWith(")")) {
            if(logger.isLoggable(Logger.WARNING))
              logger.log(Logger.WARNING,"Note that agent arguments specifications must not contain spaces");
          }
          if (args[i].indexOf(':') != -1) {
            if(logger.isLoggable(Logger.WARNING))
              logger.log(Logger.WARNING,"Note that agent specifications must be separated by a semicolon character \";\" without spaces");
          }
        }
        break;
      }
    }

    // Consistency check
    if ("true".equals(props.getProperty(Profile.NO_MTP)) && props.getProperty(Profile.MTPS) != null) {
      if(logger.isLoggable(Logger.WARNING))
        logger.log(Logger.WARNING,"WARNING: both \"-mtps\" and \"-nomtp\" options specified. The latter will be ignored");
      props.remove(Profile.NO_MTP);
    }

    return props;
  }
View Full Code Here

      System.exit(-1);
    }
  }

  private static Properties parseCmdLineArgs(String[] args) throws IllegalArgumentException {
    Properties props = new Properties();

    int i = 0;
    while (i < args.length) {
      if (args[i].startsWith("-")) {
        // Parse next option
        String name = args[i].substring(1);
        if (++i < args.length) {
          props.setProperty(name, args[i]);
        }
        else {
          throw new IllegalArgumentException("No value specified for property \""+name+"\"");
        }
        ++i;
      }
      else {
        // Get agents at the end of command line
        if (props.getProperty(MicroRuntime.AGENTS_KEY) != null) {
          if(logger.isLoggable(Logger.WARNING))
            logger.log(Logger.WARNING,"WARNING: overriding agents specification set with the \"-agents\" option");
        }
        String agents = args[i];
        props.setProperty(MicroRuntime.AGENTS_KEY, args[i]);
        if (++i < args.length) {
          if(logger.isLoggable(Logger.WARNING))
            logger.log(Logger.WARNING,"WARNING: ignoring command line argument "+args[i]+" occurring after agents specification");
          if (agents != null && agents.indexOf('(') != -1 && !agents.endsWith(")")) {
            if(logger.isLoggable(Logger.WARNING))
View Full Code Here

   * Fires up the <b><em>JADE</em></b> runtime.
   */
  public static void main(String args[]) {
    String propsFile = null;
    try {
      Properties props = parseCmdLineArgs(args);
      propsFile = props.getProperty("conf");
      if (propsFile != null) {
        props.load(propsFile);
      }
      Logger.initialize(props);
      if (props.getProperty(MicroRuntime.JVM_KEY) == null) {
        //#PJAVA_EXCLUDE_BEGIN
        props.setProperty(MicroRuntime.JVM_KEY, MicroRuntime.J2SE);
        //#PJAVA_EXCLUDE_END
        /*#PJAVA_INCLUDE_BEGIN
        props.setProperty(MicroRuntime.JVM_KEY, MicroRuntime.PJAVA);
        #PJAVA_INCLUDE_END*/
      }
 
View Full Code Here

TOP

Related Classes of jade.util.leap.Properties

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.