123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package com.pbsage.util;
- import java.io.File;
- import java.net.URLDecoder;
- import org.dom4j.Document;
- import org.dom4j.Element;
- import org.dom4j.io.SAXReader;
- public class Config {
- public static String json_file;
- public static int thread_count_ini;
- public static int thread_count_add;
- public static int thread_count_max;
- public static int loop_count;
- public static long interval_loop;
- public static long interval_step;
- public static int job_count;
- static {
- try {
- {
- String filepathDatabase = Constant.GetPath() + "/config.xml";
- SAXReader saxReader = new SAXReader();
- File xmlFile = new File(URLDecoder.decode(filepathDatabase, "UTF-8"));
- Document document = saxReader.read(xmlFile);
- Element element;
- element = (Element) document.selectSingleNode("/root/json_file");
- json_file = element.getText();
- element = (Element) document.selectSingleNode("/root/thread_count_ini");
- thread_count_ini = Integer.parseInt(element.getText());
- element = (Element) document.selectSingleNode("/root/thread_count_add");
- thread_count_add = Integer.parseInt(element.getText());
- element = (Element) document.selectSingleNode("/root/thread_count_max");
- thread_count_max = Integer.parseInt(element.getText());
- element = (Element) document.selectSingleNode("/root/loop_count");
- loop_count = Integer.parseInt(element.getText());
- element = (Element) document.selectSingleNode("/root/interval_loop");
- interval_loop = Long.parseLong(element.getText());
- element = (Element) document.selectSingleNode("/root/interval_step");
- interval_step = Long.parseLong(element.getText());
- element = (Element) document.selectSingleNode("/root/job_count");
- job_count = Integer.parseInt(element.getText());
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
|