예제 #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;
  }
예제 #3
0
  /**
   * 获取远程方法调用节点
   *
   * @param String rmiName
   * @return List<RMINode> nodeList
   */
  public static List<RMINode> getRMINodeList(String rmiName) {
    List<RMINode> nodelist = new ArrayList<RMINode>();
    Document doc = getConfigDoc();
    List nodes = doc.selectNodes("//rmi-config/listeners/listener/node");
    Iterator it = nodes.iterator();
    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);
      }
    }
    return nodelist;
  }