The java.rmi.Naming Class


The java.rmi.Naming Class

The key class that makes RMI work is java.rmi.Naming . The Naming class provides methods for storing and obtaining references to remote objects. It does so by communicating with the remote object registry. You need the following methods for the assignment:

  • bind ” Binds the specified name to a remote object so that you can then refer to that object by name .

  • lookup(String name) ” Returns a reference for the remote object associated with the specified name. Actually, the client gets a reference to the stub, which in turn communicates with the remote object.

  • rebind(String name, Remote object) ” Binds the specified name to the remote object. You can use this method instead of bind if the object is already associated by name in the registry.

There are many tutorials on RMI, but books on this topic aren't plentiful. I found RMI to be powerful yet troublesome . For one thing, I was able to get RMI to work great in my solution on Windows, but when I tested it on Solaris (version 5.8), it failed until I adjusted the code so that it worked on both platforms. So be careful with RMI; older versions of RMI and Solaris can cause trouble. Overall RMI is an awesome feature of J2SE. What you get in J2SE 1.4 is much improved since earlier versions. If you get stuck, don't panic; many other developers have, too. The most likely trouble spot will be the registry and paths. If you start RMI programmatically (as described previously), however, you'll have fewer problems.



JavaT 2 Developer Exam CramT 2 (Exam CX-310-252A and CX-310-027)
JavaT 2 Developer Exam CramT 2 (Exam CX-310-252A and CX-310-027)
ISBN: N/A
EAN: N/A
Year: 2003
Pages: 187

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net