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

📄 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/12/15   1.0          TriNT      First create       
 */
package jp.co.ntt.awgview.server;

import java.io.IOException;

import javax.jms.JMSException;
import javax.naming.NamingException;

import jp.co.ntt.awgview.server.common.AlarmLevel;
import jp.co.ntt.awgview.server.common.AlarmType;
import jp.co.ntt.awgview.server.common.LogWriter;
import jp.co.ntt.awgview.server.common.Setting;
import jp.co.ntt.awgview.server.common.Utils;
import jp.co.ntt.awgview.server.constant.Constants;
import jp.co.ntt.awgview.server.jms.JMSManager;
import jp.co.ntt.awgview.server.snmp.SnmpManager;
import jp.co.ntt.awgview.server.thread.ThreadPoolManager;

/**
 * Class name : AppMain <BR>
 * 
 * Package : jp.co.ntt_at.awgview.server <BR>
 * 
 * Description: This class provides function to load configuration and start server application <BR>
 *
 * @author : AI&T
 * @version : 1.0
 */
public class AppMainServer {
	
	public static SnmpManager snmpManager = null;
		
	public static final String VERSION = "-version";
	
	public static final String HELP = "-help";		
	
	public static final String SHUTDOWN = "-shutdown";
	
	public static ThreadPoolManager threadPool = null;
	
	public static String JBOSS_HOME = null;
		
	/**
	 * Application main of AWG-View
	 * 
	 * @param args
	 */
	public static void main(String[] args) {	
		try {
			
			if ((args != null) && (args.length > 0)){
				if (args[0] != null) {
					if (VERSION.equalsIgnoreCase(args[0].trim())) {
						printVersion();
						System.exit(1);
					} else if (HELP.equalsIgnoreCase(args[0].trim())) {
						printHelp();
						System.exit(1);
					} else if (SHUTDOWN.equalsIgnoreCase(args[0].trim())) {
						shutDown();
					}
				}				
			}
			
			JBOSS_HOME = System.getenv("JBOSS_HOME");
			
			if (JBOSS_HOME == null){
				System.out.println("Make sure that JBOSS_HOME  is still defined in the environment");
				System.exit(0);
			}
<<<<<<< .mine
			
			LogWriter.getInstance().info("AWGView initialize ...");
			LogWriter.getInstance().info("Load configuration of application ...");
=======
>>>>>>> .r711
			
			LogWriter.getInstance(LogWriter.SNMP_LOG).info("AWGView initialize ...");
			LogWriter.getInstance(LogWriter.SNMP_LOG).info("Load configuration of application ...");
				
	
			if (!Setting.readConfig()){
				System.exit(0);
			}
			
			if (!AlarmLevel.loadAlarmLevel()){				
				System.exit(0);
			}
			
			if (!AlarmType.loadAlarmType()){			
				System.exit(0);
			}			

			snmpManager = new SnmpManager();			
			snmpManager.startTrapListener();
						
			LogWriter.getInstance(LogWriter.SNMP_LOG).info("Starting Trap Listener ...");			
			
			LogWriter.getInstance(LogWriter.SNMP_LOG).info("Starting lister SNMP command to Client ...");
			
			threadPool = new ThreadPoolManager(Constants.THREAD_POOL_NUMBER);
			
			JMSManager.startJMSManager();
			
			LogWriter.getInstance(LogWriter.SNMP_LOG).info("AWGView Applications is running");				
			
		} catch (NamingException e) {
			LogWriter.getInstance(LogWriter.SNMP_LOG).error("Can not start application");
			LogWriter.getInstance(LogWriter.SNMP_LOG).error(e.toString());
			
			shutDown();
			
			System.exit(0);
		} catch (JMSException e) {
			LogWriter.getInstance(LogWriter.SNMP_LOG).error("Can not start application");
			LogWriter.getInstance(LogWriter.SNMP_LOG).error(e.toString());
			
			if(LogWriter.getInstance(LogWriter.SNMP_LOG).isTraceEnabled()){
				LogWriter.getInstance(LogWriter.SNMP_LOG).trace(Utils.parseException(e));
			}
			
			shutDown();
			
			System.exit(0);
		} catch (IOException e) {			
			LogWriter.getInstance(LogWriter.SNMP_LOG).error("Can not start application");
			LogWriter.getInstance(LogWriter.SNMP_LOG).error(e.toString());
			
			if(LogWriter.getInstance(LogWriter.SNMP_LOG).isTraceEnabled()){
				LogWriter.getInstance(LogWriter.SNMP_LOG).trace(Utils.parseException(e));
			}
			shutDown();
			System.exit(0);
		} catch (Exception e) {
			LogWriter.getInstance(LogWriter.SNMP_LOG).error("Can not start application");
			LogWriter.getInstance(LogWriter.SNMP_LOG).error(e.toString());
			
			if(LogWriter.getInstance(LogWriter.SNMP_LOG).isTraceEnabled()){
				LogWriter.getInstance(LogWriter.SNMP_LOG).trace(Utils.parseException(e));
			}			
			
			shutDown();			
			System.exit(0);
		}
	}
	
	/**
	 * This is the function to print version of AWG-View project
	 */
	protected static void printVersion() {
		String pathConf = AppMainServer.JBOSS_HOME + Constants.VERSION_FILE;
		
		System.out.println(Utils.readFile2String(pathConf));
	}

	/**
	 * This is the function to print help of AWG-View project
	 */
	protected static void printHelp() {
		String pathConf = AppMainServer.JBOSS_HOME + Constants.HELP_FILE;
		System.out.println(Utils.readFile2String(pathConf));
	}
	
	/**
	 * Shutdown application to clean-up when the user shuts down application.
	 */
	public static void shutDown() {
		try{
			LogWriter.getInstance(LogWriter.SNMP_LOG).info("Shutdown application to clean-up when the user shuts down application");
			if (snmpManager != null){
				snmpManager.finalize();
			}
			
			JMSManager.stopJMSManager();
			
			snmpManager = null;
			
			LogWriter.getInstance(LogWriter.SNMP_LOG).info("AWGView shutdown");
		}catch (JMSException e){
			LogWriter.getInstance(LogWriter.SNMP_LOG).error("Error when closing application" + e.toString());
			if(LogWriter.getInstance(LogWriter.SNMP_LOG).isTraceEnabled()){
				LogWriter.getInstance(LogWriter.SNMP_LOG).trace(Utils.parseException(e));
			}
		}catch (Throwable e){
			LogWriter.getInstance(LogWriter.SNMP_LOG).error("Error when closing application" + e.toString());
			
			if(LogWriter.getInstance(LogWriter.SNMP_LOG).isTraceEnabled()){
				LogWriter.getInstance(LogWriter.SNMP_LOG).trace(Utils.parseException(e));
			}	
		}
	}
}

⌨️ 快捷键说明

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