java.lang.Object
java.lang.Thread
mucode.abstractions.MuAgent
- All Implemented Interfaces:
- mucode.GroupHandler, java.lang.Runnable, java.io.Serializable
- public abstract class MuAgent
- extends java.lang.Thread
- implements mucode.GroupHandler, java.io.Serializable
Provides a "mobile agent" abstraction.
Migration is obtained by invoking the go 55 method as in
myAgent.go("myhost:2000"). After migration, the agent is
removed from the source host.
Only weak mobility is provided, in that the execution state of the agent (i.e., its instruction pointer and
call stack) is not preserved across migration---a limitation coming from
the Java VM. However, the data state of the agent, i.e.,
the values of its object fields, is preserved.
The agent can determine, from time to time, which classes should be shipped
at destination along with it. This is accomplished by the
classNames parameter in go(String, String[], String,
boolean) 55 . The methods provided by mucode.util.ClassInspector and java.lang.Class may be useful in determining such classes.
The method
go(String) 55 provides a simplified version of the previous method,
where the agent is shipped along with its complete class closure (excluding
classes that are ubiquitous in the µServer hosting the
agent).
The only requirement imposed on subclasses of this class is that they
must implement a public, parameterless constructor, the reason being
that the agent class serves both as a root and a handler class for the
group that is being shipped and reconstructed being the scenes.
The mobile agent abstraction provided by this class is more powerful than
the ones found in the majority of current mobile agent systems, in that the
amount of code to be transferred at destination is completely under the
control of the programmer. Still, it is just one example of the many
flavors of mobile agent one could build on top of the fundamental
primitives provided by the mucode package.
- Version:
- 1.0
| Nested classes inherited from class java.lang.Thread |
java.lang.Thread.UncaughtExceptionHandler |
|
Constructor Summary |
MuAgent()
(This constructor should never be used by the programmer.) The
public, parameterless constructor that must be implemented by a root
or handler class. |
MuAgent(mucode.MuServer server)
Creates a new agent and binds it to a µServer, that will
handle agent migration upon invocation of the go 55 method. |
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
server
private transient mucode.MuServer server
AGENTLABEL
private static final java.lang.String AGENTLABEL
- See Also:
- Constant Field Values
MuAgent
public MuAgent(mucode.MuServer server)
- Creates a new agent and binds it to a µServer, that will
handle agent migration upon invocation of the go 55 method.
MuAgent
public MuAgent()
- (This constructor should never be used by the programmer.) The
public, parameterless constructor that must be implemented by a root
or handler class. In this case, subclasses of
MuAgent
actually represent both.
go
public final void go(java.lang.String destination,
java.lang.String[] classNames,
java.lang.String dynLink,
boolean synch)
throws java.io.IOException,
java.lang.ClassNotFoundException
- Determines the migration of the agent. The execution state is discarded,
while the data state is preserved and restored at the destination
µServer. Since this method is
public, any
object is allowed to determine the migration of this agent.
go
public final void go(java.lang.String destination)
throws java.io.IOException,
java.lang.ClassNotFoundException
- Same as
go(String, String[], String, boolean) 55 but with
classNames containing the full class closure of the agent
class, remote dynamic linking disabled, and asynchronous transfer.
unpack
public final java.lang.Thread unpack(mucode.Group group)
throws mucode.MuCodeException
- Provides specialized handling of the group containing the object, as
defined by
GroupHandler.
- Specified by:
unpack in interface mucode.GroupHandler
run
public abstract void run()
- Must be redefined by the programmer with the behavior of the agent.
- Specified by:
run in interface java.lang.Runnable