Class Agent
java.lang.Object
|
+--Agent
- Direct Known Subclasses:
- AgentVisual
- public class Agent
- extends java.lang.Object
The Agent class implements the base class of a mobile agent.
It is able to jump from base to base and runs there in it's own
thread. Each Agent needs a Base object that handles it's
requests and sends and receives it.
Constructor Summary |
Agent(Base aBase)
Creates a new agent |
Agent(Base aBase,
java.lang.String aName)
Creates a new agent |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Agent
public Agent(Base aBase)
- Creates a new agent
Agent
public Agent(Base aBase,
java.lang.String aName)
- Creates a new agent
getName
public java.lang.String getName()
onMessage
public void onMessage(Message aMessage)
- This function is called on incoming messages.
Override this function in your own agents to receive messages
sent to your agent.
messageReceived
public void messageReceived(Message aMessage)
setBase
public void setBase(Base aBase)
- Transfers agent to another base.
Beam me up, Scotty!
The agent unsubscribes from his old base and
adds himself to his new home base.
getBase
public Base getBase()
- Returns the home base of the agent
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
destroy
public void destroy()
- Destroy's the agent.
It is neccessary to call this function if you want
to kill an agent, otherwise the base would not know
and the agent would continue to exist.
sleep
public static void sleep(long ms)