PART 1: Remote Method Innvocations (RMIs to the people who won’t remember that)

by Sue

To get me to finish this homework I will trick myself into writing a blog post about RMIs, which is a thing in Java that no one uses anymore cause it’s old and stupid. There is a better reason that Dave told me, but I have already forgotten it.

Fact: I don’t even pretend to know what I’m doing in front of Dave anymore.

What the hell is an RMI?
An RMI is a system that lets java code from one virtual machine use java methods that are running on another virtual machine.  The best way to describe this with my brain meats is that it’s like ajax for java.  e.g.- Back end validation:

CLIENT: “HEY YOU OVER THERE, DOES THIS LOOK VALID TO YOU?”
SERVER: “Hrmmm…. 0!”
CLIENT: “HA! it’s valid. Beep boop. *computer noises*”

I like to anthropomorphizing everything about coding languages.  It’s kind of like turning it all into cartoons in my brain.  I’m a simple person.

What are RMI’s made from?  Surely it’s something evil since it’s java
Let’s assume you know java, or you have taken about 2 and a half months of it and know your way around programming an elevator.  RMIs are made up of interfaces and classesInterfaces declare methods.  Classes implement those methods  and sometimes declare more methods.

The best way I have to describe an interface is this to think this way.  An elevator has a bunch of floor buttons.  The interface is the button panel.  All it knows is you pushed  a button.  It does none of the heavy lifting, it just says “I got pushed :) ”  and the Class actually does all the work figuring out what to do next.

Objects that have methods which can be invoked across VMs are called remote objects. They become remote by implimenting a remote interface, which does the following:

  • Extends the interface java.rmi.Remote
  • Each method inside the interface has a java.rmi.RemoteException in its throws clause, as well as any other exceptions it might throw

RMI treats remote objects different from nonRemote objects. Instead of making a copy of the remote object to use on the receiving virtual machine, RMI passes a remote stub for that object. A stub is kind of like a local representative of the remote object for the client, and as far as the client knows, it is the remote object. The client invokes all it’s methods on the local stub, and the stub passes all of that method invocation onto the remote object. A stub will have all of the remote interfaces, but it will not have access to any other methods from the receiving VM.

Think of it all like a big game of telephone or a proxy, if you’ve ever used one of those to watch UK streaming television or used Charles to troubleshoot JS without a local environment.