Class MobileAgent

java.lang.Object
  |
  +--MobileAgent

public abstract class MobileAgent
extends java.lang.Object
implements MobileAgentItf

See Also:
MobileAgentItf, Serialized Form

Field Summary
protected  java.lang.String currentHostName
          The host name of the current agent server.
protected  int currentPortNumber
          The port number of the current agent server.
protected  java.lang.String homeHostName
          The host name of the home agent server.
protected  int homePortNumber
          The port number of the home agent server.
protected  java.lang.String name
          The name that identifies the agent.
 
Constructor Summary
MobileAgent()
           
 
Method Summary
 void comeBackHome()
          The mobile agent comes back to its home agent server.
 java.lang.String getCurrentHostName()
          Returns the host name of the agent's current agent server.
 int getCurrentPortNumber()
          Returns the port number of the agent's current agent server.
 java.lang.String getHomeHostName()
          Returns the host name of the agent's home agent server.
 int getHomePortNumber()
          Returns the port number of the agent's home agent server.
 java.lang.String getName()
          Returns the agent's name.
 void init(java.lang.String name, java.lang.String homeHostName, int homePortNumber)
          Initializes the agent with a name, and the host name and the port number of the agent server on which it is created.
 boolean isMobile()
          Tests if the agent is mobile.
 void meet(java.lang.String otherAgentName)
          The mobile agent joins another agent identified by a name.
 void moveTo(java.lang.String hostName, int hostPort)
          The mobile agent moves to an agent server identified by a name and a port number.
 void run()
          This is the starting point of the agent; this method does nothing and returns.
 void setCurrentHostName(java.lang.String hostName)
          Sets the value of the Returns the host name of the agent's current agent server name.
 void setCurrentPortNumber(int portNumber)
          Sets the value of the Returns the host name of the agent's current agent server port.
 void waitFor(java.lang.String otherAgentName)
          The mobile agent waits for the arrival of another agent identified by a name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
The name that identifies the agent.

homeHostName

protected java.lang.String homeHostName
The host name of the home agent server.

homePortNumber

protected int homePortNumber
The port number of the home agent server.

currentHostName

protected transient java.lang.String currentHostName
The host name of the current agent server.

currentPortNumber

protected transient int currentPortNumber
The port number of the current agent server.
Constructor Detail

MobileAgent

public MobileAgent()
Method Detail

init

public void init(java.lang.String name,
                 java.lang.String homeHostName,
                 int homePortNumber)
Initializes the agent with a name, and the host name and the port number of the agent server on which it is created.

Parameters:
name - the name of the agent.
homeHostName - the host name of the agent server.
homePortNumber - the port number of the agent server.

getName

public java.lang.String getName()
Returns the agent's name.
Returns:
the name of the agent.

getHomeHostName

public java.lang.String getHomeHostName()
Returns the host name of the agent's home agent server.
Returns:
host name of the home agent server.

getHomePortNumber

public int getHomePortNumber()
Returns the port number of the agent's home agent server.
Returns:
port number of the home agent server.

getCurrentHostName

public java.lang.String getCurrentHostName()
Returns the host name of the agent's current agent server.
Specified by:
getCurrentHostName in interface MobileAgentItf
Returns:
host name of the current agent server.

getCurrentPortNumber

public int getCurrentPortNumber()
Returns the port number of the agent's current agent server.
Specified by:
getCurrentPortNumber in interface MobileAgentItf
Returns:
port number of the current agent server.

setCurrentHostName

public void setCurrentHostName(java.lang.String hostName)
Sets the value of the Returns the host name of the agent's current agent server name.
Specified by:
setCurrentHostName in interface MobileAgentItf
Parameters:
hostName - name of the current agent server.

setCurrentPortNumber

public void setCurrentPortNumber(int portNumber)
Sets the value of the Returns the host name of the agent's current agent server port.
Specified by:
setCurrentPortNumber in interface MobileAgentItf
Parameters:
portNumber - port number of the current agent server.

isMobile

public boolean isMobile()
Tests if the agent is mobile.
Returns:
TRUE.

run

public void run()
This is the starting point of the agent; this method does nothing and returns.

Subclasses of StationaryAgent should override this method.


moveTo

public void moveTo(java.lang.String hostName,
                   int hostPort)
The mobile agent moves to an agent server identified by a name and a port number.
Specified by:
moveTo in interface MobileAgentItf
Parameters:
hostName - the target agent server's host name.
hostPort - the target agent server's port number.

comeBackHome

public void comeBackHome()
The mobile agent comes back to its home agent server.
Specified by:
comeBackHome in interface MobileAgentItf

waitFor

public void waitFor(java.lang.String otherAgentName)
The mobile agent waits for the arrival of another agent identified by a name. The mobile agent blocks until the other agent arrives.
Specified by:
waitFor in interface MobileAgentItf
Parameters:
otherAgentName - the name of the agent the mobile agent is waiting for.

meet

public void meet(java.lang.String otherAgentName)
The mobile agent joins another agent identified by a name. The mobile agent moves to the agent server hosting the target agent.
Specified by:
meet in interface MobileAgentItf
Parameters:
otherAgentName - the name of the agent the mobile agent is joining.