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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? testeventpushsources.java

?? Java下Comet的實現框架Pushlet例子。 實現實時推送數據到客戶端。 服務器每隔30-500MS產生一個隨機數
?? JAVA
字號:
// 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 java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
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 TestEventPushSources {

	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 AEXStocksEventPushSource implements EventSource, Runnable {
		/**
		 * Here we get our stocks from.
		 */
		String pageURL = "http://www.debeurs.nl/koersen/aex.asp";
		Thread thread = null;
		volatile boolean active = false;

		// Since Baan has been thrown out...
		public final static int NR_OF_STOCKS = 24;
		
		static int a = 2;

		public final static String EMPTY = "wait...";
		private int restarts = 1;

		class Stock {
			public String name = EMPTY;
			public String rate = EMPTY;
			public String time = EMPTY;
			volatile public boolean modified = false;
		}

		Vector stocksCache = new Vector(NR_OF_STOCKS);

		public AEXStocksEventPushSource() {
			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();
			e("activated");
		}

		/**
		 * 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() {
			// Publish cache content (if any) first.
			publishStocks();

			int count = 5; // enforce update first
			while (active) {

				// Only do work if active
				// Update cache every 10 secs.
				if (count == 5) {
					updateCache();
					count = 0;
				}
				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(10000);
				} catch (InterruptedException ie) {
					break;
				}
			}

			// Loop terminated: reset vars
			thread = null;
			active = false;
		}

		
		protected String 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;
		}

		private void publishStocks() {
			// 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;
					try {
						Thread.sleep(400);
					} catch (InterruptedException ie) {
						return;
					}
				}
			}
		}

		private 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("publish: " + time);
			Dispatcher.getInstance().multicast(event);
		}

		

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

		private 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){
				e("wispy now handly setting Stock!   ----0----");
				Stock currentStock1 = (Stock) stocksCache.elementAt(0);
				currentStock1.name = "tnt";
				currentStock1.rate = a +"";
				currentStock1.time = new Date().toString();
				a++;
				currentStock1.modified = true;
				
				e("wispy now handly setting Stock!   ----1----");
				Stock currentStock2 = (Stock) stocksCache.elementAt(1);
				currentStock2.name = "ccccccc";
				currentStock2.rate = a +"";
				currentStock2.time = new Date().toString();
				a++;
				currentStock2.modified = true;
				
				e("wispy now handly setting Stock!   ----2----");
				Stock currentStock3 = (Stock) stocksCache.elementAt(2);
				currentStock3.name = "stock wyy";
				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;
//					}
//				}
//			}
		}
	}


	/**
	 * 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();
	}
}

/*
 * $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
 *
 *
 */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
另类小说综合欧美亚洲| 亚洲欧美国产高清| 国模冰冰炮一区二区| 久久亚洲春色中文字幕久久久| 日本美女一区二区| 精品福利视频一区二区三区| 国产永久精品大片wwwapp| 国产欧美日韩在线看| 99精品久久99久久久久| 亚洲成人动漫精品| 欧美大片在线观看| av欧美精品.com| 亚洲国产你懂的| 亚洲精品高清在线观看| 欧美日本免费一区二区三区| 日本va欧美va瓶| 中文字幕欧美三区| 在线免费视频一区二区| 美女被吸乳得到大胸91| 国产精品久久久久永久免费观看| 91麻豆国产精品久久| 日精品一区二区三区| 精品嫩草影院久久| 色哟哟日韩精品| 极品少妇一区二区| 亚洲综合一二区| 亚洲精品一区二区三区99| 99v久久综合狠狠综合久久| 日韩综合一区二区| 国产精品亲子伦对白| 欧美精品乱人伦久久久久久| 国产盗摄女厕一区二区三区| 亚洲国产综合视频在线观看| 国产亚洲精品资源在线26u| 欧美伦理电影网| 不卡av在线网| 极品少妇一区二区三区精品视频 | 99精品欧美一区二区蜜桃免费 | 秋霞影院一区二区| 国产三级一区二区三区| 欧美日韩精品一区二区在线播放| 国产高清久久久| 日本最新不卡在线| 亚洲综合激情另类小说区| 精品成人免费观看| 欧美亚洲高清一区二区三区不卡| 国产在线一区观看| 奇米综合一区二区三区精品视频| 亚洲视频香蕉人妖| 国产女同互慰高潮91漫画| 日韩一卡二卡三卡| 欧美日韩中字一区| 97久久人人超碰| 岛国一区二区三区| 国产精品资源网站| 久久国产精品99久久人人澡| 亚洲不卡一区二区三区| 一区二区三区四区中文字幕| 国产精品久久久久久久久免费丝袜| 欧美一二三区精品| 欧美人狂配大交3d怪物一区| 99精品久久99久久久久| av一区二区三区四区| www.亚洲国产| www.日本不卡| 丁香桃色午夜亚洲一区二区三区| 精品一二三四在线| 黄一区二区三区| 激情五月激情综合网| 麻豆成人综合网| 另类小说色综合网站| 琪琪久久久久日韩精品| 性久久久久久久| 日韩国产在线观看| 蜜桃精品视频在线| 精品一区中文字幕| 国产最新精品精品你懂的| 精品在线你懂的| 国产盗摄一区二区| 99国内精品久久| 色综合久久综合网| 欧美日韩精品是欧美日韩精品| 欧美日韩在线直播| 欧美一区二区在线免费观看| 欧美一区二区三区在线视频| 精品少妇一区二区三区在线视频| 2023国产精华国产精品| 久久久不卡网国产精品一区| 亚洲国产精品av| 亚洲免费成人av| 丝袜诱惑制服诱惑色一区在线观看 | 91久久国产综合久久| 欧美视频一区在线观看| 在线不卡的av| www日韩大片| 国产精品视频在线看| 亚洲精品老司机| 视频一区二区三区中文字幕| 久久国产精品一区二区| 成人做爰69片免费看网站| 在线观看日产精品| 欧美大片日本大片免费观看| 国产人成一区二区三区影院| 亚洲蜜臀av乱码久久精品蜜桃| 亚洲成国产人片在线观看| 老司机精品视频线观看86| 高清不卡一二三区| 欧美在线播放高清精品| 精品国产成人系列| 亚洲欧美另类小说视频| 久久精品国产亚洲高清剧情介绍 | 丁香一区二区三区| 在线观看av不卡| 日韩欧美国产wwwww| 欧美韩日一区二区三区| 日韩国产欧美在线观看| 成人综合日日夜夜| 日韩欧美一级片| 成人欧美一区二区三区小说| 秋霞午夜av一区二区三区| 成人一级片网址| 欧美一区二区三级| 亚洲精品久久嫩草网站秘色| 国产精品中文字幕日韩精品| 欧美日韩在线播放三区| 中文字幕av一区二区三区高| 视频在线在亚洲| 91麻豆精品一区二区三区| 欧美电影免费观看高清完整版在线观看| 国产精品久线在线观看| 久久国产精品99久久久久久老狼| 91香蕉视频mp4| 欧美精品一区视频| 日韩黄色免费网站| 色婷婷久久久亚洲一区二区三区| 久久久久久久久久电影| 男女性色大片免费观看一区二区| 色呦呦国产精品| 国产精品美女久久福利网站| 久久国产剧场电影| 91精品综合久久久久久| 樱桃国产成人精品视频| 成人午夜私人影院| 久久一夜天堂av一区二区三区| 五月天亚洲精品| 欧美性猛交一区二区三区精品| 中文字幕一区二区在线播放| 国产精品中文字幕一区二区三区| 欧美成人精品二区三区99精品| 午夜影院在线观看欧美| 欧美体内she精视频| 一区二区三区日韩精品| 99国产精品久久久久久久久久| 中文字幕第一区综合| 国产九色sp调教91| 精品欧美一区二区三区精品久久| 日韩电影在线观看电影| 欧美日本在线播放| 亚洲午夜久久久久久久久久久 | 日韩欧美高清dvd碟片| 亚洲一区在线视频| 91精彩视频在线| 夜夜揉揉日日人人青青一国产精品| 99精品欧美一区二区三区小说 | 欧美精品免费视频| 午夜激情一区二区三区| 欧美日本一区二区三区| 日韩av网站免费在线| 欧美一激情一区二区三区| 日韩av一二三| 久久这里只有精品6| 国产精品综合久久| 中文字幕乱码日本亚洲一区二区| 高清在线不卡av| 国产精品狼人久久影院观看方式| 波多野结衣在线一区| 亚洲天堂中文字幕| 在线观看日韩av先锋影音电影院| 香蕉久久夜色精品国产使用方法 | 91在线精品一区二区三区| 亚洲色图制服丝袜| 欧美日韩精品福利| 美女网站在线免费欧美精品| 日韩精品自拍偷拍| 成人性生交大合| 夜夜嗨av一区二区三区| 91精品国产品国语在线不卡| 经典三级在线一区| 综合久久久久久| 欧美精品vⅰdeose4hd| 毛片av中文字幕一区二区| 国产清纯美女被跳蛋高潮一区二区久久w | 国产麻豆精品一区二区| 日本一区二区成人| 欧美三级在线播放| 国产美女视频一区| 亚洲人成小说网站色在线| 欧美丰满少妇xxxbbb| 国产999精品久久久久久绿帽| 一区二区三区精品视频在线|