Beispiel #1
0
 private boolean isProtocolEnabled(Properties properties, String protocol) {
   String enabled = properties.getProperty(protocol + ".enable");
   if (enabled != null) {
     return Boolean.valueOf(enabled);
   }
   return false;
 }
Beispiel #2
0
  /** Initialize logger */
  private void initLogger(Properties properties) throws IOException {

    loggerEnabled = Boolean.valueOf(properties.getProperty("logger.enable"));

    if (loggerEnabled) {

      String fileName = properties.getProperty("logger.file");
      if (fileName != null) {

        FileHandler file = new FileHandler(fileName, true);

        // Simple formatter
        file.setFormatter(
            new Formatter() {
              private final String LINE_SEPARATOR = System.getProperty("line.separator", "\n");

              private final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

              public String format(LogRecord record) {
                String line = dateFormat.format(new Date(record.getMillis()));
                line += " " + record.getLevel().getName() + ": ";
                line += formatMessage(record);
                line += LINE_SEPARATOR;
                return line;
              }
            });

        // NOTE: Console logger level will remain INFO
        Log.getLogger().setLevel(Level.ALL);
        Log.getLogger().addHandler(file);
      }
    }
  }
Beispiel #3
0
  /** Initialize */
  public void init(String[] arguments) throws IOException, ClassNotFoundException, SQLException {

    // Load properties
    properties = new Properties();
    if (arguments.length > 0) {
      properties.loadFromXML(new FileInputStream(arguments[0]));
    }

    dataManager = new DatabaseDataManager(properties);

    initLogger(properties);
    initGeocoder(properties);

    initXexunServer("xexun");
    initGps103Server("gps103");
    initTk103Server("tk103");
    initGl100Server("gl100");
    initGl200Server("gl200");
    initT55Server("t55");
    initXexun2Server("xexun2");
    initAvl08Server("avl08");
    initEnforaServer("enfora");
    initMeiligaoServer("meiligao");
    initMaxonServer("maxon");
    initST210Server("st210");
    initProgressServer("progress");
    initH02Server("h02");
    initJt600Server("jt600");
    initEv603Server("ev603");
    initV680Server("v680");
    initPt502Server("pt502");
    initTr20Server("tr20");
    initNavisServer("navis");
    initMeitrackServer("meitrack");
    initSkypatrolServer("skypatrol");
    initGt02Server("gt02");
    initGt06Server("gt06");
    initMegastekServer("megastek");
    initNavigilServer("navigil");
    initGpsGateServer("gpsgate");
    initTeltonikaServer("teltonika");
    initMta6Server("mta6");
    initMta6CanServer("mta6can");
    initTlt2hServer("tlt2h");
    initSyrusServer("syrus");

    // Initialize web server
    if (Boolean.valueOf(properties.getProperty("http.enable"))) {
      webServer = new WebServer(properties);
    }
  }
Beispiel #4
0
  /** Initialize logger */
  private void initLogger(Properties properties) throws IOException {

    loggerEnabled = Boolean.valueOf(properties.getProperty("logger.enable"));

    if (loggerEnabled) {

      String fileName = properties.getProperty("logger.file");
      if (fileName != null) {

        FileHandler file = new FileHandler(fileName, true);

        // Simple formatter
        file.setFormatter(
            new Formatter() {
              private final String LINE_SEPARATOR = System.getProperty("line.separator", "\n");

              private final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

              @Override
              public String format(LogRecord record) {
                StringBuffer line = new StringBuffer();
                dateFormat.format(new Date(record.getMillis()), line, new FieldPosition(0));
                line.append(" ");
                line.append(record.getSourceClassName());
                line.append(".");
                line.append(record.getSourceMethodName());
                line.append(" ");
                line.append(record.getLevel().getName());
                line.append(": ");
                line.append(formatMessage(record));
                line.append(LINE_SEPARATOR);
                return line.toString();
              }
            });

        Log.getLogger().addHandler(file);
      }
    }
  }
Beispiel #5
0
  /** Initialize */
  public void init(String[] arguments) throws IOException, ClassNotFoundException, SQLException {

    // Load properties
    Properties properties = new Properties();
    if (arguments.length > 0) {
      properties.loadFromXML(new FileInputStream(arguments[0]));
    }

    dataManager = new DatabaseDataManager(properties);

    initLogger(properties);
    initGeocoder(properties);

    initXexunServer(properties);
    initGps103Server(properties);
    initTk103Server(properties);
    initGl100Server(properties);
    initGl200Server(properties);
    initT55Server(properties);
    initXexun2Server(properties);
    initAvl08Server(properties);
    initEnforaServer(properties);
    initMeiligaoServer(properties);
    initMaxonServer(properties);
    initST210Server(properties);

    // Initialize web server
    if (Boolean.valueOf(properties.getProperty("http.enable"))) {
      Integer port = Integer.valueOf(properties.getProperty("http.port", "8082"));
      String address = properties.getProperty("http.address");
      if (address != null) {
        webServer = new WebServer(address, port, dataManager);
      } else {
        webServer = new WebServer(port, dataManager);
      }
    }
  }
Beispiel #6
0
 private void initGeocoder(Properties properties) throws IOException {
   if (Boolean.parseBoolean(properties.getProperty("geocoder.enable"))) {
     geocoder = new GoogleReverseGeocoder();
   }
 }