Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/opencms/core/CmsCronScheduleJobStarter.java


1   /*
2   * File   : $Source: /usr/local/cvs/opencms/src/com/opencms/core/Attic/CmsCronScheduleJobStarter.java,v $
3   * Date   : $Date: 2003/01/20 17:57:49 $
4   * Version: $Revision: 1.3 $
5   *
6   * This library is part of OpenCms -
7   * the Open Source Content Mananagement System
8   *
9   * Copyright (C) 2001  The OpenCms Group
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about OpenCms, please see the
22  * OpenCms Website: http://www.opencms.org
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with this library; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27  */
28  
29  package com.opencms.core;
30  
31  import com.opencms.boot.CmsBase;
32  import com.opencms.boot.I_CmsLogChannels;
33  
34  import java.util.Calendar;
35  
36  /**
37   * This class starts all needed jobs for the current time.
38   */
39  class CmsCronScheduleJobStarter extends Thread {
40  
41      /** The crontable to use */
42      private CmsCronTable m_table;
43  
44      /** The time of this run */
45      private Calendar m_thisRun;
46  
47      /** The time of the last run */
48      private Calendar m_lastRun;
49  
50      /** OpenCms to get access to the system */
51      private A_OpenCms m_opencms;
52  
53      /**
54       * Creates a new instance of CmsCronScheduleJobStarter.
55       * @param opencms to get access to A_OpenCms.
56       * @param table the CmsCronTable with all entries.
57       * @param thisRun the start time of this run.
58       * @param lastRun the last start time.
59       */
60      CmsCronScheduleJobStarter(A_OpenCms opencms, CmsCronTable table, Calendar thisRun, Calendar lastRun) {
61          m_table = table;
62          m_lastRun = lastRun;
63          m_thisRun = thisRun;
64          m_opencms = opencms;
65      }
66  
67      /**
68       * The run method of this thread tests all entries, if they should be started.
69       * If so it tries to start the entry via A_OpenCms.startScheduleJob()
70       */
71      public void run() {
72          for(int i = 0; i < m_table.size(); i++) {
73              if(m_table.get(i).check(m_lastRun, m_thisRun)) {
74                  // we have to start the job for this entry
75                  if(I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && CmsBase.isLogging()) {
76                      CmsBase.log(I_CmsLogChannels.C_OPENCMS_CRONSCHEDULER, "Starting job for " + m_table.get(i));
77                  }
78                  m_opencms.startScheduleJob(m_table.get(i));
79              }
80          }
81      }
82  }