Recommended: Sing it, brah! 5 fabulous songs for developers
JW's Top 5
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 2 of 6
Likewise, an aglet requires a host Java application, an "aglet host," to be running on a computer before it can visit that computer. When aglets travel across a network, they migrate from one aglet host to another. Each aglet host installs a security manager to enforce restrictions on the activities of untrusted aglets. Hosts upload aglets through class loaders that know how to retrieve the class files and state of an aglet from a remote aglet host.
An aglet can experience many events in its life. It can be:
Created: a brand new aglet is born -- its state is initialized, its main thread starts executing
Cloned: a twin aglet is born -- the current state of the original is duplicated in the clone
Dispatched: an aglet travels to a new host -- the state goes with it
Retracted: an aglet, previously dispatched, is brought back from a remote host -- its state comes back with it
Deactivated: an aglet is put to sleep -- its state is stored on a disk somewhere
Activated: a deactivated aglet is brought back to life -- its state is restored from disk
Disposed of: an aglet dies -- its state is lost forever
Note that every activity besides creation and disposal involve either duplication, transmission across a network, or persistent storage of the aglet's state. Each of these activities uses the same process to get the state out of an aglet: serialization.
Aglet hosts use object serialization, available in JDK 1.1 or with the RMI (remote method invocation) add-on to JDK 1.0.2,
to export the state of an aglet object to a stream of bytes. Through this process, the aglet object and the tree of serializable
objects reachable from it, are written to a stream. An object is serializable if it implements either the Serializable or the Externalizable interface. In a reverse process, the state of the aglet can be reconstructed from the stream of bytes. Serialization allows
an image of the heap (the heap's state) to be exported to a byte stream (such as a file) and then reconstructed from that
byte stream.
The state of the execution stacks and program counters of the threads owned by the aglet are not serialized. Object serialization touches only data on the heap, not the stacks or the program counters. Thus when an aglet is dispatched, cloned, or deactivated, any relevant state sitting on any stack of a running aglet, as well as the current program counter for any thread, is lost.
In theory, a software agent should be able to migrate with all its state: heap, execution stack, and registers. Some will likely consider the inability of aglets to do this as a flaw in the aglet's implementation of mobile-agent theory. This feature of aglets arises out of the architecture of the JVM, which doesn't allow a program to directly access and manipulate execution stacks. This is part of the JVM's built-in security model. Unless there is a change to the JVM, aglets and any other mobile Java-based agent will be unable to carry the state of their execution stacks with them as they migrate.
Archived Discussions (Read only)