Esempio n. 1
0
  @Override
  public void init(ServletConfig config) throws ServletException {

    try {

      // init file stream http server
      server = new JettyStreamServer(new FileSaveCallback());
      WebCenterContext.put(Constants.FILE_SERVER_PORT, server.getPort());

      // init WebCenterContext
      String dewHome = System.getenv("DEW_HOME");
      Map<String, String> conf = Files.loadPropertiesFile("/conf.properties.default");
      File confFile = new File(dewHome, "app.webcenter/conf.properties");
      if (confFile.exists()) {
        System.out.println("Load conf from " + confFile.getAbsolutePath());
        Map<String, String> userConf = Files.loadPropertiesFile(new FileInputStream(confFile));
        conf.putAll(userConf);
      }
      WebCenterContext.putConf(conf);

      try {
        dbExist();
      } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      // init cluster system performance data for home page
      CircleLink cl = CircleLink.getInstance();
      dstatApp = GroupMetricsApp.getInstance();
      dstatApp.startCollectCulsterDstat(cl, DSTAT_INTERVAL);

      // init quartz scheduler
      Timer timer = Timer.getInstance();
      DBOperator operator = new DBOperator();
      ArrayList<JobBean> jobs = operator.getAllJob();
      for (JobBean job : jobs) {
        try {
          timer.schedule(job.getName(), job.getCycle());
        } catch (Throwable e) {
          log.error(e.getMessage());
        }
      }
    } catch (Exception e) {
      log.error(e.getMessage());
    }
  }
Esempio n. 2
0
 @Override
 public void destroy() {
   server.shutDown();
   MyAppDriver.getMyAppDriver().stop();
 }