Example #1
0
  public void loadDataSource() {
    JXmlWapper xmlConfig = JXmlWapper.parse(new File(this.configFile));
    int count = xmlConfig.countXmlNodes("dataSource");
    for (int i = 0; i < count; i++) {
      JXmlWapper xmlds = xmlConfig.getXmlNode("dataSource[" + i + "]");
      String dataSource = xmlds.getStringValue("@name");

      String strDescName = xmlds.getStringValue("@desc");
      String driverName = xmlds.getStringValue("@driverName");
      String dbUrl = xmlds.getStringValue("@dbUrl");
      String dbUrlBak = xmlds.getStringValue("@dbUrlBak");
      String userName = xmlds.getStringValue("@userName");
      String passWord = xmlds.getStringValue("@passWord");
      String checkSql = xmlds.getStringValue("@checkSql");
      String serverType = xmlds.getStringValue("@serverType");
      int startNum = xmlds.getIntValue("@startNum", 1);
      int maxNum = xmlds.getIntValue("@maxNum", 5);
      int maxCallNum = xmlds.getIntValue("@maxCallNum", 0);
      int interval = xmlds.getIntValue("@interval", 60);

      JdbcConnectPool pool = new JdbcConnectPool();
      pool.setCheckSql(checkSql);
      pool.setDataSource(dataSource);
      pool.setDbUrl(dbUrl);
      pool.setDbUrlBak(dbUrlBak);
      pool.setDescName(strDescName);
      pool.setDriverName(driverName);
      pool.setInterval(interval);
      pool.setMaxCallNum(maxCallNum);
      pool.setMaxNum(maxNum);
      pool.setPassWord(passWord);
      pool.setServerType(serverType);
      pool.setStartNum(startNum);
      pool.setUserName(userName);
      try {
        pool.startCheckThread();
        pool.createConnects();
      } catch (Exception localException) {
      }
      this.pools.put(dataSource, pool);
    }
  }
Example #2
0
  private void load_config() {
    JXmlWapper xml = JXmlWapper.parse(new File(this.configFile));
    int gcount = xml.countXmlNodes("group");
    for (int i = 0; i < gcount; i++) {
      JXmlWapper gnode = xml.getXmlNode("group[" + i + "]");
      String gid = gnode.getStringValue("@id");
      String gName = gnode.getStringValue("@name");

      NodeGroup objGroup = new NodeGroup();
      objGroup.setGroupID(gid);
      objGroup.setGroupName(gName);

      int ncount = gnode.countXmlNodes("node");
      for (int j = 0; j < ncount; j++) {
        JXmlWapper node = gnode.getXmlNode("node[" + j + "]");
        String nid = node.getStringValue("@id");
        String nip = node.getStringValue("@ip");
        String name = node.getStringValue("@name");
        int port = Integer.parseInt(node.getStringValue("@port"));

        MinaNode objNode = new MinaNode();
        objNode.setNodeID(nid);
        objNode.setNodeIp(nip);
        objNode.setPort(port);
        objNode.setNodeName(name);

        SocketAddress address = new InetSocketAddress(nip, port);
        objNode.setRemoteAddress(address);

        this.connectQueue.offer(objNode);
        objGroup.addNode(objNode);
        this.logger.info("加载节点 --->  " + objNode.toString());
      }
      this.groupMaps.put(gid, objGroup);
    }
    startProcessor();
  }