13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

5.8 Introducing RMI147Example 5.14 Compiling and running our server <strong>on</strong> penfold.penfold$ javac net/multitool/RMIDemo/Sessi<strong>on</strong>Impl.javapenfold$ rmic net.multitool.RMIDemo.Sessi<strong>on</strong>Implpenfold$ rmiregistry &17286penfold$ java net.multitool.RMIDemo.Sessi<strong>on</strong>ImplAsked to add 47 and 135.8.4.4 Compiling and Running the ClientExample 5.15 shows the actual steps we ran to build and run the client.Example 5.15 Compiling and running our client <strong>on</strong> grovelgrovel$ javac net/multitool/RMIDemo/Client.javagrovel$ javac net/multitool/RMIDemo/Sessi<strong>on</strong>Impl.javagrovel$ /usr/java/jdk/bin/rmic net.multitool.RMIDemo.Sessi<strong>on</strong>Implgrovel$ java net.multitool.RMIDemo.ClientPointless RMI Client. 47+13=60, right?grovel$NOTEWe compile the server class, Sessi<strong>on</strong>Impl, <strong>on</strong> the client side and run rmicagainst it just to produce the stubs the client requires. You could copy the stubclasses from the server machine, or you could put them in a JAR file, put that file<strong>on</strong> a Web server, and have the java.rmi.server.codebase property pointto that JAR file. We’re taking the simple way here, but in a real implementati<strong>on</strong>,you would not do it this way. We’ll cover more realistic cases later.5.8.5 RMI SummaryRMI greatly simplifies the business of writing multitier client-server applicati<strong>on</strong>s.It is suitable for many classes of distributed computing problems, but itdoes lack several features that required in large, missi<strong>on</strong>-critical applicati<strong>on</strong>s.For <strong>on</strong>e thing, it lacks any sort of transacti<strong>on</strong> support. If a method invocati<strong>on</strong>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

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!