Java Reference
In-Depth Information
Example 5.14 Compiling and running our server on penfold .
penfold$ javac net/multitool/RMIDemo/SessionImpl.java
penfold$ rmic net.multitool.RMIDemo.SessionImpl
penfold$ rmiregistry &
17286
penfold$ java net.multitool.RMIDemo.SessionImpl
Asked to add 47 and 13
5.8.4.4
Example 5.15 shows the actual steps we ran to build and run the client.
Compiling and Running the Client
Example 5.15 Compiling and running our client on grovel
grovel$ javac net/multitool/RMIDemo/Client.java
grovel$ javac net/multitool/RMIDemo/SessionImpl.java
grovel$ /usr/java/jdk/bin/rmic net.multitool.RMIDemo.SessionImpl
grovel$ java net.multitool.RMIDemo.Client
Pointless RMI Client. 47+13=60, right?
grovel$
NOTE
We compile the server class, SessionImpl , on the client side and run rmic
against it just to produce the stubs the client requires. You could copy the stub
classes from the server machine, or you could put them in a JAR file, put that file
on a Web server, and have the java.rmi.server.codebase property point
to that JAR file. We're taking the simple way here, but in a real implementation,
you would not do it this way. We'll cover more realistic cases later.
5.8.5
RMI greatly simplifies the business of writing multitier client-server applica-
tions. It is suitable for many classes of distributed computing problems, but it
does lack several features that required in large, mission-critical applications.
For one thing, it lacks any sort of transaction support. If a method invocation
fails, the client may not know for certain whether the server finished some work,
like writing to a database, before the failure. Also, the rmiregistry program is
RMI Summary
Search WWH ::




Custom Search