Java Reference
In-Depth Information
service with the rmid command that ships with the Java SDK in Java 1.2 and later.
Conveniently, rmid can also perform the function of the rmir egistry as well.
All the details described here are server-side details: the client can't tell the differ-
ence between an activatable remote object and a regular remote object. This sec-
tion has outlined only the process of creating activatable objects; see Java
Enterprise in a Nutshell for more information.
CORBA Interoperability with RMI/IIOP
One of the weaknesses of traditional RMI remote objects is that they work only
when Java is used for both the client and the server. (This is also a strength, in that
it keeps the remote method infrastructure simple and easy to use.) A new technol-
ogy called RMI-IIOP allows you to use RMI remote objects with the IIOP network
protocol. IIOP is the Internet Inter-ORB Protocol: the protocol used by the CORBA
distributed object standard. RMI-IIOP is implemented in the javax.rmi package,
and is a standard part of Java 1.3 and later.
RMI remote objects can't automatically use the IIOP protocol: you must implement
them specially by subclassing the javax.rmi.PortableRemoteObject class and fol-
lowing a number of other steps. Although there is extra work involved, using RMI-
IIOP can be of great value if you are working in a heterogeneous environment
and want to connect Java remote objects with legacy remote objects implemented
using the CORBA standard. See Java Enterprise in a Nutshell for an overview and
see http://java.sun.com/pr oducts/rmi-iiop/ and the RMI-IIOP documentation in the
Java SDK for complete details.
Exercises
16-1. Modify the remote banking example in this chapter so that bank customers
are allowed to borrow money from the bank against some maximum line of
credit and can also apply money from their account to pay off their debt.
Add borrow() and repay() methods to the RemoteBank interface, implement
these methods in the server, and modify the client so that it can call these
methods when the user requests them.
16-2. The rmir egistry program provides a simple name service for RMI programs;
it allows servers to register names for the remote objects they serve, and it
allows clients to look up those remote objects by name. Because it is a
global registry, shared by any number of remote services, there is a possibil-
ity of name collisions. For this reason, if a service needs to define names for
a number of remote objects, it should usually provide its own custom reg-
istry. That way, a client can use the global registry to look up the service's
custom naming registry, and then it can use this custom registry to look up
particular named objects for that service.
Use RMI to write a server that provides such a custom naming service. It
should export remote methods that correspond to the bind() , rebind() ,
unbind() , and lookup() methods of the Naming class. You will probably
want to use a java.util.Map object to associate names with remote objects.
Search WWH ::




Custom Search