1 5 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 23 public class QuartzRunner { 24 26 public static void main(String [] args) { 27 System.out.println("foo!"); 28 29 try { 30 Scheduler s = new StdSchedulerFactory().getScheduler(); 31 s.start(); 32 Runtime.getRuntime().addShutdownHook(new Thread (new Shutdown (s))); 33 } catch (Exception e) { 34 e.printStackTrace(); 35 } 36 37 System.out.println("foo!"); 38 } 39 } 40 41 42 class Shutdown implements Runnable { 43 45 private Scheduler s; 46 47 49 public Shutdown(Scheduler s) { 50 this.s = s; 51 } 52 53 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 |