/* * AgentProxy.java * * history: * 2001.04.25 alokem creation */ package magenta; import java.lang.*; import java.util.*; /** * class AgentProxy - * GdmoObject that represents a remote agent. This class (or a descended * class) is expected as an argument to ComManager's send method since * it encapsulates all the information required to send a TCP/IP message to * a remote agent. * *

The root/observers subtree also should contain objects of type * AgentProxy. These remote agents will be notified when objects are created, * deleted or changed. * *

* This class can be used as a template for creation of a GdmoObject. * It consists of the following sections - examine the source code for * details: * *

* *
* GdmoObject attributes: *
HostInfo - string in form "hostname:port" where this agent * can be contacted
*
* * @author aloke mukherjee * @version * 2001.04.25 alokem creation */ public class AgentProxy extends GdmoObject { //---------------------------------------------------------- member variables /** hostname:port info for the remote agent which this proxy represents */ private String hostInfo; //------------------------------------------ required GdmoObject constructors // other constructors could be implemented but they will not be callable by // the ComManager /** * AgentProxy constructor - * create an AgentProxy in the Object tree. */ public AgentProxy(String path, String name){ super(path, name); } // AgentProxy(path, name) //---------------------------------------------------- member access methods /** * AgentProxy::setHostInfo - * set the hostname:port of the proxy. * * @param newHostInfo string containing the hostname:port info. * * @return * "success" if value was set successfully, otherwise "failure" * * @version * 2001.04.25 alokem creation */ public String setHostInfo(String newHostInfo) { // can erase newhostinfo by setting it to null if (newHostInfo == null) { hostInfo = null; return new String("success"); } if (newHostInfo.indexOf(":") == -1) { return new String("failure HostInfo should be in format hostname:port"); } else { hostInfo = newHostInfo; return new String("success"); } } // AgentProxy::setHostInfo /** * AgentProxy::getHostInfo - * access method for hostInfo member. * * @return * the hostname:port of the remote agent which this proxy represents * * @version * 2001.04.25 alokem creation */ public String getHostInfo() { return hostInfo; } // AgentProxy::getHostInfo //----------------------------------------------------------- display method /** * AgentProxy::toString - * display the GdmoObject attributes of this object. * * @return * string describing this object * * @version * 2001.04.25 alokem creation */ public String toString() { return new String(super.toString() + " HostInfo: " + hostInfo); } // AgentProxy::toString } // class AgentProxy