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

📄 request.java

📁 Java Communicating Agents是一个用于开发网络反应式信息agent的框架
💻 JAVA
字号:
/* * $Source: /home/data/cvsroot/src/jacomma/icm/type/Request.java,v $ * $Revision: 1.5 $ * $Date: 2000/10/28 20:09:07 $ * * This file is part of the jacomma framework * Copyright (c) 2000 	Dimitrios Vyzovitis *			mailto:dviz@egnatia.ee.auth.gr *			 * *			 *			 *			 * *	This library is free software; you can redistribute it and/or modify *	it under the terms of the GNU Library General Public License as published by *	the Free Software Foundation; either version 2 of the License, or *	(at your option) any later version. * *	This library 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 Library General Public License for more details. * *	You should have received a copy of the GNU Library General Public License *	along with this library; if not, write to the Free Software *	Foundation, Inc., 59 Temple Place, Suite 330,  *	Boston, MA  02111-1307  USA */package jacomma.icm.type;import jacomma.icm.io.ObjectEncoder;import jacomma.icm.io.EncObjectDecoder;import jacomma.util.Environment;import java.util.List;import java.util.ArrayList;import java.util.Map;import java.util.Date;import java.util.HashMap;import java.net.InetAddress;/** * TBA **/public final class Request {		// Request types	public static final Symbol icmRegisterAgent = new Symbol( "icmRegisterAgent" );	public static final Symbol icmDeregisterAgent = new Symbol( "icmDeregisterAgent" );	public static final Symbol icmDetachAgent = new Symbol( "icmDetachAgent" );	public static final Symbol icmAttachAgent = new Symbol( "icmAttachAgent" );	public static final Symbol icmDisconnect = new Symbol( "icmDisconnect" );	public static final Symbol icmReconnect = new Symbol( "icmReconnect" );	public static final Symbol icmMonitorAgent = new Symbol( "icmMonitorAgent" );	public static final Symbol icmUnMonitorAgent = new Symbol( "icmUnMonitorAgent" );	public static final Symbol icmRequestForwarding = new Symbol( "icmRequestForwarding" );	public static final Symbol icmCancelForwarding = new Symbol( "icmCancelForwarding" );	public static final Symbol icmLookupLocation = new Symbol( "icmLookupLocation" );	public static final Symbol icmPingAgent = new Symbol( "icmPingAgent" );	public static final Symbol icmListAgents = new Symbol( "icmListAgents" );		// parameters	public static final Symbol icmLeaseTime = new Symbol( "icmLeaseTime" );		// Request Responses	public static final Symbol icmOk = new Symbol( "icmOk" );	public static final Symbol icmFailed = new Symbol( "icmFailed" );	// cs	public static final String icmCommServer = "icmCommServer";	public static final Handle commServer = Handle.createHandle( icmCommServer );	public static Handle commServerAt( InetAddress host ) {		return Handle.createHandle( icmCommServer, host );	}		public static Message createRegisterRequest( Handle h ) {		return _createRequest( h, commServer,  new Object[]{icmRegisterAgent, h, new HashMap()} );	}		public static Message createRegisterRequest( Handle h, InetAddress host ) {		return _createRequest( h, commServerAt( host ),  							   new Object[]{icmRegisterAgent, h, new HashMap()} );	}		public static Message createRegisterRequest( Handle h, Date lt ) {		Map map = new HashMap();		map.put( icmLeaseTime, new Integer( (int)(lt.getTime() / 100L) ) );		return _createRequest( h, commServer,  							   new Object[]{icmRegisterAgent, h, map} );	}	public static Message createRegisterRequest( Handle h, InetAddress host, Date lt ) {		Map map = new HashMap();		map.put( icmLeaseTime, new Integer( (int)(lt.getTime() / 100L) ) );		return _createRequest( h, commServerAt( host ),  							   new Object[]{icmRegisterAgent, h, map} );	}		public static Message createRegisterRequest( Handle from, Handle h ) {		return _createRequest( from, commServer,  new Object[]{icmRegisterAgent, h, new HashMap()} );	}		public static Message createRegisterRequest( Handle from, Handle h, InetAddress host ) {		return _createRequest( from, commServerAt( host ),  							   new Object[]{icmRegisterAgent, h, new HashMap()} );	}		public static Message createRegisterRequest( Handle from, Handle h, Date lt ) {		Map map = new HashMap();		map.put( icmLeaseTime, new Integer( (int)(lt.getTime() / 100L) ) );		return _createRequest( from, commServer,  							   new Object[]{icmRegisterAgent, h, map} );	}	public static Message createRegisterRequest( Handle from, Handle h, 												 InetAddress host, Date lt ) {		Map map = new HashMap();		map.put( icmLeaseTime, new Integer( (int)(lt.getTime() / 100L) ) );		return _createRequest( from, commServerAt( host ),  							   new Object[]{icmRegisterAgent, h, map} );	}		public static Message createDeregisterRequest( Handle h ) {		return _createRequest( h, commServer,  							   new Object[]{icmDeregisterAgent, h} );	}	public static Message createDeregisterRequest( Handle h, InetAddress host ) {		return _createRequest( h, commServerAt( host ),  							   new Object[]{icmDeregisterAgent, h} );	}		public static Message createDeregisterRequest( Handle from, Handle h ) {		return _createRequest( from, commServer,  							   new Object[]{icmDeregisterAgent, h} );	}	public static Message createDeregisterRequest( Handle from, Handle h, 												   InetAddress host ) {		return _createRequest( from, commServerAt( host ),  							   new Object[]{icmDeregisterAgent, h} );	}	public static Message createDeregisterRequest( Handle from, Handle h, 												   Handle cs ) {		return _createRequest( from, cs,  							   new Object[]{icmDeregisterAgent, h} );	}	public static Message createDetachRequest( Handle h ) {		return _createRequest( h, commServer,  							   new Object[]{icmDetachAgent, h} );	}		public static Message createDetachRequest( Handle h, InetAddress host ) {		return _createRequest( h, commServerAt( host ),  							   new Object[]{icmDetachAgent, h} );	}	public static Message createDetachRequest( Handle from, Handle h ) {		return _createRequest( from, commServer,  							   new Object[]{icmDetachAgent, h} );	}		public static Message createDetachRequest( Handle from, Handle h, InetAddress host ) {		return _createRequest( from, commServerAt( host ),  							   new Object[]{icmDetachAgent, h} );	}	public static Message createDetachRequest( Handle from, Handle h, Handle cs ) {		return _createRequest( from, cs,  							   new Object[]{icmDetachAgent, h} );	}		public static Message createAttachRequest( Handle h ) {		return _createRequest( h, commServer,  new Object[]{icmAttachAgent, h, new HashMap()} );	}		public static Message createAttachRequest( Handle h, InetAddress host ) {		return _createRequest( h, commServerAt( host ),  							   new Object[]{icmAttachAgent, h, new HashMap()} );	}		public static Message createAttachRequest( Handle h, Date lt ) {		Map map = new HashMap();		map.put( icmLeaseTime, new Integer( (int)(lt.getTime() / 100L) ) );		return _createRequest( h, commServer,  							   new Object[]{icmAttachAgent, h, map} );	}	public static Message createAttachRequest( Handle h, InetAddress host, Date lt ) {		Map map = new HashMap();		map.put( icmLeaseTime, new Integer( (int)(lt.getTime() / 100L) ) );		return _createRequest( h, commServerAt( host ),  							   new Object[]{icmAttachAgent, h, map} );	}		public static Message createAttachRequest( Handle from, Handle h ) {		return _createRequest( from, commServer,  new Object[]{icmAttachAgent, h, new HashMap()} );	}		public static Message createAttachRequest( Handle from, Handle h, InetAddress host ) {		return _createRequest( from, commServerAt( host ),  							   new Object[]{icmAttachAgent, h, new HashMap()} );	}		public static Message createAttachRequest( Handle from, Handle h, Handle cs ) {		return _createRequest( from, cs,  							   new Object[]{icmAttachAgent, h, new HashMap()} );	}		public static Message createAttachRequest( Handle from, Handle h, Date lt ) {		Map map = new HashMap();		map.put( icmLeaseTime, new Integer( (int)(lt.getTime() / 100L) ) );		return _createRequest( from, commServer,  							   new Object[]{icmAttachAgent, h, map} );	}	public static Message createAttachRequest( Handle from, Handle h, InetAddress host, Date lt ) {		Map map = new HashMap();		map.put( icmLeaseTime, new Integer( (int)(lt.getTime() / 100L) ) );		return _createRequest( from, commServerAt( host ),  							   new Object[]{icmAttachAgent, h, map} );	}		public static Message createAttachRequest( Handle from, Handle h, Handle cs, Date lt ) {		Map map = new HashMap();		map.put( icmLeaseTime, new Integer( (int)(lt.getTime() / 100L) ) );		return _createRequest( from, cs,  							   new Object[]{icmAttachAgent, h, map} );	}		public static Message createDisconnectRequest( Handle h ) {		return _createRequest( h, commServer,  icmDisconnect );	}	public static Message createDisconnectRequest( Handle h, InetAddress host ) {		return _createRequest( h, commServerAt( host ), 							   icmDisconnect );	}		public static Message createReconnectRequest( Handle h, Integer tag ) {		return _createRequest( h, commServer,  new Object[]{icmReconnect, tag} );	}	public static Message createReconnectRequest( Handle h, InetAddress host, Integer tag ) {		return _createRequest( h, commServerAt( host ),  							   new Object[]{icmReconnect, tag} );	}		public static Message createMonitorRequest( Handle h, Handle target ) {		return _createRequest( h, commServer,  							   new Object[]{icmMonitorAgent, target} );	}		public static Message createMonitorRequest( Handle h, Handle target, InetAddress host ) {		return _createRequest( h, commServerAt( host ),  							   new Object[]{icmMonitorAgent, target} );	}		public static Message createMonitorRequest( Handle h, Handle target, Handle cs ) {		return _createRequest( h, cs,  							   new Object[]{icmMonitorAgent, target} );	}		public static Message createUnMonitorRequest( Handle h, Handle target ) {		return _createRequest( h, commServer,  							   new Object[]{icmUnMonitorAgent, target} );	}	public static Message createUnMonitorRequest( Handle h, Handle target, 												  InetAddress host ) {		return _createRequest( h, commServerAt( host ),  							   new Object[]{icmUnMonitorAgent, target} );	}	public static Message createUnMonitorRequest( Handle h, Handle target, 												  Handle cs ) {		return _createRequest( h, cs,  							   new Object[]{icmUnMonitorAgent, target} );	}	public static Message createForwardRequest( Handle h, Handle to ) {		return _createRequest( h, commServer,  							   new Object[]{icmRequestForwarding, to} );	}		public static Message createForwardRequest( Handle h, Handle to, InetAddress host ) {		return _createRequest( h, commServerAt( host ),  							   new Object[]{icmRequestForwarding, to} );	}		public static Message createForwardRequest( Handle from, Handle h, Handle to ) {		return _createRequest( from, commServer,  							   new Object[]{icmRequestForwarding, to} );	}		public static Message createForwardRequest( Handle from, Handle h, Handle to, InetAddress host ) {		return _createRequest( from, commServerAt( host ),  							   new Object[]{icmRequestForwarding, to} );	}	public static Message createCancelForwardRequest( Handle h, Handle to ) {		return _createRequest( h, commServer,  							   new Object[]{icmCancelForwarding, to} );	}	public static Message createCancelForwardRequest( Handle h, Handle to, InetAddress host ) {		return _createRequest( h, commServerAt( host ),  							   new Object[]{icmCancelForwarding, to} );	}		public static Message createCancelForwardRequest( Handle from, Handle h, Handle to ) {		return _createRequest( from, commServer,  							   new Object[]{icmCancelForwarding, to} );	}	public static Message createCancelForwardRequest( Handle from, Handle h, 													  Handle to, InetAddress host ) {		return _createRequest( from, commServerAt( host ),  							   new Object[]{icmCancelForwarding, to} );	}		public static Message createLookupRequest( Handle h, Handle target ) {		return _createRequest( h, commServer,  							   new Object[]{icmLookupLocation, target} );	}		public static Message createLookupRequest( Handle h, Handle target, InetAddress host ) {		return _createRequest( h, commServerAt( host ),  							   new Object[]{icmLookupLocation, target} );	}		public static Message createPingRequest( Handle h, Handle target ) {		return _createRequest( h, commServer,  							   new Object[]{icmPingAgent, target} );	}	public static Message createPingRequest( Handle h, Handle target, InetAddress host ) {		return _createRequest( h, commServerAt( host ),  							   new Object[]{icmPingAgent, target} );	}		public static Message createListRequest( Handle h ) {		return _createRequest( h, commServer,  							   icmListAgents );	}	public static Message createListRequest( Handle h, InetAddress host ) {		return _createRequest( h, commServerAt( host ),  							   icmListAgents );	}			static Message _createRequest( Handle from, Handle to, Object[] args ) {				List l = new java.util.ArrayList();		for ( int i = 0; i < args.length; i++ )			l.add( args[i] );		Request cnt = new Request();		cnt.content_ = l;				Message msg = new Message( from, to, cnt );		// workaround for ICM bug		msg.getOptions().set( MessageOptions.icmReplyTo, from );		return msg;	}	static Message _createRequest( Handle from, Handle to, Symbol cmd ) {		Message msg = new Message( from, to, cmd );		// workadound for icm bug		msg.getOptions().set( MessageOptions.icmReplyTo, from );		return msg;	}		static boolean done_;		private static class Encoder{}	private static class Decoder{}		List content_;		public List toList() {		return content_;	}		public String toString() {		return content_.toString();	}		public boolean equals( Object obj ) {		try {			return content_.equals( ((Request)obj).content_ );		} catch ( ClassCastException exc ) {			return false;		}	}		public int hashCode() {		return content_.hashCode();	}			}

⌨️ 快捷键说明

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