Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Understanding RMI  RSS feed

 
Sixfrido Mendez
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am very curious to understand how to completely hardcode RMI, as well as the best method to auto-generate the Stub and Skeleton Interfaces.
 
Jiafan Zhou
Ranch Hand
Posts: 193
Fedora Linux Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In JDK5.0, there is no need to generate stub and skeleton yourself at all. All you need to do is compiling through the Interface and Interface Implementation, as well as the client side, am I right?
 
Sixfrido Mendez
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know Jiafan, I'm just learning about Java right now, and if I could get a walk through, or something like that, it would keep me from doing this .
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked at the RMI tutorial on Sun's website?
 
Sixfrido Mendez
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's where I've gotten stuck, I mean I've tried using RMIC and the RMIC registry, but I've gotten nowhere with it, I just keep hitting the wall when it comes to implementing it, probably because I don't have much time to work with it.

I've been learning portlets, servlets, JSP, JDBC, IBM's Portlet Factory, not to mention just being introduced to Java 6 weeks ago, so I'm a little overwhelmed at the moment, and if you could "dumb it down" for me so that I could get it down in theory and in practice, that would be awesome.

My main goal is to understand Java from the inside out, I don't want to just know how, but why, and if given the circumstances, be able to replicate RMI with minimal resources (ie without plugins or RMIC) just to get a total understanding of what's going on behind the scenes.
[ July 19, 2006: Message edited by: Sixfrido Mendez ]
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quick RMI overview -

RMI is a way for two Java Virtual Machines to talk between themselves.

First, you provide the "remote interface" - basically, you extend the Remote interface, make all the methods throw RemoteException, and ensure that all the method parameters and return values are "serializable" objects (i.e. - you can turn the object into a representation that you can use to send a copy over the network) or are references to "Remote" objects themselves.

Second, you implement the Remote Interface. This is sometimes called the "Server" or "Remote Implementation". Basically, you implement the Remote Interface you provided, and extend UnicastRemoteObject. You do whatever the implementation of the methods provided in the Remote Interface needs to do inside.

Third, now the reason for the Remote Interface and Implementation comes into play. If you are familiar with design patterns - this is a perfect example of the "Proxy" pattern. You run your Implementation through RMIC (in JDK1.5+, this step happens "on the fly"), and it produces a "Stub" and "Skeleton". The Stub is a class that implements your Remote Interface, too. A client class calls the Stub using a normal in-JVM method call, and inside all it does is serialize the method parameters, and send the Skeleton a message in some agreed upon format, telling it what method got called, and sending it the serialized parameters. The Skeleton receives the network message from the Stub, de-serializes the parameters, and delegates the method call to your real Implementation with a normal in-JVM method call. Once the real method call completes, the Skeleton serializes the return value (if any) and sends a message back to the Stub. The stub then returns the return value (if any) to the client.

There are tons of other issues around RMI - such as codebase, security, the nameserver, callbacks, etc. but this is the basics.
 
Sixfrido Mendez
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Nate, I believe I'm starting to get the idea.

Sixfrido Mendez II
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!