Re: Mobile agents using RMI

Gregg Wonderly <[email protected]> Mon, 14 May 2007 14:37:06 -0500
Newsgroups gmane.comp.java.sun.rmi
Message-ID <[email protected]>
Ghada Al-Mashaqbeh wrote:
> Hi all,
>
> can anybody send me a link that include the source code of a mobile agent using
 > java RMI application (an example that includes sending agent to client to get
 > some info and return this info back to the server) or any useful document
regarding
 > this topic?

There are many forms of this thing going on in different places.  The Java
mobile code model is exploited by the Jini platform to allow clients to download
the services' "proxy" to use it.  In many cases, a smart proxy is used to allow
some of the work to be done on the client.  A smart proxy is a Serializable
object that can carry a remote service proxy inside of it, as in:

public class MyServiceImpl implements MyService,Serializable {
        MyService me;
        double scale;

        public MyServiceImpl( MyService proxy, double scale ) {
                me = proxy;
                this.scale = scale;
        }

        public double getValue() {
                return me.getValue() * scale;
        }

        public void setValue( double val ) {
                return me.setValue( val * scale );
        }
}

Where a simple math operation is moved to the client instead of on the server.
This can of course be expanded to much more complicated logic to allow
operations of substantial nature to be done on the client, using downloaded code
that functions as an agent.  For example, you could use a smart proxy to pick
from a handful of available servers so that you distribute load, pick the best
service performance, or otherwise manage something explicitly in the client that
is an implicit feature of the service.

Gregg Wonderly

===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff RMI-USERS".  For general help, send email to
[email protected] and include in the body of the message "help".

For a list of frequently asked RMI questions please refer to:
http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html

To view past RMI-USERS postings, please see:
http://archives.java.sun.com/archives/rmi-users.html