FHTW Berlin

FB 4
Internationale Media and Computing
MeSoII: Media Software II
Sommersemester 2002


Exercise 12: Doing it from somewhere else - RMI

We're back to a MageLang tutorial today (hurrah!), except that this is a newer one and the group is now called jGuru.

Remote message invocation, RMI, is all about having one of your objects call a method - and get a result - that is being offered by another object that is living somewhere in the Java Universe. This is a pretty amazing concept, and it has been around in Java for a long time! Back in the good old days when I was learning programming, we had to do this all ourselves: pack the parameters appropriately, find the other object, shovel all the data over the network, wait for a result, decode it and go on. You kids have it so easy these days :-)

  1. Read the "Introduction to Distributed Computing" in the tutorial found at http://developer.java.sun.com/developer/onlineTraining/rmi/. The table "Comparison of Distributed and Nondistributed Java Programs" is important. Make sure that you understand, more or less, the column about local objects. The column about remote ones should make sense by the end of the session. Then read the chapter "Java RMI Architecture" - here we meet our old friend, the interface, again! And you will find that some knowledge of TCP/IP will be of help. Describe, at this point, how you think RMI works, in just a few sentences.
  2. Let's get going on RMI! Read the chapter "Naming Remote Objects". We are going to do the little calculator using RMI. Write and compile the Java code for the service interface using copy & paste from the exercise. You implementation will have to extend java.rmi.server.UnicastRemoteObject in order to be of any use. Copy the code given into your directory and compile it. Now use the RMI compiler, rmic, to generate the stub and skeleton files. Lastly, we set up the CalculatorServer using a free port on localhost. We now have the server put together, let's start with a simple little client. Use the one given in the tutorial for a start! Let it start using the three consoles as described in the tutorial. Cool! This all worked on the same machine, now put the client on another machine and see if you can keep it working! Do not try and implement a complete calculator with GUI as a client unless you don't want to see your family for the next week, this is an interesting but difficult extension to the exercise.
  3. Now do Magercises 1 and 2 and see if you can get the banking system to work as well!
  4. (Extra exercise) If you are bored by this exercise because you did all this during your internship, do the parameters and callbacks exercises. If you are a glutton for punishment, plough through the garbage collection section and have a look at serializing remote objects. Whew!

 


The URL to your report, which will describe what you did during the exercise and include links to your code, is due in my email box by the start of exercise 4. This means Tuesday at 8.00 for Group 1 and Thursday at 12.00 for Group 2. Do not forget to put your names on the report! When you send the URL to me, include your partner in the CC. That way I don't get either 2 emails or none, while each thought the other was doing it. And when I answer you, I can immediately answer both of you without having to look up your preferred email account.

 


Debora Weber-Wulff (weberwu@fhtw-berlin.de)