Пример #1
0
 @Test
 public void test1() throws Exception {
   Properties pro = new Properties();
   pro.load(new FileInputStream(new File("src/com/wisn/io/config.properties")));
   String name = (String) pro.get("name");
   String password = pro.getProperty("password");
   System.out.println(name + "  " + password);
   Set<Object> key = pro.keySet();
   for (Object object : key) {
     System.out.println(" " + pro.getProperty(object.toString()));
   }
   pro.put("test1", "value");
   pro.setProperty("name", "中文");
   // 有字节流保存
   //		FileOutputStream fos=new  FileOutputStream(new File("src/com/wisn/io/config.properties"));
   //		//pro.save(fos, "helloworld");
   //		pro.setProperty("new", "text");
   //		pro.store(fos, "新存入的值");
   //		fos.close();
   pro.put("wisnname", "wisnkmkRambler");
   // 用字符流保存
   FileWriter fw = new FileWriter(new File("src/com/wisn/io/config.properties"));
   pro.store(fw, "用字节流存入");
   fw.close();
   PrintWriter pw = new PrintWriter("src/com/wisn/io/config.properties");
   pro.list(pw);
   //		pw.flush();
   pw.close();
   System.out.println(pro);
   Set<String> listpro = pro.stringPropertyNames();
   for (String namestr : listpro) {
     System.out.println("name: " + namestr + "   value:" + pro.getProperty(namestr));
   }
 }
Пример #2
0
  public static void main(String[] args) {
    FileInputStream fis = null;
    FileOutputStream fos = null;
    File file = new File("editor.def");
    Properties props = new Properties();
    try {
      fis = new FileInputStream(file);
      props.load(fis);
      fis.close();
    } catch (IOException e) {
      System.out.println(e.getMessage());
      e.printStackTrace();
    }
    /*
    props.setProperty("file0", "ficheiro00000");
                  props.setProperty("file1", "ficheir011111111111");
                  props.setProperty("file2", "ficheir2 2 2 2");
                  */
    props.list(System.out); // imprime o conteudo do objeto no console

    try {
      fos = new FileOutputStream(file);
      props.store(fos, "Configuração do editor");
      fos.close();
    } catch (IOException e) {
      System.out.println(e.getMessage());
      e.printStackTrace();
    }
  }
 public static void myReadPropertiesMethod(String filePath) {
   FileReader fr = null;
   BufferedReader br = null;
   Properties ppt = new Properties();
   try {
     fr = new FileReader(filePath);
     br = new BufferedReader(fr);
     String line = null;
     while ((line = br.readLine()) != null) {
       String[] keyAndValue = line.split("=");
       ppt.setProperty(keyAndValue[0], keyAndValue[1]);
     }
     System.out.println("直接打印:");
     System.out.println(ppt.toString() + "\n");
     System.out.println("list()方法:");
     ppt.list(System.out);
   } catch (IOException e) {
     e.printStackTrace();
   } finally {
     try {
       br.close();
     } catch (IOException e) {
       e.printStackTrace();
     }
     try {
       fr.close();
     } catch (IOException e) {
       e.printStackTrace();
     }
   }
 }
Пример #4
0
 private static void listProperties(String portString) throws Exception {
   int port = Integer.parseInt(portString);
   NetworkServerControl derbyServer =
       new NetworkServerControl(InetAddress.getByName("localhost"), port);
   Properties p = derbyServer.getCurrentProperties();
   p.list(System.out);
 }
Пример #5
0
  public static String list(Properties properties) {
    UnsyncByteArrayOutputStream unsyncByteArrayOutputStream = new UnsyncByteArrayOutputStream();

    PrintStream printStream = new PrintStream(unsyncByteArrayOutputStream);

    properties.list(printStream);

    return unsyncByteArrayOutputStream.toString();
  }
 /** The PasswordPlaceholderConfigurer will read Kylin properties as the Spring resource */
 public PasswordPlaceholderConfigurer() {
   Resource[] resources = new Resource[1];
   Properties prop = KylinConfig.getKylinProperties();
   StringWriter writer = new StringWriter();
   prop.list(new PrintWriter(writer));
   String propString = writer.getBuffer().toString();
   IOUtils.closeQuietly(writer);
   InputStream is = IOUtils.toInputStream(propString, Charset.defaultCharset());
   resources[0] = new InputStreamResource(is);
   this.setLocations(resources);
 }
    public void testLoadedProperties() throws IOException {
        InputStream is = this.getClass().getResourceAsStream(name);

        Properties p = new Properties();
        p.load(is);

        // We do not recommend using System.out and System.err in tests 
        // as a general practice, but here we list the properties to 
        // System.out just to demonstrate that they have been found and 
        // loaded.
        p.list(System.out);
    }
