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

📄 syslistener.java

📁 天乙社区6.0是一套基于JAVA技术的网络虚拟社区
💻 JAVA
字号:
package com.laoer.bbscs.web.servlet;

import com.laoer.bbscs.sys.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.laoer.bbscs.lucene.*;

/**
 * <p>Title: TianYi BBS</p>
 * <p>Description: TianYi BBS System</p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: LAOER.COM/TIANYISOFT.NET</p>
 * @author laoer
 * @version 6.0
 */

public class SysListener
    extends HttpServlet implements ServletContextListener {

  private static final Log logger = LogFactory.getLog(SysListener.class);

  Timer aTimer = new Timer(true);

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

    //Constant.SC = sce.getServletContext();
    String rootpath = sce.getServletContext().getRealPath("/");
    if (rootpath != null) {
      rootpath = rootpath.replaceAll("\\\\", "/");
    }
    else {
      rootpath = "/";
    }
    if (!rootpath.endsWith("/")) {
      rootpath = rootpath + "/";
    }
    Constant.ROOTPATH = rootpath;
    logger.info("Application Run Path:" + rootpath);
    Properties prop = new Properties();
    InputStream stream = this.getClass().getResourceAsStream(
        "/configpath.properties");
    try {
      prop.load(stream);
      String config_path = prop.getProperty("config_path");
      if (!config_path.endsWith("/")) {
        config_path = config_path + "/";
      }
      if (config_path.equals("/") || config_path.equals("/WEB-INF/classes/")) {
        Constant.CONFIGPATH = rootpath + "WEB-INF/classes/";
      }
      else {
        Constant.CONFIGPATH = config_path;
      }
    }
    catch (IOException ex) {
      logger.error(ex);
      Constant.CONFIGPATH = rootpath + "WEB-INF/classes/";
    }
    logger.info("Application Run ConfigPath:" + Constant.CONFIGPATH);

    AppContext.getInstance();

    if (SysInfo.getInstance().getBoardthread() > 0) {
      aTimer.schedule(BoardLoadTimerTask.getInstance(),
                      SysInfo.getInstance().getBoardthread() * 60 * 1000,
                      SysInfo.getInstance().getBoardthread() * 60 * 1000);

      /*
       aTimer.schedule(BoardLoadTimerTask.getInstance(sce.getServletContext()),
                      SysInfo.getInstance().getBoardthread() * 60 * 1000,
                      SysInfo.getInstance().getBoardthread() * 60 * 1000);*/
    }
    /*aTimer.schedule(new SubscibeSendTimerTask(sce.getServletContext()),
                    5 * 60 * 1000, 5 * 60 * 1000);*/
    if (SysInfo.getInstance().getIndexall() == 1) {
      logger.info("Create index all......");
      IndexHTML.doIndex(true);
    }
    aTimer.schedule(new IndexTimerTask(),
                    SysInfo.getInstance().getIndextime() * 60 * 1000,
                    SysInfo.getInstance().getIndextime() * 60 * 1000);
    //IAdvService advs = (IAdvService)wac.getBean("advService");
    //logger.info("Init Adv...");
    //Constant.ADV1 = advs.findAdvByType((short)0);
    //Constant.ADV2 = advs.findAdvByType((short)1);
  }

  //Notification that the servlet context is about to be shut down
  public void contextDestroyed(ServletContextEvent sce) {
    //BoardLoadThread.getInstance(sce.getServletContext()).setIsRun(false);
    //BoardLoadThread.getInstance(sce.getServletContext()).destroy();
    aTimer.cancel();
    AppContext.getInstance().getAppContext().close();
  }
}

⌨️ 快捷键说明

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