Source code: com/opencms/core/CmsCronScheduleJob.java
1 /*
2 * File : $Source: /usr/local/cvs/opencms/src/com/opencms/core/Attic/CmsCronScheduleJob.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 import com.opencms.file.CmsObject;
34 import com.opencms.util.Utils;
35
36 /**
37 * This thread launches one job in its own thread.
38 */
39 class CmsCronScheduleJob extends Thread {
40
41 /** The CmsObject to get access to the system */
42 private CmsObject m_cms;
43
44 /** The cron entry for this job */
45 private CmsCronEntry m_entry;
46
47 /**
48 * Creates a new CmsCronScheduleJob.
49 * @param cms the CmsObject with an logged in user.
50 * @poaram entry the entry to launch.
51 */
52 CmsCronScheduleJob(CmsObject cms, CmsCronEntry entry) {
53 m_cms = cms;
54 m_entry = entry;
55 }
56
57 /**
58 * The run method of this thread loads the module-class and launches the Method
59 * launch() on this module.
60 */
61 public void run() {
62 try {
63 // load the job class
64 Class module = getClass().getClassLoader().loadClass(m_entry.getModuleName());
65 // create an instance
66 I_CmsCronJob job = (I_CmsCronJob) module.newInstance();
67 // invoke method launch
68 String retValue = job.launch(m_cms, m_entry.getModuleParameter());
69 // log the returnvalue to the logfile
70 if(I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && CmsBase.isLogging()) {
71 CmsBase.log(I_CmsLogChannels.C_OPENCMS_CRONSCHEDULER, "Successful launch of job " + m_entry + (retValue != null ? " Message: " + retValue : "") );
72 }
73 } catch(Exception exc) {
74 // log the exception
75 if(I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && CmsBase.isLogging()) {
76 CmsBase.log(I_CmsLogChannels.C_OPENCMS_CRONSCHEDULER, "Error running job for " + m_entry + " Error: " + Utils.getStackTrace(exc));
77 }
78 }
79 }
80
81 }