Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Intermediate RMI interface

 
Greenhorn
Posts: 20
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

While documenting my OCMJD code I noticed I'm using an empty interface combining the Remote interface defined in java and the SubcontractorService interface I wrote:
public interface RmiSubcontractorService extends Remote, SubcontractorService {}

This combined interface is used by my RmiServer class, which is used to register and unregister the SubcontractorService:
public class RmiServer extends UnicastRemoteObject implements RmiSubcontractorService {

This works just fine, but I wanted to see if the RmiServer class would still work as expected when implementing the combined interfaces directly:
public class RmiServer extends UnicastRemoteObject implements Remote, SubcontractorService {

I was surprised to find this broke the RMI functionality.
That is, the service can be registered, but my RMI client is suddenly unable to find it.

OO wise it doesn't make much sense to me.
Does anyone know if this is an RMI related issue?

Thanks in advance.
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A remote object has to implement an interface that extends the Remote interface, and it's true that from the perspective of the remote object it doesn't make a difference whether the interface it implements extends Remote or whether it implements Remote itself as a second interface. However, from the perspective of the remote interface it does make a difference, because that interface is also used to generate stubs, either via rmic or dynamically via java.lang.reflect.Proxy. If the interface didn't extend the Remote interface there would be no way of determining whether it could be used to invoke remote methods. The Remote interface is used as a marker interface.

Edit: just to clarify, Remote interface with the uppercase 'R' refers to java.rmi.Remote and remote interface with the lowercase 'r' refers to the interface that extends java.rmi.Remote.
 
Robin van Riel
Greenhorn
Posts: 20
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see.
Thanks for clearing that up, Jelle!
 
Everybody's invited. Even this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic