KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > applications > crontab > TestCronJob


1 /*
2  This software is OSI Certified Open Source Software.
3 OSI Certified is a certification mark of the Open Source Initiative.
4
5 The license (Mozilla version 1.0) can be read at the MMBase site.
6 See http://www.MMBase.org/license
7  */

8 package org.mmbase.applications.crontab;
9
10 import org.mmbase.bridge.*;
11 import org.mmbase.util.logging.*;
12
13 /**
14  * A test cron-job. Aquires a Cloud object, and sleeps vor 130 seconds (if you e.g. schedule it
15  * every minute, you test overlapping jobs: the job should not be restarted if still running)
16  */

17
18 public class TestCronJob extends AbstractCronJob implements CronJob {
19
20     private static final Logger log = Logging.getLoggerInstance(TestCronJob.class);
21
22     public void run() {
23         Cloud cloud = ContextProvider.getDefaultCloudContext().getCloud("mmbase", "class", null); // testing Class Security
24
//Cloud cloud = ContextProvider.getDefaultCloudContext().getCloud("mmbase", "anonymous", null);
25
log.info("found cloud " + cloud.getUser().getIdentifier() + "/" + cloud.getUser().getRank());
26         try {
27             log.info("sleeping");
28             Thread.sleep(130 * 1000);
29             log.info("sleeped");
30         } catch (Exception JavaDoc e) {}
31     }
32 }
33
Popular Tags