Пример #8
0
  public static void main(String args[]) throws Exception {
    if (args.length == 0) {
      System.err.println("Usage: java DumpXML file.xml");
      Runtime.getRuntime().exit(1);
    }

    IXMLParser parser = XMLParserFactory.createDefaultXMLParser();
    IXMLReader reader = StdXMLReader.fileReader(args[0]);
    parser.setReader(reader);
    XMLElement xml = (XMLElement) parser.parse();

    Properties prop = xml.getAttributes();
    prop.list(System.out);
  }
 private String getSystemProperties() {
   StringWriter swriter = new StringWriter();
   PrintWriter writer = new PrintWriter(swriter);
   writer.println("<html>");
   writer.println("<head><title>Java Properties</title></head>");
   writer.println("<body>");
   writer.println("<pre>");
   Properties properties = System.getProperties();
   properties.list(writer);
   writer.println("</pre>");
   writer.println("</body>");
   writer.println("</html>");
   writer.flush();
   return swriter.toString();
 }
Пример #10
0
 public static void loadProperties(String fileName) {
   InputStream is = null;
   try {
     pp = new Properties();
     File f = Files.findFile(fileName);
     if (f == null) throw new RuntimeException("nutz-test.properties Not FOUND!!!");
     is = Streams.fileIn(f);
     pp.load(is);
     pp.list(System.out);
   } catch (Exception e) {
     throw Lang.wrapThrow(e);
   } finally {
     Streams.safeClose(is);
   }
 }
  /**
   * Set NetworkTypeahead weighted connections store maxScn.
   *
   * <pre>
   * JVM arguments:
   *     -server -Xms4g -Xmx8g
   *
   * Program arguments:
   *     network-typeahead-member.config maxScn
   * </pre>
   *
   * @param args
   * @throws Exception
   */
  public static void main(String[] args) throws Exception {
    /** Load properties. */
    Properties properties = new Properties();
    try {
      String configFile = args[0];
      FileInputStream inStream = new FileInputStream(configFile);
      InputStreamReader reader = new InputStreamReader(inStream, "UTF-8");
      properties.load(reader);
      PropertiesResolver.resolve(properties);
      properties.list(System.out);
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }

    long maxScn = 0;
    try {
      maxScn = Long.parseLong(args[1]);
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }

    Chronos c = new Chronos();
    NetworkTypeaheadConfig<TypeaheadElement> config;
    WeightedNetworkTypeaheadInitializer<TypeaheadElement> initializer;

    /** Configure NetworkTypeahead */
    config = TypeaheadConfigFactory.createNetworkTypeaheadConfig(properties);
    config.setElementStoreCached(false); // disable cache to bypass serialization
    config.setElementStoreSegmentFactory(new ChannelSegmentFactory());
    config.setConnectionsStoreSegmentFactory(new ChannelSegmentFactory());
    initializer = new WeightedNetworkTypeaheadInitializer<TypeaheadElement>(config);

    WeightedNetworkTypeahead<TypeaheadElement> typeahead =
        (WeightedNetworkTypeahead<TypeaheadElement>) initializer.getTypeahead();

    // Set NetworkTypehead connections store hwMark
    typeahead.getConnectionsStore().saveHWMark(maxScn);
    typeahead.getConnectionsStore().sync();

    System.out.printf("Time: %d ms.%n", c.tick());
  }
