⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 syslistener.java

📁 天乙代码src_531.rar 天乙代码src_531.rar 天乙代码src_531.rar 天乙代码src_531.rar
💻 JAVA
字号:
package com.laoer.bbscs.servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import com.laoer.bbscs.sysinfo.*;
import com.laoer.bbscs.bbs.business.*;
import org.apache.log4j.*;
import com.laoer.bbscs.lucene.*;
import com.laoer.bbscs.util.*;

/**
 * <p>Title: 天乙社区V5.0</p>
 * <p>Description: BBS-CS天乙社区V5.0</p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: laoer.com</p>
 * @author 龚天乙
 * @version 5.0
 */

public class SysListener
    extends HttpServlet
    implements ServletContextListener {

  Timer aTimer = new Timer();

  //Notification that the web application is ready to process requests
  public void contextInitialized(ServletContextEvent sce) {

    Sys.SYSINFO = new SysInfo();

    String rootpath = sce.getServletContext().getRealPath("/");

    if (rootpath != null) {
      rootpath = rootpath.replaceAll("\\\\", "/");
      if (!rootpath.endsWith("/")) {
        rootpath = rootpath + "/";
      }
    }
    else {
      rootpath = Sys.SYSINFO.WEBPATH;
    }

    if (Sys.SYSINFO.WEBPATH == null || Sys.SYSINFO.WEBPATH.length() == 0 ||
        Sys.SYSINFO.WEBPATH.equals("/")) {
      Sys.SYSINFO.WEBPATH = rootpath;
      //System.out.println(Sys.SYSINFO.WEBPATH);
    }
    if (Sys.SYSINFO.FILEPATH == null || Sys.SYSINFO.FILEPATH.length() == 0 ||
        Sys.SYSINFO.FILEPATH.equals("/")) {
      Sys.SYSINFO.FILEPATH = rootpath + "file/";
    }
    if (Sys.SYSINFO.SYSLOG == null || Sys.SYSINFO.SYSLOG.length() == 0 ||
        Sys.SYSINFO.SYSLOG.equals("/")) {
      Sys.SYSINFO.SYSLOG = rootpath + "sys.html";
    }

    //PropertyConfigurator.configure(Sys.SYSINFO.WEBPATH +"WEB-INF/log4j.properties");
    PropertyConfigurator.configure(Sys.getLog4jPro(Sys.SYSINFO.SYSLOG));

    Logger logger = Logger.getLogger(SysListener.class.getName());

    logger.info("Initialize System Info");
    logger.info("Initialize Cache");
    Sys.CACHE = new Cache(Sys.SYSINFO.CACHEMAXSIZE,
                          Sys.SYSINFO.CACHEMAXLIFETIME);

    logger.info("Initialize Website Info(Website name,URL)");
    Sys.WEBSITE = WebSite.getWebSite();

    logger.info("Initialize first board");
    Board initBoard = BoardFactory.getInstance();
    initBoard.setBoardList(null);

    logger.info("Initialize second board");
    Boards initBoards = BoardsFactory.getInstance();
    initBoards.setBoardsList(null);

    logger.info("Initialize CSS");
    CSS aCSS = CSSFactory.getInstance();
    aCSS.setInitCSS();

    logger.info("Initialize blackuser list");
    BlackUserInfo aBlackUserInfo = new BlackUserInfo();
    BlackUser aBlackUser = BlackUserFactory.getInstance();
    aBlackUser.setBlackUserInfo(aBlackUserInfo);
    aBlackUser.setBlackUserList(null);

    logger.info("Create index");
    if (Sys.SYSINFO.INDEXALL.equals("yes")) {
      IndexHTML.doIndex(true);
    }

    aTimer.schedule(new ServerSessionTimerTask(), 0,
                    Sys.SYSINFO.SESSIONOVERTIME);
    if (Sys.SYSINFO.MAINSERVER.equals("yes")) {
      logger.info("Create file thread, per 5 min");
      aTimer.schedule(new CreateFileTimerTask(), 0, 300000);
      logger.info("Board list file thread, per 2 hour");
      aTimer.schedule(new CreateBoardsFileTimerTask(), 0, 7200000);
      logger.info("Create index thread");
      aTimer.schedule(new IndexTimerTask(), 0, Sys.SYSINFO.INDEXTIME);
      logger.info("Delete out time, guest per 1 hour");
      aTimer.schedule(new UserOnlineTimerTask(), 0, 60 * 60000);
    }
    if (Sys.SYSINFO.SINGLESERVER.equals("no")) {
      aTimer.schedule(new SessionServerTimerTask(), 0);
    }
  }

  //Notification that the servlet context is about to be shut down
  public void contextDestroyed(ServletContextEvent sce) {
    aTimer.cancel();
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -