KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > workflow > timer > QuartzRunner


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 /*
6  * Created by IntelliJ IDEA.
7  * User: plightbo
8  * Date: May 22, 2002
9  * Time: 2:05:40 PM
10  */

11 package com.opensymphony.workflow.timer;
12
13 import org.quartz.Scheduler;
14 import org.quartz.SchedulerException;
15
16 import org.quartz.impl.StdSchedulerFactory;
17
18
19 /**
20  * To run:
21  *
22  */

23 public class QuartzRunner {
24     //~ Methods ////////////////////////////////////////////////////////////////
25

26     public static void main(String JavaDoc[] args) {
27         System.out.println("foo!");
28
29         try {
30             Scheduler s = new StdSchedulerFactory().getScheduler();
31             s.start();
32             Runtime.getRuntime().addShutdownHook(new Thread JavaDoc(new Shutdown JavaDoc(s)));
33         } catch (Exception JavaDoc e) {
34             e.printStackTrace();
35         }
36
37         System.out.println("foo!");
38     }
39 }
40
41
42 class Shutdown implements Runnable JavaDoc {
43     //~ Instance fields ////////////////////////////////////////////////////////
44

45     private Scheduler s;
46
47     //~ Constructors ///////////////////////////////////////////////////////////
48

49     public Shutdown(Scheduler s) {
50         this.s = s;
51     }
52
53     //~ Methods ////////////////////////////////////////////////////////////////
54

55     public void run() {
56         try {
57             System.out.println("Shutting down...");
58             s.shutdown();
59         } catch (SchedulerException e) {
60             e.printStackTrace();
61         }
62     }
63 }
64
Popular Tags