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

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

?? notificationchannelendpoint.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.rp.proxy;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

import org.fosstrak.reader.rprm.core.msg.notification.Notification;
import org.apache.log4j.Logger;

/**
 * The class provides the basic functionality to listen to notification messages from
 * a reader via TCP and notify registered listeners. It acts as a end point for a 
 * notification channel on a reader.
 * 
 * @author regli
 */
public class NotificationChannelEndPoint implements Runnable {

	/** the logger */
	private static Logger log = Logger.getLogger(NotificationChannelEndPoint.class);
	
	/** the thread */
	private final Thread thread;
	
	/** contains the subscribers of this NotificationChannelEndPoint */
	private final List<NotificationChannelListener> listeners = new Vector<NotificationChannelListener>();
	
	/** server socket to communicate with the reader's notification channel */
	private final ServerSocket ss;

	/**
	 * Constructor opens the server socket and starts the thread.
	 * 
	 * @param port on which the notification channel communicates
	 * @throws RPProxyException if server socket could not be created on specified port.
	 */
	public NotificationChannelEndPoint(int port) throws RPProxyException {
		
		try {
			ss = new ServerSocket(port);
		} catch (IOException e) {
			throw new RPProxyException(e.getMessage());
		}
		
		thread = new Thread(this);
		thread.start();
		
		try {
         context = JAXBContext
               .newInstance("org.fosstrak.reader.rprm.core.msg.notification");
         unmarshaller = context.createUnmarshaller();
      } catch (JAXBException e) {
         // failed, try at notifyListeners(...) call
      }
	}
	
	/**
	 * This mehtod adds a new subscriber to the list of listeners.
	 * 
	 * @param listener to add to this notification channel end point
	 */
	public void addListener(NotificationChannelListener listener) {
		
		listeners.add(listener);
		
	}
	
	/**
	 * This method removes a subscriber from the list of listeners.
	 * 
	 * @param listener to remove from this notification channel end point
	 */
	public void removeListener(NotificationChannelListener listener) {
		
		listeners.remove(listener);
		
	}
	
	/**
	 * This method contains the main loop of the thread, in which data is read from the socket
	 * and forwarded to the method notifyListeners().
	 */
	public void run() {
		
		try {
			while (true) {
				Socket s = ss.accept();
				BufferedReader reader = new BufferedReader(new InputStreamReader(s.getInputStream()));
				while (s.isConnected()) {
					StringBuffer data = new StringBuffer();
					String line = null;
					while (!reader.ready()) {
						try {
							Thread.sleep(100);
						} catch (InterruptedException e) {
						}
					}
					while (!"".equals(line) && reader.ready()) {
						line = reader.readLine();
						data.append(line);
					};
					log.debug("Incoming notification: " + data.substring(data.indexOf("<?xml")));
					notifyListeners(data);
				}
			}
		} catch (IOException e) {
		}
		
	}
	
