src/org/objectweb/cjdbc/controller/core/shutdown/ControllerShutdownThread.java

説明を見る。
00001 00025 package org.objectweb.cjdbc.controller.core.shutdown; 00026 00027 import java.io.File; 00028 import java.util.ArrayList; 00029 00030 import org.objectweb.cjdbc.common.exceptions.ShutdownException; 00031 import org.objectweb.cjdbc.common.i18n.Translate; 00032 import org.objectweb.cjdbc.controller.core.Controller; 00033 import org.objectweb.cjdbc.controller.core.ControllerConstants; 00034 import org.objectweb.cjdbc.controller.core.ReportManager; 00035 import org.objectweb.cjdbc.controller.core.ControllerServerThread; 00036 import org.objectweb.cjdbc.controller.jmx.MBeanServerManager; 00037 import org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase; 00038 00048 public class ControllerShutdownThread extends ShutdownThread 00049 { 00050 private Controller controller; 00051 private ReportManager report; 00052 private boolean systemExit = true; 00053 00060 public ControllerShutdownThread(Controller controller, int ilevel) 00061 { 00062 super(ilevel, ShutdownThread.CONTROLLER, controller.getName()); 00063 this.controller = controller; 00064 this.report = controller.getReport(); 00065 } 00066 00070 public void shutdownImmediate() 00071 { 00072 shutdown(); 00073 } 00074 00075 protected void beforeShutdown() 00076 { 00077 if (report !=null && report.isGenerateOnShutdown()) 00078 { 00079 report.startReport(); 00080 } 00081 } 00082 00083 protected void shutdown() 00084 { 00085 logger.info("Shutting down controller"); 00086 logger.debug(Translate.get("controller.shutdown.post")); 00087 if (report !=null && report.isGenerateOnShutdown()) 00088 { 00089 report.generate(); 00090 logger.info(Translate.get("fatal.report.generated", report 00091 .getReportLocation() 00092 + File.separator + ControllerConstants.REPORT_FILE)); 00093 } 00094 if (systemExit) 00095 System.exit(0); 00096 } 00097 00101 public void shutdownSmart() throws ShutdownException 00102 { 00103 shutdownJmxAgent(); 00104 shutdownServerConnectionThread(); 00105 shutdownDatabases(this.getShutdownLevel()); 00106 shutdown(); 00107 } 00108 00112 public void shutdownFast() throws ShutdownException 00113 { 00114 shutdownJmxAgent(); 00115 shutdownServerConnectionThread(); 00116 shutdownDatabases(this.getShutdownLevel()); 00117 shutdown(); 00118 } 00119 00120 private void shutdownJmxAgent() 00121 { 00122 logger.info("Shutting down Jmx Agent"); 00123 try 00124 { 00125 if (controller.getJmxEnable()) 00126 MBeanServerManager.setJmxEnabled(false); 00127 } 00128 catch (Exception jme) 00129 { 00130 logger.error(Translate.get("controller.shutdown.jmx.error",jme.getMessage()),jme); 00131 //throw new ShutdownException(jme); 00132 } 00133 } 00134 00135 private void shutdownDatabases(int level) 00136 { 00137 logger.info("Shutting down databases"); 00138 try 00139 { 00140 //Shutdown each virtual database with proper level 00141 ArrayList listvb = controller.getVirtualDatabases(); 00142 int nbvb = listvb.size(); 00143 for (int i = 0; i < nbvb; i++) 00144 { 00145 logger.info("Shutting down database:"+((VirtualDatabase)listvb.get(i)).getName() + " with level:"+level); 00146 ((VirtualDatabase) listvb.get(i)).shutdown(level); 00147 logger.info("Database:"+((VirtualDatabase)listvb.get(i)).getName()+" is shutdown"); 00148 } 00149 } 00150 catch (Exception e) 00151 { 00152 logger.error(Translate.get("controller.shutdown.database.error",e)); 00153 } 00154 } 00155 00156 private void shutdownServerConnectionThread() throws ShutdownException 00157 { 00158 logger.info("Shutting down Connection thread"); 00159 try 00160 { 00161 // Shutdown Server Connections Thread 00162 ControllerServerThread thread = controller.getConnectionThread(); 00163 if (thread != null && !thread.isShuttingDown()) 00164 thread.shutdown(); 00165 } 00166 catch (Exception e) 00167 { 00168 throw new ShutdownException(e); 00169 } 00170 } 00171 00177 public void setSystemExit(boolean systemExit) 00178 { 00179 this.systemExit = systemExit; 00180 } 00181 }

CJDBCversion1.0.4に対してTue Oct 12 15:16:01 2004に生成されました。 doxygen 1.3.8