Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 17 18 21 package org.quartz.plugins.management; 22 23 import org.apache.commons.logging.Log; 24 import org.apache.commons.logging.LogFactory; 25 import org.quartz.Scheduler; 26 import org.quartz.SchedulerException; 27 import org.quartz.spi.SchedulerPlugin; 28 29 37 public class ShutdownHookPlugin implements SchedulerPlugin { 38 39 46 47 private String name; 48 49 private Scheduler scheduler; 50 51 private boolean cleanShutdown = true; 52 53 private final Log log = LogFactory.getLog(getClass()); 54 55 62 63 public ShutdownHookPlugin() { 64 } 65 66 73 74 84 public boolean isCleanShutdown() { 85 return cleanShutdown; 86 } 87 88 98 public void setCleanShutdown(boolean b) { 99 cleanShutdown = b; 100 } 101 102 protected Log getLog() { 103 return log; 104 } 105 106 113 114 123 public void initialize(String name, final Scheduler scheduler) 124 throws SchedulerException { 125 this.name = name; 126 this.scheduler = scheduler; 127 128 getLog().info("Registering Quartz shutdown hook."); 129 130 Thread t = new Thread ("Quartz Shutdown-Hook " 131 + scheduler.getSchedulerName()) { 132 public void run() { 133 getLog().info("Shutting down Quartz..."); 134 try { 135 scheduler.shutdown(isCleanShutdown()); 136 } catch (SchedulerException e) { 137 getLog().info( 138 "Error shutting down Quartz: " + e.getMessage(), e); 139 } 140 } 141 }; 142 143 Runtime.getRuntime().addShutdownHook(t); 144 } 145 146 public void start() { 147 } 149 150 157 public void shutdown() { 158 } 161 162 } 163 164
| Popular Tags
|