	/**
	 * This method stops the thread and closes the socket
	 */
	public void stop() {
		
		// stop thread
		if (thread.isAlive()) {
			thread.interrupt();
		}
		
		// close socket
		try {
			ss.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	
	/**
	 * This method starts the notification channel end point for testing purposes.
	 * 
	 * @param args command line arguments, which can contain the port number. If the
	 * port number is not given port 9000 is used.
	 * @throws RPProxyException if something goes wrong while creating notification channel end point
	 */
	public static void main(String[] args) throws RPProxyException {
		
		int port = 9000;
		if (args.length == 1) {
			try {
				port = Integer.parseInt(args[0]);
			} catch (NumberFormatException e) {}
		}
		new Thread(new NotificationChannelEndPoint(port)).start();
		
	}
	
	//
	// private
	//
	
   /** the msg notification JAXBContext **/
   private JAXBContext context = null;
   
   /** the msg notification Unmarshaller **/
   private Unmarshaller unmarshaller = null;
   
	/**
	 * This method parses a received notification message and notifies all
	 * subscribers.
	 * 
	 * @param data string buffer with notification as string
	 */
	private void notifyListeners(StringBuffer data) {
		
		Notification notification = null;
		try {
         if (context == null) {
            context = JAXBContext
                  .newInstance("org.fosstrak.reader.rprm.core.msg.notification");
         }
         if (unmarshaller == null) {
            unmarshaller = context.createUnmarshaller();
         }
			notification = (Notification)unmarshaller.unmarshal(new ByteArrayInputStream(data.substring(data.indexOf("<?xml")).getBytes()));
			
			Iterator listenerIt = listeners.iterator();
			while (listenerIt.hasNext()) {
				((NotificationChannelListener)listenerIt.next()).dataReceived(notification);
			}
		
		} catch (JAXBException e) {
			e.printStackTrace();
		}
		
	}

}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区调教| 色吧成人激情小说| 一区二区三区四区视频精品免费 | 亚洲国产精品久久一线不卡| 日韩免费观看高清完整版| 99久久久国产精品免费蜜臀| 国产中文字幕精品| 午夜精品免费在线观看| 国产精品乱码妇女bbbb| 欧美一区二区女人| 欧美视频中文字幕| 99视频精品在线| 国产一区在线观看视频| 日本中文字幕不卡| 午夜在线成人av| 亚洲免费资源在线播放| 国产精品午夜久久| 久久影院午夜论| 精品美女一区二区| 91精品国产欧美一区二区18 | 国产美女一区二区| 卡一卡二国产精品 | 美女视频黄频大全不卡视频在线播放| 国产精品久久久久毛片软件| 2024国产精品视频| 精品乱码亚洲一区二区不卡| 9191久久久久久久久久久| 欧洲国内综合视频| 色八戒一区二区三区| 91免费看片在线观看| a美女胸又www黄视频久久| 国产精品系列在线观看| 国产福利一区在线观看| 国产福利电影一区二区三区| 麻豆高清免费国产一区| 蜜桃av一区二区| 青青草伊人久久| 久久激情五月婷婷| 久久国产精品色婷婷| 美女视频黄免费的久久 | 成人精品国产一区二区4080| 国产aⅴ综合色| 成人在线综合网站| 成人av网站免费观看| 成人av网站免费| 日本高清不卡视频| 欧美日韩国产不卡| 91精品国产综合久久香蕉的特点| 欧美高清www午色夜在线视频| 欧美高清一级片在线| 日韩视频在线观看一区二区| 精品国产乱码91久久久久久网站| 精品久久人人做人人爱| 久久香蕉国产线看观看99| 国产欧美精品一区| 亚洲色图欧美激情| 天堂午夜影视日韩欧美一区二区| 日韩电影在线观看电影| 国产一区欧美一区| 99久久综合色| 欧美日韩激情一区二区三区| 日韩欧美二区三区| 中日韩av电影| 一区二区三区.www| 理论电影国产精品| 福利一区福利二区| 欧美亚洲动漫另类| 26uuu精品一区二区| 国产精品卡一卡二| 亚洲成人自拍偷拍| 欧美吻胸吃奶大尺度电影| 欧美日韩国产一级| 久久久久久99久久久精品网站| 国产精品萝li| 亚洲一区视频在线| 韩国一区二区在线观看| 99久久99久久精品免费看蜜桃| 欧美性一级生活| 国产无人区一区二区三区| 夜夜精品浪潮av一区二区三区| 蜜臀久久99精品久久久久宅男| 丁香另类激情小说| 欧美挠脚心视频网站| 久久精品夜夜夜夜久久| 亚洲一区精品在线| 国产成人综合精品三级| 欧美午夜精品理论片a级按摩| 久久久不卡影院| 午夜精品爽啪视频| jizzjizzjizz欧美| 日韩免费观看2025年上映的电影 | 亚洲一区欧美一区| 国产精品77777| 欧美日韩国产欧美日美国产精品| 国产人妖乱国产精品人妖| 亚洲综合男人的天堂| 国产成人免费在线观看不卡| 欧美乱妇20p| 成人免费在线播放视频| 国产一区二区三区高清播放| 欧美精品tushy高清| 亚洲欧美日韩电影| 国产超碰在线一区| 欧美变态凌虐bdsm| 亚洲成av人在线观看| 一本一本久久a久久精品综合麻豆| 精品91自产拍在线观看一区| 天堂蜜桃一区二区三区 | 国产欧美一区二区精品婷婷| 日韩电影网1区2区| 欧美性感一类影片在线播放| 中文字幕一区二区三| 国产盗摄视频一区二区三区| 精品国产91亚洲一区二区三区婷婷| 亚洲一区在线免费观看| a美女胸又www黄视频久久| 久久久777精品电影网影网| 日本不卡视频在线| 欧美日韩免费一区二区三区| 亚洲免费毛片网站| aaa亚洲精品| 一区在线观看视频| 高清国产一区二区| 国产日韩欧美精品电影三级在线 | 欧美视频在线一区二区三区 | 91免费版pro下载短视频| 久久综合久久综合久久| 日本sm残虐另类| 51午夜精品国产| 日韩在线一二三区| 欧美精品免费视频| 日本成人中文字幕在线视频 | 精品日韩成人av| 久久精品国产亚洲一区二区三区| 欧美一级理论性理论a| 视频一区二区中文字幕| 9191久久久久久久久久久| 日韩不卡在线观看日韩不卡视频| 欧美日韩国产精品成人| 日本不卡一区二区三区 | 欧美午夜在线一二页| 亚洲一区二区三区爽爽爽爽爽| 97se亚洲国产综合自在线观| 国产精品黄色在线观看| 91蜜桃网址入口| 亚洲午夜精品一区二区三区他趣| 欧美日韩一二区| 日本vs亚洲vs韩国一区三区 | 国产精品成人在线观看| 色综合天天综合给合国产| 曰韩精品一区二区| 91麻豆精品国产自产在线| 免费成人小视频| 欧美激情一区二区| 91国产福利在线| 亚洲成a人片综合在线| 日韩无一区二区| 国产精品自拍一区| 中文字幕综合网| 欧美猛男gaygay网站| 久久99久久久欧美国产| 中文子幕无线码一区tr| 91成人国产精品| 日韩福利电影在线| 久久精品一区二区三区av| 在线看日韩精品电影| 久久国产精品色| 中文字幕欧美一区| 宅男噜噜噜66一区二区66| 国产精品影视网| 亚洲国产综合视频在线观看| 日韩欧美一区中文| 99国产精品视频免费观看| 午夜伦理一区二区| 国产日韩v精品一区二区| 欧美性一级生活| 国产99精品视频| 无码av免费一区二区三区试看| 久久网这里都是精品| 91黄色激情网站| 国产激情视频一区二区三区欧美| 亚洲与欧洲av电影| 久久久91精品国产一区二区三区| 在线观看av一区二区| 国产麻豆精品theporn| 亚洲国产日日夜夜| 国产性做久久久久久| 51精品国自产在线| 91一区二区在线| 国内精品写真在线观看| 亚洲最大的成人av| 欧美激情一区在线观看| 日韩三级视频中文字幕| 91视频在线观看| 国产成人自拍网| 精品一区二区精品| 亚洲高清久久久| 亚洲精选在线视频| 欧美经典一区二区三区| 精品国产乱码久久久久久图片|