Meaningless Drivel is fun!*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes I am close  to submit - question about rmi Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "I am close  to submit - question about rmi" Watch "I am close  to submit - question about rmi" New topic
Author

I am close to submit - question about rmi

Mike Tilling
Ranch Hand

Joined: Feb 17, 2006
Posts: 86
Hi

I am using RMI as follows (I am using jdk1.5.0_07)

//Create the registry
Registry registry = LocateRegistry.createRegistry(1099);

//Obtains the stub for the registry on the local machine
registry = LocateRegistry.getRegistry();

//Exports the remote object
Data db = new Data("server");
RmiInterface dataStub = (RmiInterface) UnicastRemoteObject.exportObject (db, 0);

//Bind the remote object's stub in the registry
registry.bind("Server", dataStub);

The client has to connect first to the server before being able to query the database, the connection to the server is done like that:

//Obtains a stub for the registry on the server's host
Registry registry = LocateRegistry.getRegistry(serverName, 1099);

//Looks up the remote object's stub by name in the registry
dataRmi = (RmiInterface) registry.lookup("Server");

-On the other hand, it was mentioned in the Assignment that:

-You must not require the use of an HTTP server.
-You must not require the installation of a security manager.
-You must provide all classes pre-installed so that no dynamic class downloading occurs.
-You must use RMI over JRMP (do not use IIOP)

-does the way I used RMI fit with all the Assignment specs?
Oliver Weikopf
Ranch Hand

Joined: Feb 17, 2004
Posts: 58
Yes. What you do fulfills the requirements.
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 918

Hallo,

I am not an RMI expert but the export the remote object is ready necesary ?

Data db = new Data("server");
RmiInterface dataStub = (RmiInterface) UnicastRemoteObject.exportObject (db, 0);


Regards,Mihai


SCJP, SCJD, SCWCD, OCPJBCD
Oliver Weikopf
Ranch Hand

Joined: Feb 17, 2004
Posts: 58
No, it seems not to be necessary. I don't do it either.
Vairoj Arunyaangkul
Greenhorn

Joined: Sep 23, 2006
Posts: 9
I believe it is unnecessary only if your remote implementation class is extended from UnicastRemoteObject. It this case, the exporting is done by UnicastRemoteObject's constructor. If your class does not extended from UnicastRemoteObject, you then need to manually export it.
Oricio Ocle
Ranch Hand

Joined: Nov 30, 2004
Posts: 284

-does the way I used RMI fit with all the Assignment specs?

Provided information is insuficient regarding:

-You must provide all classes pre-installed so that no dynamic class downloading occurs.

You are close to submit... I supose those magic literals in your code are only for the example purpose, not?

Regards, Oricio


SCJP, OCMJD, OCMJEA
 
 
subject: I am close to submit - question about rmi