Пример #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());
  }
Пример #2
0
  /**
   * 获取远程方法绑定URL
   *
   * @param RMINode rmiNode
   * @return String rmiUrl
   */
  public static String getRMIURL(RMINode rmiNode) {
    String host = rmiNode.getHost();
    int port = rmiNode.getPort();
    String rmiName = rmiNode.getRmiName();
    String rmiUrl = "rmi://" + host + ":" + port + "/" + rmiName;

    //		System.out.println("rmiUrl:" + rmiUrl);

    return rmiUrl;
  }