Пример #1
0
  @Override
  public void init() throws ServletException {
    super.init();

    System.out.println("");
    System.out.println("");
    System.out.println("		    _  ____  _     _     ____");
    System.out.println("		   / |/  _ \\/ \\ |\\/ \\   /  _ \\");
    System.out.println("		   | || / \\|| | //| |   | / \\|");
    System.out.println("		/\\_| || |-||| \\// | |_/\\| \\_/|");
    System.out.println("		\\____/\\_/ \\|\\__/  \\____/\\____/");
    System.out.println("");
    System.out.println("");

    /** JSTL Constant * */
    getServletContext().setAttribute("BACK_PARAM_NAME", ElementaryURLHelper.BACK_PARAM_NAME);

    try {
      DebugHelper.updateLoggerLevel(getServletContext());
    } catch (Exception e1) {
      logger.warning("error when update logger level : " + e1.getMessage());
      e1.printStackTrace();
    }

    StaticConfig staticConfig = StaticConfig.getInstance(getServletContext());

    writeInfo(System.out);

    DebugListening.staticConfig = staticConfig;

    if (staticConfig.isMailingThread()) {
      logger.info("start mailing thread.");
      mailingThread = new MailingThread(getServletContext());
      mailingThread.start();
    } else {
      logger.info("not start mailing thread for this instance");
    }

    threadManager = ThreadManager.getInstance(getServletContext());
    threadManager.setThreadDir(new File(staticConfig.getThreadFolder()));
    threadManager.start();

    try {
      SynchroThread.createInstance(staticConfig.getThreadFolder(), SynchroThread.class);
    } catch (InstantiationException e) {
      e.printStackTrace();
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    }

    if (staticConfig.getTempDir() != null) {
      System.setProperty("java.io.tmpdir", staticConfig.getTempDir());
    }

    MultiReadRequestWrapper.clearTempDir(getServletContext());
    TemplateFactory.copyDefaultTemplate(getServletContext());
  }
Пример #2
0
 @Override
 public void destroy() {
   Collection<GlobalContext> allGlobalContext = null;
   try {
     allGlobalContext = GlobalContextFactory.getAllGlobalContext(getServletContext());
   } catch (Exception ex) {
     ex.printStackTrace();
   }
   if (allGlobalContext != null) {
     for (GlobalContext globalContext : allGlobalContext) {
       globalContext.destroy();
     }
   }
   if (mailingThread != null) {
     mailingThread.stop = true;
     synchronized (mailingThread.stop) {
       try {
         mailingThread.stop.wait();
         logger.info("mailing thread stopped");
       } catch (InterruptedException e) {
         e.printStackTrace();
       }
     }
   }
   threadManager.stop = true;
   synchronized (threadManager.stop) {
     try {
       threadManager.stop.wait();
       logger.info("thread manager stopped");
     } catch (InterruptedException e) {
       e.printStackTrace();
     }
   }
   super.destroy();
   StaticConfig.getInstance(getServletContext()).shutdown();
 }