⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tempfile.tmp

📁 this is example use EJB with jboss.
💻 TMP
字号:
/*
 * Copyright(C) 2008, NTT AT Co., Ltd.
 * Project: AWGView
 *
 * Notes:
 *  N/A
 *
 * Record of change:
 * Date         Version      Name       Content
 * 2008/01/20   1.0          TriNT      First create       
 */
package jp.co.ntt.awgview.server.thread;

import jp.co.ntt.awgview.server.AppMainServer;
import jp.co.ntt.awgview.server.common.LogWriter;
import jp.co.ntt.awgview.server.dao.DBFunctionsManager;
import jp.co.ntt.awgview.server.snmp.SnmpManager;

/**
 * Class name 	: ObjectFIFO <BR>
 * 
 * Package 		: jp.co.ntt_at.awgview.server.thread <BR>
 * 
 * Description	: Demonstrate adding a Shutdown Hook to the Runtime.
 * This class provides a way of trapping a shutdown of the virtual machine<BR>
 * 
 * @author 		: AI&T
 * @version 	: 1.0
 */
public class ShutdownHook extends Thread {
	/** Main thread that need to safety stop */	
	private Thread safeThread = null;
	
	/** Keep reference SnmpManager object to wake it up when shutdown */	
	private SnmpManager snmpManager = null;

	/**
	 * ShutdownHook <BR>	 * 
	 * @param   safeThread thread
	 * 
	 */	
	public ShutdownHook(Thread safeThread) {
		super();
		this.safeThread = safeThread;
	}

	/**
	 * setSnmpManagerProcess Setting Process <BR>
	 * @param  snmpManager
	 */	
	public void setSnmpManagerProcess(SnmpManager snmpManager) {
		this.snmpManager = snmpManager;
	}

	/**
	 * Running thread process to execute stop server<BR>
	 * 
	 */	
	public void run() {	
		
<<<<<<< .mine
		try {			
			DBFunctionsManager.closeAllConnection();
			LogWriter.getSNMPLogger().info("ShutdownHook: Close thread " +  safeThread.getName());
=======
		try {
>>>>>>> .r926
			LogWriter.getDBLogger().info("ShutdownHook: Close thread " +  safeThread.getName());
			if ( (this.snmpManager != null)) {				
				//Stop service				
				synchronized (this.snmpManager) {
					// Server will be stopped in snmpManager process					
					this.snmpManager.notify();
				}
				AppMainServer.shutDown();
			} else { 
				//** snmpManager process has not been start *//*
				LogWriter.getSNMPLogger().info("Execute stop server");
				AppMainServer.shutDown();
			}			
			safeThread.interrupt();
			LogWriter.getSNMPLogger().info("ShutdownHook: Closed thread " +  safeThread.getName());
		} catch (Exception e) {
			System.out.println("Error when execute stop server " + e.toString());
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -