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

📄 napletserverlog.java

📁 移动Agent编程工具Naplet
💻 JAVA
字号:
/* * @<#> NapletServerLog.java version 0.0.1, 1/1/2000 * * THIS PROGRAM IS FREE SOFTWARE; YOU CAN DISTRIBUTE IT AND/OR * MODIFY IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE  * AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION. * * THIS PROGRAM 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 GENERAL PUBLIC LICENSE FOR MORE DETAILS. * * Copyright (c) 2000-2002 Wayne State University. All Rights Reserved. */package naplet.server;import java.util.*;import java.net.*;import naplet.*;/** * The <code>NapletServerLog</code> class implements a naplet table within * a server. The table contains a vector of <code>FootPrint</code> * for each visiting naplet. Each footprint records  *   where-come-from/where-leave-for, arrival/departure time, ARRIVAL/DEPART  *  * @see NapletServerImpl * @version 0.0.1, 1/1/2000 * @author C. Xu */public class NapletServerLog {	private HashMap table; 	public NapletServerLog() {		table = new HashMap();	}		public synchronized void arrive( Naplet nap, InetAddress src) {		try {			register(nap.getNapletID(), new URN(src), new Date(), NapletEvent.ARRIVE);		} catch (InvalidURNException iue) {			throw new NapletInternalError( iue.getMessage() );		}	}	public synchronized void depart( Naplet nap, URN dest ) {		register(nap.getNapletID(), dest, new Date(), NapletEvent.DEPART);	}	/**	 * Check the visiting log of a naplet; return an ArrayList of footprints	 * @param nid Naplet in question 	 */ 	public synchronized ArrayList checkLog( NapletID nid) {		ArrayList fpList = null;		String key = nid.toString();		if (table.containsKey(key)) {			fpList = (ArrayList)table.get(key);		}		return fpList;	}	void register(NapletID nid, URN server, Date time, int event){       	try { 			String key = nid.toString();			FootPrint fp = new FootPrint(server, time, event);					/* Since a naplet may visit a server more than one time		 	* footprints of the naplet are stored in an ArrayList		 	*/			if (table.containsKey(key)) {				ArrayList footprints = (ArrayList) table.get(key);				footprints.add(fp);			} else {				ArrayList footprints = new ArrayList();				footprints.add(fp);				table.put(key, footprints);			}		} catch (InvalidEventException iee) {			throw new NapletInternalError( iee.getMessage() );		}	}                 }

⌨️ 快捷键说明

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