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

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

?? testeventpushsources1.java

?? Java下Comet的實(shí)現(xiàn)框架Pushlet例子。 實(shí)現(xiàn)實(shí)時(shí)推送數(shù)據(jù)到客戶端。 服務(wù)器每隔30-500MS產(chǎn)生一個(gè)隨機(jī)數(shù)
?? JAVA
字號(hào):
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
// Distributable under LGPL license. See terms of license at gnu.org.

package nl.justobjects.pushlet.test;

import nl.justobjects.pushlet.core.Dispatcher;
import nl.justobjects.pushlet.core.Event;
import nl.justobjects.pushlet.core.EventSource;
import nl.justobjects.pushlet.util.Rand;

import hfut.wispy.webservice.GlobalSettings;

import java.util.Date;
import java.util.Vector;

/**
 * Event sources that push events (for testing).
 * 
 * @author Just van den Broecke - Just Objects &copy;
 * @version $Id: TestEventPushSources.java,v 1.10 2007/11/09 13:16:57 justb Exp $
 */
public class TestEventPushSources1 {

	static public class AEXStocksEventPushSourceABN {
		String pageURL = "http://ri2.rois.com/E36msPtnZC0e15CVb4KT97JAGfGSfCcrvv6*FcyZIoNyh/CTIB/RI2APISNAP?RIC=0%23.AEX&FORMAT=XML";
		// This could be further expanded: getting the Reuters AEX stocks
		// as XML from ABN with this URL, but we may get into legal problems...
	}

	/**
	 * Produces events from REAL stocks from the AEX.
	 */
	static public class AEXStocksEventPushSource1 implements EventSource,
			Runnable {
		/**
		 * Here we get our stocks from.
		 */
		Thread thread = null;

		volatile boolean active = false;

		// Since Baan has been thrown out...
		public final static int NR_OF_STOCKS = 5;

		static int a = 0;

		public static Date lastUpdateDate = new Date();

		public final static String EMPTY = "wait...";

		private int restarts = 1;

		public volatile static Vector<Stock> stocksCache = new Vector(
				NR_OF_STOCKS);

		static GlobalSettings globalSettings = GlobalSettings.getInstance();

		public AEXStocksEventPushSource1() {
			for (int i = 0; i < NR_OF_STOCKS; i++) {
				stocksCache.addElement(new Stock());
			}
			// updateCache();
		}

		/**
		 * Activate the event source.
		 */
		synchronized public void activate() {
			e("activating...");
			// Stop a possibly running thread
			stopThread();

			// Start new thread and
			thread = new Thread(this, "AEXStocksPublisher-" + (restarts++));
			active = true;
			thread.start();
			p("[---Thread---] : AEXStocksPublisher-" + restarts);
			e("activated");
		}

		synchronized public Thread getThread() {
			if (thread != null) {
				return thread;
			}
			return null;
		}

		/**
		 * Deactivate the event source.
		 */
		synchronized public void passivate() {
			e("passivating...");
			active = false;
			stopThread();

			// Mark the cache modified so we'll send the contents
			// on the next activation.
			// for (int i = 0; i < NR_OF_STOCKS; i++) {
			// ((Stock) stocksCache.elementAt(i)).modified = true;
			// }

			e("passivated");
		}

		/**
		 * Deactivate the event source.
		 */
		synchronized public void stop() {
		}

		public void run() {
			p("run()");
			// Publish cache content (if any) first.
			publishStocks();

			int count = 2; // enforce update first

			while (active) {
				this.thread.setPriority(Thread.MIN_PRIORITY);
				if (globalSettings.IsStartReader) {
					this.thread.setPriority(Thread.NORM_PRIORITY);
					// Only do work if active
					// Update cache every 10 secs.
					if (count % 2 == 0) {
						updateCache();
						Date now = new Date();
						p("lastUpdateDate : "
								+ (now.getTime() - lastUpdateDate.getTime() + "毫秒"));
						lastUpdateDate = now;
					}
					count++;

					// Do updates for changed stock rates
					publishStocks();

					// If we were interrupted just return.
					if (thread == null || thread.isInterrupted()) {
						break;
					}

					// Sleep 2 secs before sending next updates
					try {
						Thread.sleep(Rand.randomLong(500, 1500));
					} catch (InterruptedException ie) {
						break;
					}
				} else {
					try {
						Thread.sleep(2000);
					} catch (InterruptedException e) {
						// TODO 自動(dòng)生成 catch 塊
						e.printStackTrace();
					}
				}
			}
			// Loop terminated: reset vars
			thread = null;
			active = false;
		}

		//		

		private void publishStocks() {
			// p("sending updates");
			// Publish only modified stocks from the cache
			for (int i = 0; i < NR_OF_STOCKS; i++) {
				Stock nextStock = (Stock) stocksCache.elementAt(i);

				// Publish modified stocks
				if (nextStock.modified) {
					publishStock(i, nextStock.name, nextStock.rate,
							nextStock.time);
					nextStock.modified = false;
					// wispy no sleep test
					try {
						Thread.sleep(200);
					} catch (InterruptedException ie) {
						return;
					}
				}
			}
		}

		public void publishStock(int index, String name, String rate,
				String time) {
			Event event = Event.createDataEvent("/stocks/aexonlinewispy");
			event.setField("number", index + "");
			event.setField("name", name);
			event.setField("rate", rate);
			event.setField("time", time);
			// p("publish: nr=" + index + " name=" + name + " rate=" + rate);
			p("[sending updates]  --rate-- : " + rate);
			p("[sending updates]  --time-- : " + time);
			Dispatcher.getInstance().multicast(event);
		}

		private void stopThread() {
			if (thread != null) {
				thread.interrupt();
				thread = null;
			}
		}

		public static void updateCache(String name, String rate, String time) {
			e("");
			System.out.println("[updateCache]   ----" + "SWT" + "----");
			Stock currentStock1 = (Stock) stocksCache.elementAt(3);
			currentStock1.name = name;
			currentStock1.rate = rate;
			currentStock1.time = time;
			currentStock1.modified = true;
			e("");
		}

		public static void updateCache() {
			// p("updating Cache");

			// Get the line with all stocks from HTML page
			// String stocksLine = getStocksLine();
			// if ("".equals(stocksLine)) {
			// e("updateCache: stocksLine == null");

			if (true) {
				System.out.println("[updateCache]    ----" + a + "----");
				Stock currentStock1 = (Stock) stocksCache.elementAt(0);
				currentStock1.name = "tnt---111";
				currentStock1.rate = a + "";
				currentStock1.time = new Date().toString();
				a++;
				currentStock1.modified = true;

				System.out.println("[updateCache]   ----" + a + "----");
				Stock currentStock2 = (Stock) stocksCache.elementAt(1);
				currentStock2.name = "ccc---222";
				currentStock2.rate = a + "";
				currentStock2.time = new Date().toString();
				a++;
				currentStock2.modified = true;

				System.out.println("[updateCache]    ----" + a + "----");
				Stock currentStock3 = (Stock) stocksCache.elementAt(2);
				currentStock3.name = "wyy---333";
				currentStock3.rate = a + "";
				currentStock3.time = new Date().toString();
				a++;
				currentStock3.modified = true;

				return;
			}

			// Parse the stocksline and put in cache.
			// Beware: this is the messy part!!
			// We assume that stock/names and rates are located at
			// regular positions in the line.
			//			
			// String delim = "<>";
			// StringTokenizer st = new StringTokenizer(stocksLine, delim);
			// String nextToken = "";
			// int count = 0;
			// String nextStock = "";
			// String nextQuote = "";
			// String currentQuote = null;
			// int index = -1;
			// while (st.hasMoreTokens()) {
			// nextToken = st.nextToken();
			// count++;
			// // The <TD> with the stock name
			// if ((count - 5) % 57 == 0) {
			// p("c=" + count + " s=" + nextToken);
			// nextStock = nextToken;
			// }
			//
			// // The <TD> with the stock rate
			// if ((count - 10) % 57 == 0) {
			// nextQuote = nextToken;
			// index++;
			// p("c=" + count + " val=" + nextQuote);
			// Stock currentStock = (Stock) stocksCache.elementAt(index);
			//
			// // Only update new or modified stocks
			// if (EMPTY.equals(currentStock.rate) ||
			// !currentStock.rate.equals(nextQuote)) {
			// p("modified: " + nextStock);
			// currentStock.name = nextStock;
			// currentStock.rate = nextQuote;
			// currentStock.modified = true;
			// }
			// }
			// }
		}

		public boolean isActive() {
			return active;
		}

		public void setActive(boolean active) {
			this.active = active;
		}

		public static Vector getStocksCache() {
			return stocksCache;
		}

		public static void setStocksCache(Vector stocksCache) {
			AEXStocksEventPushSource1.stocksCache = stocksCache;
		}
	}

	/**
	 * Util: stderr print method.
	 */
	public static void e(String s) {
		System.out.println("AEXStocksEventPushSource: " + s);
	}

	/**
	 * Util: stdout print method.
	 */
	public static void p(String s) {
		System.out.println(s);
	}

	public static void main(String[] args) {
		// new TestEventPushSources$AEXStocksEventPushSource();
	}

	// private void sendUpdates() {
	// p("sending updates");
	// // In any case send a random stock value by
	// // making it modified, just to see something moving...
	// // int randomIndex = Rand.randomInt(0, NR_OF_STOCKS - 1);
	// // Stock randomStock = (Stock) stocksCache.elementAt(randomIndex);
	// // randomStock.modified = true;
	//
	// publishStocks();
	// }

