Exemplo n.º 1
0
  private NBFields getServerConfig()
      throws ParserConfigurationException, SAXException, IOException, TransformerException {
    NBFields fields = new NBFields();
    DOMConfigurator dom = new DOMConfigurator(ServerConfiguration.getConfigFile());

    fields.put("LICENSE", "");
    fields.put("ROOT_PATH", dom.getConf("server/default-file-path"));
    fields.put("LOG4J_PATH", dom.getConf("server/log-properties"));
    fields.put("USER_PATH", dom.getConf("server/user-config-file"));
    fields.put("INSTANCE_CONF_PATH", dom.getConf("server/instance-config-file"));
    fields.put("LOCALE", dom.getConf("server/time-locale"));
    fields.put("ENCODING", dom.getConf("server/server-encoding"));
    fields.put("MAX_CLIENT", dom.getConf("server/network/max-client-num"));
    fields.put("SERVICE_PORT", dom.getConf("server/network/service-port"));
    fields.put("SOCK_BUFF_SIZE", dom.getConf("server/network/max-socket-buffer"));
    fields.put("SOCK_TIME_OUT", dom.getConf("server/network/read-time-out"));

    ArrayList<HashMap<String, String>> getProtocolList =
        dom.getSubNodeListParamMap("server/protocol-list");
    ArrayList<NBFields> protocolList = new ArrayList<NBFields>();
    for (int i = 0; i < getProtocolList.size(); i++) {
      NBFields protocolFields = new NBFields();
      protocolFields.put("ID", getProtocolList.get(i).get("id"));
      protocolFields.put("NAME", getProtocolList.get(i).get("name"));
      protocolFields.put("CLASS", getProtocolList.get(i).get("class"));
      protocolList.add(protocolFields);
    }
    fields.put("PCL_LIST", protocolList);

    ArrayList<HashMap<String, String>> getPluginList =
        dom.getSubNodeListParamMap("server/plug-in-list");
    ArrayList<NBFields> pluginList = new ArrayList<NBFields>();
    for (int i = 0; i < getPluginList.size(); i++) {
      NBFields pluginFields = new NBFields();
      pluginFields.put("ID", getPluginList.get(i).get("id"));
      pluginFields.put("NAME", getPluginList.get(i).get("name"));
      pluginFields.put("TYPE", getPluginList.get(i).get("type"));

      // Plugin param
      HashMap<String, String> paramMap =
          dom.getSubNodeListMapBySubNodeIDList(
              "server/plug-in-list", (String) pluginFields.get("ID"));
      Set<String> keyList = paramMap.keySet();
      Iterator<String> itr = keyList.iterator();
      while (itr.hasNext()) {
        String key = itr.next();
        pluginFields.put("PRM__" + key, paramMap.get(key));
      }

      pluginList.add(pluginFields);
    }
    fields.put("PLG_LIST", pluginList);

    return fields;
  }
Exemplo n.º 2
0
  private NBFields getPluginList(String pluginName)
      throws ParserConfigurationException, SAXException, IOException, TransformerException {
    NBFields fields = new NBFields();
    DOMConfigurator dom = new DOMConfigurator(ServerConfiguration.getConfigFile());

    ArrayList<HashMap<String, String>> getPluginList =
        dom.getSubNodeListParamMap("server/plug-in-list");
    ArrayList<NBFields> pluginList = new ArrayList<NBFields>();
    for (int i = 0; i < getPluginList.size(); i++) {
      if (pluginName.equals("")) {
        NBFields pluginFields = new NBFields();
        pluginFields.put("ID", getPluginList.get(i).get("id"));
        pluginFields.put("NAME", getPluginList.get(i).get("name"));
        pluginFields.put("TYPE", getPluginList.get(i).get("type"));

        pluginList.add(pluginFields);
      } else {
        if (getPluginList.get(i).get("id").contains(pluginName)) {
          NBFields pluginFields = new NBFields();
          pluginFields.put("ID", getPluginList.get(i).get("id"));
          pluginFields.put("NAME", getPluginList.get(i).get("name"));
          pluginFields.put("TYPE", getPluginList.get(i).get("type"));

          pluginList.add(pluginFields);
        }
      }
    }

    fields.put("PLG_LST", pluginList);

    return fields;
  }