aspose file tools*
The moose likes Distributed Java and the fly likes RMI and callback client codebase Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "RMI and callback client codebase" Watch "RMI and callback client codebase" New topic
Author

RMI and callback client codebase

Ranadhir Nag
Ranch Hand

Joined: Mar 09, 2006
Posts: 138
We have an applet which acts as a callback client for an RMI server.
The applet registers itself with the RMI server for callback .
The RMI Server and the registry is running on the host on which the applet is downloaded.
The code for registering the applet as a callback client is as follows:
Registry registry =
LocateRegistry.getRegistry(getCodeBase().getHost(), RMIInterface.REGISTRY_PORT);
RMIInterface remoteReference =
(RMIInterface) registry.lookup(RMIInterface.REGISTRY_NAME);

try {

System.out.println("Registering for notification");
UnicastRemoteObject.exportObject(this);
remoteReference.registerForNotification(this);
}

In the java console ,we notice that the rmiregistry connects to the document root of the Applet URL for getting the client stub on UnicastRemoteObject.exportObject(this).
Is this because we have specified the applet as:
<APPLET CODE = "com.ibm.applet.PackagedApplet.class" archive="applet/remotermi.jar"
WIDTH = 500 HEIGHT = 50
id="Fractal">
How can we specify the rmiregistry to look for the client stub at an alternate location,rather than going to the webserver hosting the applet ,to retrieve it?
In this case ,we need the rmiregistry to pick up the client stub from the local machine(rmi server codebase is an option) on which the applet is downloaded.
How can that be done?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12806
    
    5
How can we specify the rmiregistry to look for the client stub at an alternate location,rather than going to the webserver hosting the applet ,to retrieve it?

getCodeBase() is naturally going to refer to the source URL.

How about a parameter in the Applet tags to give a local address, or maybe the user can enter an address in the applet?

The real question in my mind is - why an applet? In order to connect to a local resource won't it have to be signed, etc.? Perhaps this is more a Java Webstart type of application?

Bill
Ranadhir Nag
Ranch Hand

Joined: Mar 09, 2006
Posts: 138
The server is indeed a webstart application,initialiased by another applet.
For it to call back on a client applet,we need the client stub to be packaged with the server;rather than the registry going to the client URL for the stub.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RMI and callback client codebase