01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: /*
06: * Created by IntelliJ IDEA.
07: * User: plightbo
08: * Date: May 22, 2002
09: * 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: * To run:
20: *
21: */
22: public class QuartzRunner {
23: //~ Methods ////////////////////////////////////////////////////////////////
24:
25: public static void main(String[] args) {
26: System.out.println("foo!");
27:
28: try {
29: Scheduler s = new StdSchedulerFactory().getScheduler();
30: s.start();
31: Runtime.getRuntime().addShutdownHook(
32: new Thread(new Shutdown(s)));
33: } catch (Exception e) {
34: e.printStackTrace();
35: }
36:
37: System.out.println("foo!");
38: }
39: }
40:
41: class Shutdown implements Runnable {
42: //~ Instance fields ////////////////////////////////////////////////////////
43:
44: private Scheduler s;
45:
46: //~ Constructors ///////////////////////////////////////////////////////////
47:
48: public Shutdown(Scheduler s) {
49: this .s = s;
50: }
51:
52: //~ Methods ////////////////////////////////////////////////////////////////
53:
54: public void run() {
55: try {
56: System.out.println("Shutting down...");
57: s.shutdown();
58: } catch (SchedulerException e) {
59: e.printStackTrace();
60: }
61: }
62: }
|