Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I am close to submit - question about rmi

 
Mike Tilling
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. What you do fulfills the requirements.
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Oliver Weikopf
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, it seems not to be necessary. I don't do it either.
 
Vairoj Arunyaangkul
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 284
Debian Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
-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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic