亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? messagelayer.java

?? 關(guān)于 RFID 讀寫器的相關(guān)內(nèi)容
?? JAVA
字號:
/*
 * Copyright (C) 2007 ETH Zurich
 *
 * This file is part of Fosstrak (www.fosstrak.org).
 *
 * Fosstrak is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1, as published by the Free Software Foundation.
 *
 * Fosstrak is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with Fosstrak; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301  USA
 */

package org.fosstrak.reader.rprm.core.msg;


import java.io.File;
import java.net.URL;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;


import org.fosstrak.reader.rprm.core.ReaderDevice;
import org.fosstrak.reader.rprm.core.ReaderProtocolException;
import org.fosstrak.reader.rprm.core.mgmt.agent.snmp.SnmpAgent;
import org.fosstrak.reader.rprm.core.mgmt.alarm.AlarmChannel;
import org.fosstrak.reader.rprm.core.mgmt.simulator.MgmtSimulator;
import org.fosstrak.reader.rprm.core.msg.transport.ConnectionThreadPool;
import org.fosstrak.reader.rprm.core.msg.transport.ServerConnection;
import org.fosstrak.reader.rprm.core.util.ResourceLocator;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;
import org.snmp4j.agent.io.ImportModes;

/**
 * MessageLayer is the main class. It instantiates the whole infrastructure.
 * After that, class <code>MessageDispatcher</code> and
 * <code>CommandDispatcher</code> are ready to execute commands on the reader.
 *
 * @author Patrice Oehen (poehen@student.ethz.ch)
 * @author Anna Wojtas, Marcel Bihr, Lukas Blunschi
 * @author Andreas F黵er, ETH Zurich, anfuerer@student.ethz.ch
 *
 */
public class MessageLayer {

	// ====================================================================
	// ---------------------------- Fields ------------------------------//
	// ====================================================================

	/** The logger. */
	private static Logger log = Logger.getLogger(MessageLayer.class);

	/** All connected <code>clients</code>. */
	private Clients clients = null;


	/**
	 * The time in ms that the reader waits for a notification connection in
	 * listen mode.
	 */
	private static int notificationListenTimeout;

	/** The single instance of the dispatcher. */
	private MessageDispatcher sDispatcher;

	/** The <code>IncomingMessageBuffer</code>. */
	private IncomingMessageBuffer mbuffer;

	/** The outgoing message dispatcher. */
	private OutgoingMessageDispatcher outDispatcher;

	/** The SNMP agent. */
	private SnmpAgent snmpAgent;

	/** The management agent's address */
	private String mgmtAgentAddress;

	/** The management agent's port */
	private int mgmtAgentPort;

	/** The management agent type (SNMP per default) */
	public static AgentType mgmtAgentType = AgentType.SNMP;

	/** Specifies whether the management simulator will be started */
	private boolean mgmtSimulatorStart;

	/** The management agent's properties file */
	private static final String mgmtAgentPropFile = ReaderDevice.PROPERTIES_FILE;
   private static final String mgmtAgentDefaultPropFile = ReaderDevice.DEFAULT_PROPERTIES_FILE;

	/** The agent type enum */
	public enum AgentType {
		SNMP
	}

	// ====================================================================
	// ------------------------- Constructor ----------------------------//
	// ====================================================================

	/**
	 * Creates a new Message Layer
	 */
	public MessageLayer() {
		DOMConfigurator.configure("./props/log4j.xml");
		//BasicConfigurator.configure();

		this.initialize();
	}

	// ====================================================================
	// ------------------------- Methods --------------------------------//
	// ====================================================================

	/**
	 * The main method.
	 *
	 * @param args
	 *            Not used
	 */
	public static void main(String[] args) {
		MessageLayer m = new MessageLayer();
	}

	/**
	 * Initializes the messaging layer and starts the reader device.
	 *
	 * @param reader reference to the ReaderDevice
	 */
	private void initialize() {
		log.debug("**************************************");
		log.debug("* MessageLayer is beeing initialized *");
		log.debug("**************************************");

		readMgmtAgentProperties(MessageLayer.mgmtAgentPropFile,
         MessageLayer.mgmtAgentDefaultPropFile);

		switch (MessageLayer.mgmtAgentType) {

			case SNMP:

				/*************************
				 *   create SNMP agent   *
				 *************************/

				String bootCounterFileName = "SnmpAgentBC.cfg";
				String configFileName = "SnmpAgentConfig.cfg";
				File bootCounterFile = new File(bootCounterFileName);
				File configFile = new File(configFileName);

				// delete the old files
				bootCounterFile.delete();
				configFile.delete();

				// create agent
				snmpAgent = SnmpAgent.create(bootCounterFile, configFile,
						mgmtAgentAddress + "/" + mgmtAgentPort);
				break;

			// case ...:

		}


		/*************************
		 *     MessageLayer      *
		 *************************/

		String connType;

		// sets the parameters according to the properties file
		try {
			Map serverConns = new HashMap();
			MessageLayerConfiguration conf = MessageLayerConfiguration.getInstance();

			try {
				ConnectionThreadPool.create(conf.getThreadPoolSize());

			} catch (NumberFormatException e) {
				log.error("Could not interpret the threadPoolSize from the property file. Please ensure to use a correct integer format.");
			}

			if (conf.hasTcpServerConnection()) {
				connType = ServerConnection.TCP_SERVER;
				try {
					int tcpPort = conf.getTcpPort();
					serverConns.put(connType, new Integer(tcpPort));
				} catch (NumberFormatException e) {
					log.error("Could not interpret the tcpPort from the property file. Please ensure to use a correct integer format.");
				}
			}

			if (conf.hasHttpServerConnection()) {
				connType = ServerConnection.HTTP_SERVER;
				try {
					int httpPort = conf.getHttpPort();
					serverConns.put(connType, new Integer(httpPort));
				} catch (NumberFormatException e) {
					log.error("Could not interpret the httpPort from the property file. Please ensure to use a correct integer format.");
				}
			}

			try {
				notificationListenTimeout = conf.getNotificationListenTimeout();
			} catch (NumberFormatException e) {
				log.error("Could not interpret the notificationListenTimeout from the property file. Please ensure to use a correct integer format.");
			}

			// create the message buffer
			log.debug("creating an IncomingMessageBuffer");
			mbuffer = IncomingMessageBuffer.getInstance();

			// create clients
			log.debug("creating Clients");
			clients = Clients.getInstance();

			// create the outgoing message dispatcher
			log.debug("creating an OutgoingMessageDispatcher");
			outDispatcher = OutgoingMessageDispatcher.getInstance();
			outDispatcher.initialize(clients);

			// create and init the service dispatcher
			log.debug("creating a ServiceDispatcher");
			sDispatcher = MessageDispatcher.getInstance(this);
			sDispatcher.initialize(mbuffer, clients, outDispatcher);
			sDispatcher.start();

			log.debug("creating ServiceConnection");
			Iterator iter = serverConns.keySet().iterator();

			while (iter.hasNext()) {
				String cType = (String) iter.next();
				ServerConnection.createServerConnection(cType,
						((Integer) serverConns.get(cType)).intValue(), mbuffer);
			}

			ReaderDevice readerDevice = ReaderDevice.getInstance();

			switch (MessageLayer.mgmtAgentType) {

				case SNMP:

					/*************************
					 * initialize SNMP agent *
					 *************************/

					snmpAgent.init();
					snmpAgent.loadConfig(ImportModes.UPDATE_CREATE);

					// We need to add the alarm channels again because at their
					// creation the SNMP agent was not initialized yet.
					Enumeration<AlarmChannel> alarmChanIter = readerDevice.getAlarmChannels().elements();
					while (alarmChanIter.hasMoreElements()) {
						snmpAgent.addAlarmChannels(new AlarmChannel[] { alarmChanIter.nextElement() });
					}

					snmpAgent.run();
					break;

				// case ...:

			}

			if (mgmtSimulatorStart) {
				MgmtSimulator inst = new MgmtSimulator(readerDevice);
				inst.setVisible(true);
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Resets the MessageLayer to the default values and restarts dispatching.
	 *
	 */
	public void reset() {
		/* TODO: Was ist genauer Semantik von reset?? Connections auch zumachen? */

		// Close all server connections
		List servers = ServerConnection.getServerConnections();
		for (Iterator it = servers.iterator(); it.hasNext();) {
			ServerConnection server = (ServerConnection) it.next();
			server.close();
		}

		// Reset all clients
		Clients clients = Clients.getInstance();
		clients.reset();

		// Reset all buffers and dispatchers
		sDispatcher.suspendThread();
		sDispatcher = null;

		mbuffer.clean();

		// Re-Initialize
		initialize();
	}

	/**
	 * The time in ms a server waits for a host to connect a notification
	 * connection in listen mode.
	 *
	 * @return The time in milliseconds.
	 */
	public static int getNotificationListenTimeout() {
		return notificationListenTimeout;
	}

	/**
	 * Gets the name of this class (e.g.,
	 * org.fosstrak.reader.msg.MessageLayer).
	 *
	 * @return The class name of this class
	 */
	public static String getClassname() {
		Class clazz = MessageLayer.class;
		return clazz.getName();
	}

	/**
	 * Gets the current CLASSPATH
	 *
	 * @return The CLASSPATH
	 */
	public static String getClasspath() {
		return System.getProperty("java.class.path");
	}

	/**
	 * Reads the management agent properties from a file.
	 *
	 * @param propFile
	 *            The properties file
	 * @throws ReaderProtocolException
	 */
	private void readMgmtAgentProperties(String propFile, String defaultPropFile) {
		XMLConfiguration conf;
      URL fileurl = ResourceLocator.getURL(propFile, defaultPropFile, this.getClass());
		try {
			conf = new XMLConfiguration(fileurl);
			MessageLayer.mgmtAgentType = AgentType.valueOf(conf.getString(
					"mgmtAgentType").toUpperCase());
			mgmtAgentAddress = conf.getString("mgmtAgentAddress");
			mgmtAgentPort = conf.getInt("mgmtAgentPort");
			mgmtSimulatorStart = conf.getBoolean("mgmtSimulatorStart");
		} catch (ConfigurationException e) {
			log.error("Failed to read the management agent information from "
					+ propFile + "\n -> Start default SNMP agent.");
			MessageLayer.mgmtAgentType = AgentType.SNMP;
		}
	}

}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人免费视频播放| 国产亚洲精品bt天堂精选| 色网站国产精品| 91亚洲永久精品| 欧美日韩国产美女| 91麻豆精品国产91久久久久久久久| av激情成人网| 日韩久久免费av| 国产精品视频九色porn| 樱桃视频在线观看一区| 免费人成在线不卡| 99精品视频在线观看| 欧美性做爰猛烈叫床潮| 26uuu久久综合| 伊人夜夜躁av伊人久久| 老司机精品视频线观看86| 国产成a人亚洲| 欧美一区二区三区视频免费播放 | 亚洲午夜激情网页| 国产在线精品不卡| 欧美日本国产视频| 欧美韩日一区二区三区四区| 日韩精品成人一区二区三区| 高清国产一区二区| 日韩精品一区在线观看| 亚洲精品免费一二三区| 成人91在线观看| 国产天堂亚洲国产碰碰| 日韩va亚洲va欧美va久久| 欧美最猛性xxxxx直播| 中文一区一区三区高中清不卡| 日本亚洲一区二区| 精品日韩成人av| 久久av资源网| 国产精品区一区二区三区| 国产精品自在欧美一区| 久久久久久久国产精品影院| 精品一区中文字幕| 国产精品美女视频| 色伊人久久综合中文字幕| 亚洲五月六月丁香激情| 欧美裸体一区二区三区| 免费的成人av| 亚洲色图另类专区| 欧美va亚洲va香蕉在线| 国产91露脸合集magnet| 亚洲国产一区二区在线播放| 欧美高清视频在线高清观看mv色露露十八| 亚洲国产wwwccc36天堂| 日韩欧美国产wwwww| 91在线视频网址| 久久精品国产99久久6| 亚洲女厕所小便bbb| 日韩午夜在线影院| 99国产精品久久久久久久久久 | 日日夜夜一区二区| 久久久久久夜精品精品免费| 色老头久久综合| 国产成人精品午夜视频免费 | 99久久99久久精品国产片果冻 | 亚洲视频一二区| 日韩一区二区在线观看| 欧美私人免费视频| 91麻豆自制传媒国产之光| 东方aⅴ免费观看久久av| 久久99日本精品| 久久99精品久久久久久国产越南 | 欧美一级精品大片| 欧美私人免费视频| 欧美日韩精品专区| 欧美日韩一区在线| 欧美精品国产精品| 欧美一区二区视频在线观看2022 | 北岛玲一区二区三区四区| 日韩精品一区二区三区在线播放| 亚洲二区视频在线| 欧美一区二区三区啪啪| 91丨九色丨尤物| 国产精品一区二区久久不卡| 美女一区二区视频| 国产成人免费av在线| 成人黄色777网| 日本丰满少妇一区二区三区| 国产精品66部| 91蜜桃网址入口| 日韩欧美在线123| 久久久久久久综合狠狠综合| 综合久久久久久| 日韩精品国产欧美| 狂野欧美性猛交blacked| 蜜桃精品视频在线观看| 丁香婷婷综合色啪| 色www精品视频在线观看| 欧美日韩国产在线观看| 日本一区二区不卡视频| 亚洲国产精品久久人人爱蜜臀| 日本午夜精品一区二区三区电影 | 美女网站色91| 欧美一区永久视频免费观看| 久久一区二区三区四区| 亚洲国产精品欧美一二99| 国内偷窥港台综合视频在线播放| 91视频国产资源| 国产精品丝袜黑色高跟| 亚洲综合无码一区二区| 91福利视频久久久久| 中文字幕免费观看一区| 久久国产精品99久久久久久老狼| 成人国产精品视频| 亚洲欧美在线视频观看| 国产精品1区2区3区在线观看| 精品嫩草影院久久| 国产成人精品免费一区二区| 日韩欧美第一区| 国内精品视频一区二区三区八戒 | 亚洲成人你懂的| 日韩欧美视频在线| 成人美女视频在线看| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆| 国产一区二区三区免费观看| 久久青草国产手机看片福利盒子| 国产剧情在线观看一区二区| 日本一区二区三区在线观看| 91看片淫黄大片一级在线观看| 国产精品视频在线看| 欧美亚洲尤物久久| 天堂成人免费av电影一区| 国产三级久久久| 欧美人成免费网站| 五月激情六月综合| 久久久777精品电影网影网 | 精品中文字幕一区二区小辣椒| 欧美日韩免费电影| 精品一区免费av| 亚洲第一激情av| 日本一区二区三区久久久久久久久不| 在线观看国产一区二区| 精品一区二区三区视频在线观看| 久久综合九色综合欧美98| 成人手机电影网| 风间由美性色一区二区三区| 亚洲第一搞黄网站| 一区二区三区国产精品| 久久久精品蜜桃| 欧美一级日韩免费不卡| 国产老肥熟一区二区三区| 日韩成人一区二区| 国产三级精品在线| 精品国产髙清在线看国产毛片| av中文字幕在线不卡| 99国产精品久| 色8久久人人97超碰香蕉987| av成人免费在线观看| 国产·精品毛片| 大尺度一区二区| 成人一二三区视频| 国产91在线|亚洲| av动漫一区二区| 一本久久综合亚洲鲁鲁五月天 | 亚洲一区二区三区在线看| 亚洲宅男天堂在线观看无病毒| 亚洲国产视频直播| 久久99精品久久只有精品| 国产成人精品一区二区三区四区| 粉嫩在线一区二区三区视频| 91视频免费播放| 亚洲国产成人在线| 亚洲曰韩产成在线| 中文字幕一区二区三区不卡在线| 国产精品久久久久一区| 怡红院av一区二区三区| 国产乱人伦精品一区二区在线观看 | 精品国产一区二区精华| 亚洲欧洲av在线| 亚洲国产成人porn| 北条麻妃国产九九精品视频| 日韩免费视频一区二区| 亚洲国产精品一区二区久久恐怖片| 美女www一区二区| 99国产精品国产精品久久| 久久久精品国产99久久精品芒果 | 精品久久久久久亚洲综合网| 中文字幕在线一区| 国产乱码精品一区二区三区av| 99久久99久久免费精品蜜臀| 久久久久久亚洲综合| 麻豆91精品视频| 国产日韩成人精品| 五月婷婷综合在线| 色偷偷成人一区二区三区91| 精品国产91亚洲一区二区三区婷婷| 一区二区三区欧美亚洲| 717成人午夜免费福利电影| 另类欧美日韩国产在线| 日韩精品专区在线影院重磅| 久久99日本精品| 国产精品久久久久久久久果冻传媒| 成人免费观看av| 国产精品不卡在线| 欧洲一区二区av|