KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quartz > examples > example12 > RemoteServerExample


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.example12;
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  * @author Bill Kratzer
29  *
30  * TODO To change the template for this generated type comment go to Window -
31  * Preferences - Java - Code Style - Code Templates
32  */

33 public class RemoteServerExample {
34
35     /**
36      * This example will spawn a large number of jobs to run
37      *
38      * @author James House, Bill Kratzer
39      */

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