Esempio n. 1
0
  public static void contextDestroyed(ServletContextEvent sce) {
    UserLoginListener.forceAllUserOffline();

    if (runingMonitor) {
      log.info("记录服务器关闭日志");
      log.info("Recording the server shutdown logging", Locale.ENGLISH);
      runingTime.setShutdownTime(new Date());
      runingTime.setRuningTime(
          runingTime.getShutdownTime().getTime() - runingTime.getStartupTime().getTime());
      LogQueue.addLog(runingTime);
    }
    if (memoryMonitor) {
      log.info("停止内存监视线程");
      log.info("Stop memory monitor thread", Locale.ENGLISH);
      memoryMonitorThread.running = false;
      memoryMonitorThread.interrupt();
    }

    if (LogQueue.getLogQueue() != null) {
      LogQueue.getLogQueue().saveLog();
    }
    deregisterDrivers();
    log.info("卸载JDBC驱动");
    log.info("Uninstalled JDBC driver", Locale.ENGLISH);
  }
Esempio n. 2
0
  public static void contextInitialized(ServletContextEvent sce) {
    contextPath = sce.getServletContext().getContextPath();
    log.info("启动【" + PropertyHolder.getProperty("app.name") + "】");
    log.info("Launch【" + PropertyHolder.getProperty("app.name") + "】", Locale.ENGLISH);
    log.info("应用上下文:" + contextPath);
    log.info("App context:" + contextPath, Locale.ENGLISH);
    ServletContext sc = sce.getServletContext();
    basePath = sc.getRealPath("/");
    if (!basePath.endsWith(File.separator)) {
      basePath = basePath + File.separator;
    }
    // 整个系统中的文件操作都以basePath为基础
    FileUtils.setBasePath(basePath);
    log.info("basePath:" + basePath);
    String userDir = System.getProperty("user.dir");
    log.info("user.dir:" + userDir);
    userDir = FileUtils.getAbsolutePath("/WEB-INF/classes/data/");
    System.setProperty("user.dir", userDir);
    log.info("将user.dir重新设置为:" + userDir);
    log.info("Reset user directory:" + userDir, Locale.ENGLISH);

    String encoding = System.getProperty("file.encoding");
    log.info("你的操作系统所用的编码file.encoding:" + encoding);
    log.info("Encoding of your OS is file.encoding:" + encoding, Locale.ENGLISH);

    // 为spring的配置做预处理
    prepareForSpring();
    // 注册模块
    registerModules();
    // 解析所有的dic.xml文件,并生成供客户端EXT JS调用的文件
    DictionaryGenerator.generateDic(basePath);

    if (runingMonitor) {
      log.info("记录服务器启动日志");
      log.info("Recording the server boot logging", Locale.ENGLISH);
      runingTime = new RuningTime();
      try {
        runingTime.setServerIP(InetAddress.getLocalHost().getHostAddress());
      } catch (UnknownHostException e) {
        log.error("记录服务器启动日志出错", e);
        log.error("Failed to record the server boot logging", e, Locale.ENGLISH);
      }
      runingTime.setAppName(contextPath);
      runingTime.setOsName(System.getProperty("os.name"));
      runingTime.setOsVersion(System.getProperty("os.version"));
      runingTime.setOsArch(System.getProperty("os.arch"));
      runingTime.setJvmName(System.getProperty("java.vm.name"));
      runingTime.setJvmVersion(System.getProperty("java.vm.version"));
      runingTime.setJvmVendor(System.getProperty("java.vm.vendor"));
      runingTime.setStartupTime(new Date());
    }
    if (memoryMonitor) {
      log.info("启动内存监视线程");
      log.info("Enable memory monitor thread", Locale.ENGLISH);
      int circle = PropertyHolder.getIntProperty("monitor.memory.circle");
      memoryMonitorThread = new MemoryMonitorThread(circle);
      memoryMonitorThread.start();
    }
    running = true;
  }
Esempio n. 3
0
 @Override
 protected void afterRender(Map map, RuningTime obj) {
   map.put("runingTime", obj.getRuningTimeStr());
   map.remove("osName");
   map.remove("osVersion");
   map.remove("osArch");
   map.remove("jvmVersion");
   map.remove("jvmName");
   map.remove("jvmVendor");
   map.remove("updateTime");
   map.remove("createTime");
   map.remove("appName");
 }