	// private String getStocksLine() {
	// p("getStocksLine()");
	// BufferedReader br = null;
	// InputStream is = null;
	// String nextLine = "";
	//
	// // Read line from server
	// try {
	// is = new URL(pageURL).openStream();
	// br = new BufferedReader(new InputStreamReader(is));
	// boolean foundLine = false;
	// while (!foundLine) {
	// nextLine = br.readLine();
	// if (nextLine == null) {
	// return "";
	// }
	// foundLine = (nextLine.indexOf("details.asp?iid=14053&parent=aex") != -1);
	// }
	// } catch (Exception e) {
	// // e("could not open or read URL pageURL=" + pageURL + " ex=" + e);
	// return "";
	// } finally {
	// try {
	// if (is != null) is.close();
	// } catch (IOException ignore) {
	// }
	// }
	// return nextLine;
	// }
}

/*
 * $Log: TestEventPushSources.java,v $ Revision 1.10 2007/11/09 13:16:57 justb
 * use Rand from util package (and and Rand.java to pushlet client jar
 * 
 * Revision 1.9 2005/02/28 09:14:56 justb sessmgr/dispatcher factory/singleton
 * support
 * 
 * Revision 1.8 2005/02/21 16:59:17 justb SessionManager and session lease
 * introduced
 * 
 * Revision 1.7 2005/02/18 10:07:23 justb many renamings of classes (make names
 * compact)
 * 
 * Revision 1.6 2005/02/18 09:54:15 justb refactor: rename Publisher Dispatcher
 * and single Subscriber class
 * 
 * Revision 1.5 2004/09/03 22:35:37 justb Almost complete rewrite, just checking
 * in now
 * 
 * Revision 1.4 2004/03/10 15:45:55 justb many cosmetic changes
 * 
 * Revision 1.3 2003/08/15 08:37:41 justb fix/add Copyright+LGPL file headers
 * and footers
 * 
 * Revision 1.2 2003/05/18 16:15:08 justb support for XML encoded Events
 * 
 * Revision 1.1.1.1 2002/09/24 21:02:33 justb import to sourceforge
 * 
 * Revision 1.1.1.1 2002/09/20 22:48:20 justb import to SF
 * 
 * Revision 1.1.1.1 2002/09/20 14:19:02 justb first import into SF
 * 
 * Revision 1.6 2001/02/18 23:45:13 just fixes for AEX
 * 
 * Revision 1.5 2000/10/30 14:16:09 just no message
 * 
 * Revision 1.4 2000/09/24 21:02:43 just chnages due to changed webpage in
 * debeurs.nl
 * 
 * Revision 1.3 2000/08/31 12:49:50 just added CVS comment tags for log and
 * copyright
 * 
 * 
 */

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品婷婷国产综合久久性色| 久久综合九色综合97_久久久| 久久精品国产精品亚洲精品 | 99精品欧美一区二区蜜桃免费| 亚洲777理论| 日本一区二区电影| 91精品久久久久久久91蜜桃| 国产a精品视频| 奇米影视一区二区三区| 亚洲免费在线视频| 国产欧美精品一区| 日韩一区二区三区视频在线观看 | 99久久免费精品高清特色大片| 日本免费新一区视频| 亚洲欧美激情在线| 国产午夜精品一区二区三区嫩草| 欧美男男青年gay1069videost| youjizz国产精品| 国产成人在线影院| 激情偷乱视频一区二区三区| 亚洲成人av在线电影| 亚洲人成伊人成综合网小说| 国产精品日产欧美久久久久| 欧美精品一区男女天堂| 日韩一区二区三区观看| 欧美日韩美女一区二区| 91传媒视频在线播放| 99视频精品全部免费在线| 国产精品88888| 国产伦理精品不卡| 国产精品一区2区| 国产一区二区三区黄视频 | 岛国一区二区在线观看| 久久99热99| 国内精品免费在线观看| 蜜臀av国产精品久久久久| 婷婷六月综合亚洲| 亚洲高清不卡在线| 一区二区三区国产精品| 亚洲综合色区另类av| 亚洲国产日日夜夜| 亚洲v中文字幕| 日韩精品一区第一页| 天堂va蜜桃一区二区三区漫画版| 亚洲国产视频a| 视频一区二区中文字幕| 婷婷综合在线观看| 美女网站一区二区| 久久不见久久见免费视频1| 国内外成人在线| 岛国精品在线播放| 91亚洲国产成人精品一区二三| av一二三不卡影片| 日本久久精品电影| 欧美亚洲国产bt| 欧美精选午夜久久久乱码6080| 欧美嫩在线观看| 日韩一区二区在线免费观看| 久久综合丝袜日本网| 欧美精彩视频一区二区三区| 综合av第一页| 日韩精品成人一区二区三区| 久久国产麻豆精品| 国产精品一二三四区| jizz一区二区| 欧美日韩一区二区三区不卡| 欧美一区永久视频免费观看| 精品国产免费一区二区三区四区 | 久久久久久一级片| 自拍偷拍国产精品| 午夜私人影院久久久久| 久久97超碰国产精品超碰| 不卡的看片网站| 欧美精品色综合| 国产清纯美女被跳蛋高潮一区二区久久w| 国产精品午夜久久| 亚洲一区二三区| 精品一区二区三区在线播放视频 | 欧美日韩性生活| 久久综合999| 亚洲精品视频免费看| 免费在线成人网| 不卡欧美aaaaa| 91精品国产综合久久久久久久久久 | 中文字幕av一区二区三区| 中文字幕av资源一区| 亚洲妇女屁股眼交7| 国产福利一区二区三区视频| 色婷婷综合在线| 久久久久亚洲综合| 亚洲超碰97人人做人人爱| 国产成a人亚洲| 这里只有精品电影| 亚洲欧美影音先锋| 久久se这里有精品| 欧美午夜精品电影| 国产精品天干天干在观线| 日韩制服丝袜av| 91免费版在线看| 久久精品亚洲乱码伦伦中文| 亚洲一区二区三区自拍| 成人一级片网址| 日韩欧美的一区| 一区二区三区四区av| 国产精品一区二区三区四区| 欧美另类高清zo欧美| 1024国产精品| 国产很黄免费观看久久| 欧美高清你懂得| 亚洲精品日韩一| 国产成人av在线影院| 日韩一区二区电影在线| 亚洲国产日韩精品| 99久久久国产精品| 久久免费偷拍视频| 久久99精品久久久久久国产越南| 欧美视频在线一区| 亚洲婷婷在线视频| 成人福利电影精品一区二区在线观看| 91精品国产丝袜白色高跟鞋| 亚洲一区二区三区视频在线播放 | 亚洲精品va在线观看| 波多野结衣亚洲一区| 久久毛片高清国产| 精品一区二区三区日韩| 宅男噜噜噜66一区二区66| 亚洲一区二区三区四区的| 91美女在线观看| 亚洲人成精品久久久久久| 不卡电影一区二区三区| 国产精品欧美精品| 成人精品免费网站| 国产欧美日韩在线| 不卡一卡二卡三乱码免费网站| 久久久久久久网| 国产精品综合av一区二区国产馆| 日韩欧美国产一区在线观看| 免费看日韩精品| 亚洲精品一区二区三区蜜桃下载 | 美女脱光内衣内裤视频久久影院| 欧美伦理视频网站| 日韩av不卡一区二区| 91精品视频网| 久久99久久99| 国产亚洲va综合人人澡精品 | 美日韩一区二区| 日韩欧美卡一卡二| 国产乱码精品一区二区三区忘忧草 | 亚洲视频图片小说| 色伊人久久综合中文字幕| 亚洲人成网站精品片在线观看| 91片在线免费观看| 亚洲一二三区在线观看| 在线综合亚洲欧美在线视频| 激情综合网激情| 国产精品天美传媒| 91精品福利视频| 午夜精品一区二区三区电影天堂| 91精品免费在线| 国产精一品亚洲二区在线视频| 欧美国产1区2区| 日本韩国欧美在线| 久久精品免费看| 国产精品色在线| 在线观看欧美精品| 久久激情五月婷婷| 中文字幕在线播放不卡一区| 欧美日韩中文另类| 精品一区二区三区香蕉蜜桃| 日本一区二区免费在线观看视频| 色系网站成人免费| 久久不见久久见免费视频1| 欧美国产97人人爽人人喊| 欧美体内she精高潮| 极品少妇xxxx精品少妇| 成人免费在线视频| 日韩欧美在线1卡| a4yy欧美一区二区三区| 日韩中文字幕麻豆| 国产欧美日韩精品a在线观看| 在线观看日韩av先锋影音电影院| 久久国产夜色精品鲁鲁99| 综合亚洲深深色噜噜狠狠网站| 欧美一区二区网站| heyzo一本久久综合| 免费成人av资源网| 亚洲黄色片在线观看| 欧美精品一区二区三| 欧日韩精品视频| 粉嫩13p一区二区三区| 首页亚洲欧美制服丝腿| 成人欧美一区二区三区| 精品国产一区二区三区忘忧草 | 91精品国产aⅴ一区二区| jiyouzz国产精品久久| 蜜乳av一区二区三区| 一片黄亚洲嫩模| 国产精品久久三| 久久蜜桃香蕉精品一区二区三区| 欧美午夜影院一区|