KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quartz > examples > example10 > PlugInExample


1 /*
2  * Copyright 2005 OpenSymphony
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy
6  * of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations
14  * under the License.
15  *
16  */

17
18 package org.quartz.examples.example10;
19
20 import org.apache.commons.logging.Log;
21 import org.apache.commons.logging.LogFactory;
22 import org.quartz.Scheduler;
23 import org.quartz.SchedulerFactory;
24 import org.quartz.SchedulerMetaData;
25 import org.quartz.impl.StdSchedulerFactory;
26
27 /**
28  * This example will spawn a large number of jobs to run
29  *
30  * @author James House, Bill Kratzer
31  */

32 public class PlugInExample {
33
34     public void run() throws Exception JavaDoc {
35         Log log = LogFactory.getLog(PlugInExample.class);
36
37         // First we must get a reference to a scheduler
38
SchedulerFactory sf = new StdSchedulerFactory();
39         Scheduler sched = sf.getScheduler();
40
41         log.info("------- Initialization Complete -----------");
42
43         log.info("------- (Not Scheduling any Jobs - relying on XML definitions --");
44
45         log.info("------- Starting Scheduler ----------------");
46
47         // start the schedule
48
sched.start();
49
50         log.info("------- Started Scheduler -----------------");
51
52         log.info("------- Waiting five minutes... -----------");
53
54         // wait five minutes to give our jobs a chance to run
55
try {
56             Thread.sleep(300L * 1000L);
57         } catch (Exception JavaDoc e) {
58         }
59
60         // shut down the scheduler
61
log.info("------- Shutting Down ---------------------");
62         sched.shutdown(true);
63         log.info("------- Shutdown Complete -----------------");
64
65         SchedulerMetaData metaData = sched.getMetaData();
66         log.info("Executed " + metaData.numJobsExecuted() + " jobs.");
67     }
68
69     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
70
71         PlugInExample example = new PlugInExample();
72         example.run();
73     }
74
75 }
Popular Tags