Beispiel #1
0
  /** 测试方法 */
  public static void TestGetNodeList(String rmiName) {
    List nodeList = new ArrayList();
    Document doc = FileUtil.loadXml("E:\\tsms\\defaultroot\\WEB-INF\\rmi-config.xml");

    List nodes = doc.selectNodes("//rmi-config/listeners/listener/node");
    Iterator it = nodes.iterator();
    // System.out.println("nodes:" + nodes);
    while (it.hasNext()) {
      Element elm = (Element) it.next();
      if (rmiName.equals(elm.attribute("rmiName").getValue())) {
        RMINode rminode = new RMINode();
        rminode.setHost(elm.attribute("host").getValue());
        rminode.setPort(Integer.parseInt(elm.attribute("port").getValue()));
        rminode.setRmiName(rmiName);
        nodeList.add(rminode);
      }
    }

    for (int i = 0; i < nodeList.size(); i++) {
      RMINode node = (RMINode) nodeList.get(i);
      System.out.println(node.getHost());
      System.out.println(node.getPort());
    }

    RMINode node0 = (RMINode) nodeList.get(0);
    System.out.println("----node0----");
    System.out.println(node0.getHost());
    System.out.println(node0.getPort());
  }
Beispiel #2
0
 public static Document getConfigDoc() {
   configDoc = FileUtil.loadXml(configXmlUrl);
   return configDoc;
 }