Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need to create RMI stubs if I have a subinterface of Remote?

 
Cless Alvein
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From my understanding, we don't need to create RMI stubs despite what the specification says. That being said, I'd like to do it just to be sure. From what I understand, RMI stubs are sort of like an interface; they expose the method signatures of the object but not the implementation. So yes, it makes sense to require RMI stubs if I am trying to access a class over the remote connection.

However, I chose to create an interface called RemoteDBMain that extends RMI's Remote interface. Then, I have an implementation of RemoteDBMain called RemoteData, which is created on the server's side and is bound in the RMI registry using some code that looks like:
On the client's side, I find the RMI registry on the server and request the RemoteDBMain object from the server. Since my client doesn't know about RemoteData and only cares that the returned object implements RemoteDBMain, am I right in thinking that my client needs no stubs? That is, the "stub" in my case is the RemoteDBMain interface itself! Thus, as long as I include the RemoteDBMain.class file with the client, I should be fine, correct?

Of course, since all of our files are packaged together in a single JAR this means that all of the class files for the client and server are packaged together anyway
 
Cless Alvein
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After some cross-VM testing, it appears that I do need to generate a stub for the RemoteData class even though it is never directly referenced by the client. My assumption is that when I call exportObject, somewhere along the way getClass() is invoked on the object and so it tries to export it as a RemoteData instance instead of a RemoteDBMain one. Fair enough; it can't really know that I only care about the interface it implements and not the actual class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic