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