Chapter 12. Remote Method Invocation


Terms you'll need to understand:

  • Remote Method Invocation (RMI)

  • Stubs and skeletons

  • Remote object

  • rmic

  • rmiregistry

  • Remote interface

  • Naming.lookup

  • ClassNotFoundException

  • Naming.bind

Techniques you'll need to master:

  • The steps to start the RMI registry, server, and client

  • Identifying what code goes on the server and what code goes on the client

  • Writing a remote interface

  • Properly managing RMI exceptions, such as ClassNotFoundException

  • Knowing how to register an object with the RMI registry by using Naming.bind or Naming.lookup

In this chapter, you review the basics of Java Remote Method Invocation (RMI). RMI is how you can call methods on a remote object ”one that is on another Java Virtual Machine (JVM) ”as though that object is local. Before RMI, this process was difficult, but RMI provides a way to invoke objects remotely, even those on different hosts .

In this chapter, you build an application that works in local mode and remote mode. In local mode, the client communicates with the database, accessing the database files directly. In remote mode, your application modifies the supplied code in a way that creates a database server. In this remote mode, the client reads and writes to the database over the network. The assignment allows two approaches for communication between the client and the database in remote mode. You can use RMI or serialized objects over Transmission Control Protocol (TCP) socket connections. Both approaches are valid, and your choice does not affect your grade.

graphics/tip_icon.gif

Although the assignment allows you to use RMI or serialized objects over TCP/IP, RMI is recommended because it requires fewer lines of code and has thread safety built in. Although RMI has problems of its own, of the two choices, it is a more elegant solution. One shortcoming of RMI is that it offers less detailed control than you get with sockets. However, the tradeoff is worth it.




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