lime.mobileagent.mucode
Class MobileAgent

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--mucode.abstractions.MuAgent
              |
              +--lime.mobileagent.mucode.MobileAgent
All Implemented Interfaces:
mucode.GroupHandler, ILimeAgent, java.lang.Runnable, java.io.Serializable

public abstract class MobileAgent
extends mucode.abstractions.MuAgent
implements ILimeAgent

This class provides a Lime-enabled mobile agent, on top of µCode mobile agents. Agents can be migrated using the migrate(java.lang.String) method, and automatically retain the content (data and reactions) associated to their Lime tuple spaces. For more information about the details of mobile agents int µCode, please refer to the µCode SourceForge site.

See Also:
MuAgent, ILimeAgent, Serialized Form

Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
MobileAgent()
           
MobileAgent(mucode.MuServer s)
           
 
Method Summary
abstract  void doRun()
          Must be redefined by the programmer with the behavior of the agent.
 LimeAgentMgr getMgr()
          Returns the LimeAgentMgr object associated to this agent.
 void migrate(java.lang.String destination)
          Migrates this agent to the specified destination, expressed as a string host:port.
 void migrate(java.lang.String destination, java.lang.String[] classes, java.lang.String dynLink, boolean synch)
          Migrates this agent to the specified destination, expressed as a string host:port.
 void run()
           
 
Methods inherited from class mucode.abstractions.MuAgent
go, go, unpack
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MobileAgent

public MobileAgent()

MobileAgent

public MobileAgent(mucode.MuServer s)
Method Detail

getMgr

public LimeAgentMgr getMgr()
Returns the LimeAgentMgr object associated to this agent.
Specified by:
getMgr in interface ILimeAgent
Following copied from interface: lime.ILimeAgent
Returns:
the manager of this agent.

migrate

public final void migrate(java.lang.String destination)
                   throws java.io.IOException,
                          java.lang.ClassNotFoundException
Migrates this agent to the specified destination, expressed as a string host:port. The agent is migrated together with all the classes it references, except for system classes (including those in lime.*, lights.*) and for ubiquitous classes (i.e., classes the programmer specifies are available at all servers. See the µCode documentation for more details.
Parameters:
destination - specified as host:port (if the port is missing, the default µCode port is assumed).
Throws:
java.io.IOException - if an error occurs during transmission.
java.lang.ClassNotFoundException - if a class cannot be found during agent serialization.

migrate

public final void migrate(java.lang.String destination,
                          java.lang.String[] classes,
                          java.lang.String dynLink,
                          boolean synch)
                   throws java.io.IOException,
                          java.lang.ClassNotFoundException
Migrates this agent to the specified destination, expressed as a string host:port. The classes migrated with the agent are specified by their full name in the classes array. At destination, if a class is missing it can be retrieved from the server specified in the dynlink parameter (a null value means that dynamic linking is forbidden). The synch boolean parameter specifies whether the invocation is blocking or non-blocking. See the µCode documentation for more details.
Parameters:
destination - specified as host:port (if the port is missing, the default µCode port is assumed).
classes - the fully specified name of all the classes that should be shipped with the agent.
dynlink - the server from which classes that need to be resolved at destination can be dynamically linked from.
synch - true if the invocation is blocking, false otherwise (not yet implemented, use false).
Throws:
java.io.IOException - if an error occurs during transmission.
java.lang.ClassNotFoundException - if a class cannot be found during agent serialization.

run

public final void run()
Overrides:
run in class mucode.abstractions.MuAgent

doRun

public abstract void doRun()
Must be redefined by the programmer with the behavior of the agent.