Пример #12
0
 /** @tests java.util.Properties#list(java.io.PrintWriter) */
 @TestTargetNew(
     level = TestLevel.COMPLETE,
     notes = "",
     method = "list",
     args = {java.io.PrintWriter.class})
 public void test_listLjava_io_PrintWriter() {
   ByteArrayOutputStream baos = new ByteArrayOutputStream();
   PrintWriter pw = new PrintWriter(baos);
   Properties myProps = new Properties();
   String propList;
   myProps.setProperty("Abba", "Cadabra");
   myProps.setProperty("Open", "Sesame");
   myProps.list(pw);
   pw.flush();
   propList = baos.toString();
   assertTrue(
       "Property list innacurate",
       (propList.indexOf("Abba=Cadabra") >= 0) && (propList.indexOf("Open=Sesame") >= 0));
 }
 public static void LoadOfPropertiesMethod(String filePath) {
   FileReader fr = null;
   Properties ppt = new Properties();
   try {
     fr = new FileReader(filePath);
     /** Load(FileInputStream fis) is also well. */
     ppt.load(fr);
     System.out.println("直接打印:");
     System.out.println(ppt.toString() + "\n");
     System.out.println("list()方法:");
     ppt.list(System.out);
   } catch (IOException e) {
     e.printStackTrace();
   } finally {
     try {
       fr.close();
     } catch (IOException e) {
       e.printStackTrace();
     }
   }
 }
  @Override
  public void run() {
    Provider[] ps = java.security.Security.getProviders();
    for (Provider p : ps) {
      System.out.println("=========================================================");
      System.out.println(p);
      p.list(System.out);
    }

    try {
      System.out.println();
      System.out.println("=========================================================");
      System.out.println("a test of " + Properties.class);
      Properties ppt = new Properties();
      ppt.setProperty("hello", "world");
      ppt.list(System.out);
      ppt.store(System.out, "[some comments]");
      ppt.storeToXML(System.out, "[some comments]", "utf-8");
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Пример #15
0
  public static void main(String[] args) throws IOException {

    System.out.println("Hello, world..");

    String basePath = "conf";
    if (args.length > 0) {
      basePath = args[0];
    }

    File file = new File(basePath + File.separator + "cmd.conf");
    try {
      List<String> lines = Files.readLines(file, Charset.forName("UTF-8"));

      Properties prop = new Properties();
      prop.list(System.out);

      for (String line : lines) {
        System.out.println(line);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Пример #16
0
 /** Set the right values for the properties. */
 private static void setProperties() {
   sbProperties.setProperty(
       MIN_WINDOW_SIZE_PROPERTY,
       System.getProperty(
           MIN_WINDOW_SIZE_PROPERTY,
           sbProperties.getProperty(MIN_WINDOW_SIZE_PROPERTY, DEFAULT_MIN_WINDOW_SIZE)));
   sbProperties.setProperty(
       MAX_WINDOW_SIZE_PROPERTY,
       System.getProperty(
           MAX_WINDOW_SIZE_PROPERTY,
           sbProperties.getProperty(MAX_WINDOW_SIZE_PROPERTY, DEFAULT_MAX_WINDOW_SIZE)));
   sbProperties.setProperty(
       WINDOW_GROWTH_FACTOR_PROPERTY,
       System.getProperty(
           WINDOW_GROWTH_FACTOR_PROPERTY,
           sbProperties.getProperty(WINDOW_GROWTH_FACTOR_PROPERTY, DEFAULT_WINDOW_GROWTH_FACTOR)));
   sbProperties.setProperty(
       DUPLICATE_POLICY_PROPERTY,
       System.getProperty(
           DUPLICATE_POLICY_PROPERTY,
           sbProperties.getProperty(DUPLICATE_POLICY_PROPERTY, DEFAULT_DUPLICATE_POLICY)));
   StringWriter s_writer = new StringWriter();
   sbProperties.list(new PrintWriter(s_writer));
 }
Пример #17
0
  /** implemented. */
  public void test_list() {
    th.checkPoint("list(java.io.PrintStream)void");
    Properties p = new Properties();
    try {
      p.list((PrintStream) null);
      th.fail("should throw NullPointerException -- 1");
    } catch (NullPointerException ne) {
      th.check(true);
    }

    try {
      p.load(bin);
    } catch (Exception e) {
    }
    p.list(psout);
    byte ba[] = bout.toByteArray();
    Vector v = new Vector();
    Enumeration ek = p.keys();
    String s;
    while (ek.hasMoreElements()) {
      s = (String) ek.nextElement();
      v.add(s + "=" + p.getProperty(s));
    }
    v.add("Smart=move");
    v.add("animal=dog");

    int start, count = 0;
    v.removeElement("longvalue=I'mtryingtogiveavaluelongerthen40characters");
    v.add("longvalue=I'mtryingtogiveavaluelongerthen40char...");
    while (count < ba.length) {
      start = count;
      while (ba[count] != '\n' && count < ba.length) {
        count++;
      }
      s = new String(ba, start, count - start);
      if (!s.startsWith("--")) // list() adds a header
      th.check(v.contains(s), "v does not contain:$" + s + "$");
      v.removeElement(s);
      count++;
    }

    try {
      p.list((PrintStream) null);
      th.fail("should throw NullPointerException -- 2");
    } catch (NullPointerException ne) {
      th.check(true);
    }

    th.checkPoint("list(java.io.PrintWriter)void");
    resetStreams();
    p = new Properties();
    try {
      p.list((PrintWriter) null);
      th.fail("should throw NullPointerException -- 1");
    } catch (NullPointerException ne) {
      th.check(true);
    }

    try {
      p.load(bin);
    } catch (Exception e) {
    }
    p.list(pwout);
    ba = bout.toByteArray();
    v = new Vector();
    ek = p.keys();
    while (ek.hasMoreElements()) {
      s = (String) ek.nextElement();
      v.add(s + "=" + p.getProperty(s));
    }
    v.add("Smart=move");
    v.add("animal=dog");

    count = 0;
    v.removeElement("longvalue=I'mtryingtogiveavaluelongerthen40characters");
    v.add("longvalue=I'mtryingtogiveavaluelongerthen40char...");

    while (count < ba.length) {
      start = count;
      while (ba[count] != '\n' && count < ba.length) {
        count++;
      }
      s = new String(ba, start, count - start);
      if (!s.startsWith("--")) // list() adds a header
      th.check(v.contains(s), "v does not contain:$" + s + "$");
      v.removeElement(s);
      count++;
    }

    try {
      p.list((PrintStream) null);
      th.fail("should throw NullPointerException -- 2");
    } catch (NullPointerException ne) {
      th.check(true);
    }
  }
Пример #18
0
 /**
  * Prints the contents of this preference store to the given print stream.
  *
  * @param out the print stream
  */
 public void list(PrintStream out) {
   properties.list(out);
 }
Пример #19
0
 /**
  * Prints the contents of this preference store to the given print writer.
  *
  * @param out the print writer
  */
 public void list(PrintWriter out) {
   properties.list(out);
 }
  /**
   *
   *
   * <pre>
   * java NetworkTypeaheadWeightedConnectionsStoreBootstrap -server -Xms4G -Xmx16G \
   *      connectionsDir maxScn configFile ...
   *
   * java NetworkTypeaheadWeightedConnectionsStoreBootstrap -server -Xms4G -Xmx16G \
   *      bootstrap/member/connections 170403771779 \
   *      config/network-typeahead/member/i001.config \
   *      config/network-typeahead/member/i002.config \
   *      config/network-typeahead/member/i003.config
   * </pre>
   *
   * @param args
   * @throws Exception
   */
  public static void main(String args[]) throws Exception {
    Chronos c = new Chronos();
    MultiConnectionsHandler multiHandler = new MultiConnectionsHandler();

    File connectionsDir = new File(args[0]);
    long maxScn = Long.parseLong(args[1]);
    for (int i = 2; i < args.length; i++) {
      /** Load bootstrap properties. */
      Properties properties = new Properties();
      try {
        String configFile = args[i];
        FileInputStream inStream = new FileInputStream(configFile);
        InputStreamReader reader = new InputStreamReader(inStream, "UTF-8");
        properties.load(reader);
        PropertiesResolver.resolve(properties);
        properties.list(System.out);
      } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
      }

      /** Configure NetworkTypeahead */
      NetworkTypeaheadConfig<TypeaheadElement> config =
          TypeaheadConfigFactory.createNetworkTypeaheadConfig(properties);
      config.setElementStoreCached(false); // disable cache to bypass serialization
      config.setElementStoreSegmentFactory(new ChannelSegmentFactory());
      config.setConnectionsStoreSegmentFactory(
          new WriteBufferSegmentFactory(config.getConnectionsStoreSegmentMB()));

      WeightedNetworkTypeaheadInitializer<TypeaheadElement> initializer =
          new WeightedNetworkTypeaheadInitializer<TypeaheadElement>(config);
      WeightedNetworkTypeahead<TypeaheadElement> typeahead =
          (WeightedNetworkTypeahead<TypeaheadElement>) initializer.getTypeahead();

      ConnectionFilter connectionFilter = typeahead.getConnectionFilter();
      ArrayStoreWeights weightedConnectionsStore = typeahead.getConnectionsStore();
      System.out.printf("Added %s%n", config.getConnectionsStoreDir().getParent());

      multiHandler.add(
          new WeightedConnectionsStoreConnectionsHandler(
              weightedConnectionsStore, connectionFilter, maxScn));
    }

    if (multiHandler.isEmpty()) return;

    /** Bootstrap weighted-connections-store */
    System.out.println("-- starting bootstrap --");

    ConnectionsScanner scanner = new ConnectionsScanner(connectionsDir);
    scanner.scan(multiHandler);

    Iterator<ConnectionsHandler> iter = multiHandler.iterator();
    while (iter.hasNext()) {
      ArrayStoreWeights weightedConnectionsStore;
      weightedConnectionsStore =
          ((WeightedConnectionsStoreConnectionsHandler) iter.next()).getWeightedConnectionsStore();
      weightedConnectionsStore.sync();
    }

    System.out.println();
    System.out.printf("Bootstrap done in %d seconds%n", c.getTotalTime() / 1000);
  }
Пример #21
0
  /** Setup the Protocol instance acording to the configuration string */
  public boolean setProperties(Properties props) {
    String str;

    str = props.getProperty("join_timeout"); // time to wait for JOIN
    if (str != null) {
      join_timeout = new Long(str).longValue();
      props.remove("join_timeout");
    }

    str = props.getProperty("print_local_addr");
    if (str != null) {
      print_local_addr = new Boolean(str).booleanValue();
      props.remove("print_local_addr");
    }

    str = props.getProperty("view_change_timeout"); // time to wait for VIEW_CHANGE
    if (str != null) {
      view_change_timeout = new Long(str).longValue();
      props.remove("view_change_timeout");
    }

    str = props.getProperty("join_retry_timeout"); // time to wait between JOINs
    if (str != null) {
      join_retry_timeout = new Long(str).longValue();
      props.remove("join_retry_timeout");
    }

    str = props.getProperty("leave_timeout"); // time to wait until coord responds to LEAVE req.
    if (str != null) {
      leave_timeout = new Long(str).longValue();
      props.remove("leave_timeout");
    }

    str = props.getProperty("flush_timeout"); // time to wait until FLUSH completes (0=forever)
    if (str != null) {
      flush_timeout = new Long(str).longValue();
      props.remove("flush_timeout");
    }

    str = props.getProperty("rebroadcast_unstable_msgs"); // bcast unstable msgs (recvd from FLUSH)
    if (str != null) {
      rebroadcast_unstable_msgs = new Boolean(str).booleanValue();
      props.remove("rebroadcast_unstable_msgs");
    }

    str = props.getProperty("rebroadcast_timeout"); // time to wait until REBROADCAST_MSGS completes
    if (str != null) {
      rebroadcast_timeout = new Long(str).longValue();
      props.remove("rebroadcast_timeout");
    }

    str = props.getProperty("disable_initial_coord"); // allow initial mbr to become coord or not
    if (str != null) {
      disable_initial_coord = new Boolean(str).booleanValue();
      props.remove("disable_initial_coord");
    }

    if (props.size() > 0) {
      System.err.println("GMS.setProperties(): the following properties are not recognized:");
      props.list(System.out);
      return false;
    }
    return true;
  }
Пример #22
0
  /**
   * Setup the Protocol instance acording to the configuration string The following properties are
   * being read by the UDP protocol param mcast_addr - the multicast address to use default is
   * 224.0.0.200 param mcast_port - (int) the port that the multicast is sent on default is 7500
   * param ip_mcast - (boolean) flag whether to use IP multicast - default is true param ip_ttl -
   * Set the default time-to-live for multicast packets sent out on this socket. default is 32
   *
   * @return true if no other properties are left. false if the properties still have data in them,
   *     ie , properties are left over and not handled by the protocol stack
   */
  public boolean setProperties(Properties props) {
    String str, tmp;

    tmp = System.getProperty("UDP.bind_addr");
    if (tmp != null) {
      str = tmp;
    } else {
      str = props.getProperty("bind_addr");
    }
    if (str != null) {
      try {
        bind_addr = InetAddress.getByName(str);
      } catch (UnknownHostException unknown) {
        Trace.fatal("UDP.setProperties()", "(bind_addr): host " + str + " not known");
        return false;
      }
      props.remove("bind_addr");
    }

    str = props.getProperty("bind_port");
    if (str != null) {
      bind_port = new Integer(str).intValue();
      props.remove("bind_port");
    }

    str = props.getProperty("start_port");
    if (str != null) {
      bind_port = new Integer(str).intValue();
      props.remove("start_port");
    }

    str = props.getProperty("port_range");
    if (str != null) {
      port_range = new Integer(str).intValue();
      props.remove("port_range");
    }

    str = props.getProperty("mcast_addr");
    if (str != null) {
      mcast_addr_name = new String(str);
      props.remove("mcast_addr");
    }

    str = props.getProperty("mcast_port");
    if (str != null) {
      mcast_port = new Integer(str).intValue();
      props.remove("mcast_port");
    }

    str = props.getProperty("ip_mcast");
    if (str != null) {
      ip_mcast = new Boolean(str).booleanValue();
      props.remove("ip_mcast");
    }

    str = props.getProperty("ip_ttl");
    if (str != null) {
      ip_ttl = new Integer(str).intValue();
      props.remove("ip_ttl");
    }

    str = props.getProperty("mcast_send_buf_size");
    if (str != null) {
      mcast_send_buf_size = Integer.parseInt(str);
      props.remove("mcast_send_buf_size");
    }

    str = props.getProperty("mcast_recv_buf_size");
    if (str != null) {
      mcast_recv_buf_size = Integer.parseInt(str);
      props.remove("mcast_recv_buf_size");
    }

    str = props.getProperty("ucast_send_buf_size");
    if (str != null) {
      ucast_send_buf_size = Integer.parseInt(str);
      props.remove("ucast_send_buf_size");
    }

    str = props.getProperty("ucast_recv_buf_size");
    if (str != null) {
      ucast_recv_buf_size = Integer.parseInt(str);
      props.remove("ucast_recv_buf_size");
    }

    str = props.getProperty("loopback");
    if (str != null) {
      loopback = new Boolean(str).booleanValue();
      props.remove("loopback");
    }

    // this is deprecated, just left for compatibility (use use_incoming_packet_handler)
    str = props.getProperty("use_packet_handler");
    if (str != null) {
      use_incoming_packet_handler = new Boolean(str).booleanValue();
      props.remove("use_packet_handler");
      Trace.warn(
          "UDP.setProperties()",
          "'use_packet_handler' is deprecated; use 'use_incoming_packet_handler' instead");
    }

    str = props.getProperty("use_incoming_packet_handler");
    if (str != null) {
      use_incoming_packet_handler = new Boolean(str).booleanValue();
      props.remove("use_incoming_packet_handler");
    }

    str = props.getProperty("use_outgoing_packet_handler");
    if (str != null) {
      use_outgoing_packet_handler = new Boolean(str).booleanValue();
      props.remove("use_outgoing_packet_handler");
    }

    str = props.getProperty("max_bundle_size");
    if (str != null) {
      int bundle_size = Integer.parseInt(str);
      if (bundle_size > max_bundle_size) {
        Trace.error(
            "UDP.setProperties()",
            "max_bundle_size ("
                + bundle_size
                + ") is greater than largest UDP fragmentation size ("
                + max_bundle_size
                + ")");
        return false;
      }
      if (bundle_size <= 0) {
        Trace.error("UDP.setProperties()", "max_bundle_size (" + bundle_size + ") is <= 0");
        return false;
      }
      max_bundle_size = bundle_size;
      props.remove("max_bundle_size");
    }

    str = props.getProperty("max_bundle_timeout");
    if (str != null) {
      max_bundle_timeout = Long.parseLong(str);
      if (max_bundle_timeout <= 0) {
        Trace.error(
            "UDP.setProperties()", "max_bundle_timeout of " + max_bundle_timeout + " is invalid");
        return false;
      }
      props.remove("max_bundle_timeout");
    }

    str = props.getProperty("enable_bundling");
    if (str != null) {
      enable_bundling = new Boolean(str).booleanValue();
      props.remove("enable_bundling");
    }

    if (props.size() > 0) {
      System.err.println("UDP.setProperties(): the following properties are not recognized:");
      props.list(System.out);
      return false;
    }

    if (enable_bundling) {
      if (use_outgoing_packet_handler == false) {
        Trace.warn(
            "UDP.setProperties()",
            "enable_bundling is true; setting use_outgoing_packet_handler=true");
      }
      use_outgoing_packet_handler = true;
    }

    return true;
  }
Пример #23
0
 /** List the properties in the <code>Code</code>. */
 public static void list(PrintStream out) throws IOException {
   prp.list(out);
 }
  @Override
  public void list(PrintStream out) {
    super.list(out);

    parent.list(out);
  }
Пример #25
0
  /** Setup the Protocol instance acording to the configuration string */
  public boolean setProperties(Properties props) {
    String str;

    str = props.getProperty("start_port");
    if (str != null) {
      start_port = new Integer(str).intValue();
      props.remove("start_port");
    }

    str = props.getProperty("bind_addr");
    if (str != null) {
      try {
        bind_addr = InetAddress.getByName(str);
      } catch (UnknownHostException unknown) {
        Trace.fatal("TCP.setProperties()", "(bind_addr): host " + str + " not known");
        return false;
      }
      props.remove("bind_addr");
    }

    str = props.getProperty("reaper_interval");
    if (str != null) {
      reaper_interval = Long.parseLong(str);
      props.remove("reaper_interval");
    }

    str = props.getProperty("conn_expire_time");
    if (str != null) {
      conn_expire_time = Long.parseLong(str);
      props.remove("conn_expire_time");
    }

    str = props.getProperty("recv_buf_size");
    if (str != null) {
      recv_buf_size = Integer.parseInt(str);
      props.remove("recv_buf_size");
    }

    str = props.getProperty("send_buf_size");
    if (str != null) {
      send_buf_size = Integer.parseInt(str);
      props.remove("send_buf_size");
    }

    str = props.getProperty("loopback");
    if (str != null) {
      loopback = new Boolean(str).booleanValue();
      props.remove("loopback");
    }

    str = props.getProperty("skip_suspected_members");
    if (str != null) {
      skip_suspected_members = new Boolean(str).booleanValue();
      props.remove("skip_suspected_members");
    }

    if (props.size() > 0) {
      System.err.println("TCP.setProperties(): the following properties are not recognized:");
      props.list(System.out);
      return false;
    }
    return true;
  }
Пример #26
0
 public void list(PrintWriter out) {
   p.list(out);
 }
Пример #27
0
 public void list(PrintStream out) {
   p.list(out);
 }
  @Override
  public void list(PrintWriter out) {
    super.list(out);

    parent.list(out);
  }
Пример #29
0
  public static void list(Map<String, String> map, PrintWriter printWriter) {
    Properties properties = fromMap(map);

    properties.list(printWriter);
  }
 private void printSystemProperties() {
   Properties props = System.getProperties();
   props.list(System.out);
 }