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

📄 mafagentsystem_rmiclient.java

📁 aglet的部分源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.ibm.maf.rmi;/* * @(#)MAFAgentSystem_RMIClient.java *  * IBM Confidential-Restricted *  * OCO Source Materials *  * 03L7246 (c) Copyright IBM Corp. 1996, 1998 *  * The source code for this program is not published or otherwise * divested of its trade secrets, irrespective of what has been * deposited with the U.S. Copyright Office. */import java.security.AccessController;import java.security.PrivilegedExceptionAction;import java.security.PrivilegedActionException;import com.ibm.maf.*;import java.rmi.*;public final class MAFAgentSystem_RMIClient extends MAFAgentSystem {	private MAFAgentSystem_RMI _agent_system = null;	private String _address = null;	static java.util.Hashtable to_maf = new java.util.Hashtable();	MAFAgentSystem_RMIClient(MAFAgentSystem_RMI __rmi, String address) {		_agent_system = __rmi;		_address = address;		if (_address != null) {			to_maf.put(__rmi, this);		} 	}	public Name create_agent(Name agent_name, AgentProfile agent_profile, 							 byte[] agent, String place_name, 							 Object[] arguments, ClassName[] class_names, 							 String code_base, 							 MAFAgentSystem class_provider) throws ClassUnknown, 							 ArgumentInvalid, DeserializationFailed, 							 MAFExtendedException 	/* RequestRefused */	{		try {			final MAFAgentSystem_RMI fAgentSystem = _agent_system;			final Name fAgentName = agent_name;			final AgentProfile fAgentProfile = agent_profile;			final byte[] fAgent = agent;			final String fPlaceName = place_name;			final Object[] fArguments = arguments;			final ClassName[] fClassNames = class_names;			final String fCodeBase = code_base;			final MAFAgentSystem fClassProvider = class_provider;			return (Name)AccessController				.doPrivileged(new PrivilegedExceptionAction() {				public Object run() throws RemoteException {					MAFAgentSystem_RMI rmi_class_provider = 						to_rmi_agentsystem(fClassProvider);					while (true) {						try {							return fAgentSystem								.create_agent(fAgentName, fAgentProfile, 											  fAgent, fPlaceName, fArguments, 											  fClassNames, fCodeBase, 											  rmi_class_provider);						} catch (ConnectException ex) {							rebind(ex);						} catch (UnmarshalException ex) {							rebind(ex);						} catch (MarshalException ex) {							rebind(ex);						} 					} 				} 			});		} catch (PrivilegedActionException ex) {			RemoteException ee = (RemoteException)ex.getException();			if (ee.detail instanceof ClassUnknown) {				throw (ClassUnknown)ee.detail;			} else if (ee.detail instanceof ArgumentInvalid) {				throw (ArgumentInvalid)ee.detail;			} else if (ee.detail instanceof DeserializationFailed) {				throw (DeserializationFailed)ee.detail;			} else if (ee.detail instanceof MAFExtendedException) {				throw (MAFExtendedException)ee.detail;			} else if (ee.detail instanceof RuntimeException) {				throw (RuntimeException)ee.detail;			} else {				ex.printStackTrace();				throw new RuntimeException(ee.getMessage());			} 		} catch (Exception ex) {			ex.printStackTrace();			return null;		} 	}	public byte[][] fetch_class(ClassName[] class_name_list, 								String code_base, 								AgentProfile agent_profile) throws ClassUnknown, 								MAFExtendedException 	/* , RequestRefused */	{		try {			final MAFAgentSystem_RMI fAgentSystem = _agent_system;			final ClassName[] fClassNameList = class_name_list;			final String fCodeBase = code_base;			final AgentProfile fAgentProfile = agent_profile;			return (byte[][])AccessController				.doPrivileged(new PrivilegedExceptionAction() {				public Object run() throws RemoteException {					while (true) {						try {							return fAgentSystem.fetch_class(fClassNameList, 															fCodeBase, 															fAgentProfile);						} catch (ConnectException ex) {							rebind(ex);						} catch (UnmarshalException ex) {							rebind(ex);						} catch (MarshalException ex) {							rebind(ex);						} 					} 				} 			});		} catch (PrivilegedActionException ex) {			RemoteException ee = (RemoteException)ex.getException();			if (ee.detail instanceof ClassUnknown) {				throw (ClassUnknown)ee.detail;			} else if (ee.detail instanceof MAFExtendedException) {				throw (MAFExtendedException)ee.detail;			} else if (ee.detail instanceof RuntimeException) {				throw (RuntimeException)ee.detail;			} else {				ex.printStackTrace();				throw new RuntimeException(ee.getMessage());			} 		} catch (Exception ex) {			ex.printStackTrace();			return null;		} 	}	static synchronized MAFAgentSystem find_maf_agentsystem(MAFAgentSystem_RMI __rmi, 			String address) {		if (__rmi == null) {			return null;		} 		MAFAgentSystem maf = (MAFAgentSystem)to_maf.get(__rmi);		if (maf == null) {		// && address != null) {			maf = new MAFAgentSystem_RMIClient(__rmi, address);		} 		return maf;	}	public String find_nearby_agent_system_of_profile(AgentProfile profile) 			throws EntryNotFound {		try {			final MAFAgentSystem_RMI fAgentSystem = _agent_system;			final AgentProfile fProfile = profile;			return (String)AccessController				.doPrivileged(new PrivilegedExceptionAction() {				public Object run() throws RemoteException {					while (true) {						try {							return fAgentSystem								.find_nearby_agent_system_of_profile(fProfile);						} catch (ConnectException ex) {							rebind(ex);						} catch (UnmarshalException ex) {							rebind(ex);						} catch (MarshalException ex) {							rebind(ex);						} 					} 				} 			});		} catch (PrivilegedActionException ex) {			RemoteException ee = (RemoteException)ex.getException();			if (ee.detail instanceof EntryNotFound) {				throw (EntryNotFound)ee.detail;			} else if (ee.detail instanceof RuntimeException) {				throw (RuntimeException)ee.detail;			} else {				ex.printStackTrace();				throw new RuntimeException(ee.getMessage());			} 		} catch (Exception ex) {			ex.printStackTrace();			return null;		} 	}	public AgentStatus get_agent_status(Name agent_name) 			throws AgentNotFound {		try {			final MAFAgentSystem_RMI fAgentSystem = _agent_system;			final Name fAgentName = agent_name;			return (AgentStatus)AccessController				.doPrivileged(new PrivilegedExceptionAction() {				public Object run() throws RemoteException {					while (true) {						try {							return fAgentSystem.get_agent_status(fAgentName);						} catch (ConnectException ex) {							rebind(ex);						} catch (UnmarshalException ex) {							rebind(ex);						} catch (MarshalException ex) {							rebind(ex);						} 					} 				} 			});		} catch (PrivilegedActionException ex) {			RemoteException ee = (RemoteException)ex.getException();			if (ee.detail instanceof AgentNotFound) {				throw (AgentNotFound)ee.detail;			} else if (ee.detail instanceof RuntimeException) {				throw (RuntimeException)ee.detail;			} else {				ex.printStackTrace();				throw new RuntimeException(ee.getMessage());			} 		} catch (Exception ex) {			ex.printStackTrace();			return null;		} 	}	public AgentSystemInfo get_agent_system_info() {		try {			final MAFAgentSystem_RMI fAgentSystem = _agent_system;			return (AgentSystemInfo)AccessController				.doPrivileged(new PrivilegedExceptionAction() {				public Object run() throws RemoteException {					while (true) {						try {							return fAgentSystem.get_agent_system_info();						} catch (ConnectException ex) {							rebind(ex);						} catch (UnmarshalException ex) {							rebind(ex);						} catch (MarshalException ex) {							rebind(ex);						} 					} 				} 			});		} catch (PrivilegedActionException ex) {			RemoteException ee = (RemoteException)ex.getException();			if (ee.detail instanceof RuntimeException) {				throw (RuntimeException)ee.detail;			} else {				ex.printStackTrace();				throw new RuntimeException(ee.getMessage());			} 		} catch (Exception ex) {			ex.printStackTrace();			return null;		} 	}	public AuthInfo get_authinfo(Name agent_name) throws AgentNotFound {		try {			final MAFAgentSystem_RMI fAgentSystem = _agent_system;			final Name fAgentName = agent_name;			return (AuthInfo)AccessController				.doPrivileged(new PrivilegedExceptionAction() {				public Object run() throws RemoteException {					while (true) {						try {							return fAgentSystem.get_authinfo(fAgentName);						} catch (ConnectException ex) {							rebind(ex);						} catch (UnmarshalException ex) {							rebind(ex);						} catch (MarshalException ex) {							rebind(ex);						} 					} 				} 			});		} catch (PrivilegedActionException ex) {			RemoteException ee = (RemoteException)ex.getException();			if (ee.detail instanceof AgentNotFound) {				throw (AgentNotFound)ee.detail;			} else if (ee.detail instanceof RuntimeException) {				throw (RuntimeException)ee.detail;			} else {				ex.printStackTrace();				throw new RuntimeException(ee.getMessage());			} 		} catch (Exception ex) {			ex.printStackTrace();			return null;		} 	}	public MAFFinder get_MAFFinder() throws FinderNotFound {		try {			final MAFAgentSystem_RMI fAgentSystem = _agent_system;			return (MAFFinder)AccessController				.doPrivileged(new PrivilegedExceptionAction() {				public Object run() throws RemoteException {					while (true) {						try {							return fAgentSystem.get_MAFFinder();						} catch (ConnectException ex) {							rebind(ex);						} catch (UnmarshalException ex) {							rebind(ex);						} catch (MarshalException ex) {							rebind(ex);						} 					} 				} 			});		} catch (PrivilegedActionException ex) {			RemoteException ee = (RemoteException)ex.getException();			if (ee.detail instanceof FinderNotFound) {				throw (FinderNotFound)ee.detail;			} else if (ee.detail instanceof RuntimeException) {				throw (RuntimeException)ee.detail;			} else {				ex.printStackTrace();				throw new RuntimeException(ee.getMessage());			} 		} catch (Exception ex) {			ex.printStackTrace();			return null;		} 	}	public String getAddress() {		return _address;	}	static public MAFAgentSystem_RMI getMAFAgentSystem_RMI(String address) 			throws java.io.IOException {		return to_rmi_agentsystem(MAFAgentSystem.getMAFAgentSystem(address));	}	public Name[] list_all_agents() {		try {			final MAFAgentSystem_RMI fAgentSystem = _agent_system;			return (Name[])AccessController				.doPrivileged(new PrivilegedExceptionAction() {				public Object run() throws RemoteException {					while (true) {						try {							return fAgentSystem.list_all_agents();						} catch (ConnectException ex) {							rebind(ex);						} catch (UnmarshalException ex) {							rebind(ex);						} catch (MarshalException ex) {							rebind(ex);						} 					} 				} 			});		} catch (PrivilegedActionException ex) {			RemoteException ee = (RemoteException)ex.getException();			if (ee.detail instanceof RuntimeException) {				throw (RuntimeException)ee.detail;			} else {				ex.printStackTrace();				throw new RuntimeException(ee.getMessage());			} 		} catch (Exception ex) {			ex.printStackTrace();			return null;		} 	}	public Name[] list_all_agents_of_authority(byte[] authority) {		try {			final MAFAgentSystem_RMI fAgentSystem = _agent_system;			final byte[] fAuthority = authority;			return (Name[])AccessController				.doPrivileged(new PrivilegedExceptionAction() {				public Object run() throws RemoteException {					while (true) {						try {							return fAgentSystem								.list_all_agents_of_authority(fAuthority);						} catch (ConnectException ex) {							rebind(ex);						} catch (UnmarshalException ex) {							rebind(ex);						} catch (MarshalException ex) {							rebind(ex);						} 					} 				} 			});		} catch (PrivilegedActionException ex) {			RemoteException ee = (RemoteException)ex.getException();			if (ee.detail instanceof RuntimeException) {				throw (RuntimeException)ee.detail;			} else {				ex.printStackTrace();				throw new RuntimeException(ee.getMessage());			} 		} catch (Exception ex) {			ex.printStackTrace();			return null;		} 	}	public String[] list_all_places() {		try {			final MAFAgentSystem_RMI fAgentSystem = _agent_system;			return (String[])AccessController				.doPrivileged(new PrivilegedExceptionAction() {				public Object run() throws RemoteException {					while (true) {						try {							return fAgentSystem.list_all_places();						} catch (ConnectException ex) {							rebind(ex);						} catch (UnmarshalException ex) {							rebind(ex);						} catch (MarshalException ex) {							rebind(ex);						} 					} 				} 			});		} catch (PrivilegedActionException ex) {			RemoteException ee = (RemoteException)ex.getException();			if (ee.detail instanceof RuntimeException) {				throw (RuntimeException)ee.detail;			} else {				ex.printStackTrace();

⌨️ 快捷键说明

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