1 23 24 package org.continuent.sequoia.controller.core.shutdown; 25 26 import java.util.Date ; 27 28 import org.continuent.sequoia.common.exceptions.ShutdownException; 29 import org.continuent.sequoia.common.i18n.Translate; 30 import org.continuent.sequoia.common.log.Trace; 31 32 40 public abstract class ShutdownThread implements Runnable  41 { 42 43 public ThreadGroup shutdownGroup = new ThreadGroup ("shutdown" + new Date ()); 44 45 protected int shutdownLevel; 46 47 48 Trace logger = Trace 49 .getLogger("org.continuent.sequoia.controller.shutdown"); 50 51 57 public ShutdownThread(int level) 58 { 59 this.shutdownLevel = level; 60 logger = Trace.getLogger("org.continuent.sequoia.controller.shutdown"); 61 } 62 63 68 public ThreadGroup getShutdownGroup() 69 { 70 return shutdownGroup; 71 } 72 73 78 public int getShutdownLevel() 79 { 80 return this.shutdownLevel; 81 } 82 83 88 public void run() 89 { 90 try 91 { 92 shutdown(); 93 } 94 catch (ShutdownException se) 95 { 96 se.printStackTrace(); 97 abortShutdown(se); 98 } 99 } 100 101 106 public void abortShutdown(Exception cause) 107 { 108 logger.info(Translate.get("controller.shutdown.aborted", cause)); 109 } 110 111 116 public abstract void shutdown() throws ShutdownException; 117 118 } | Popular Tags |