• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Intermediate RMI interface

 
Greenhorn
Posts: 20
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see.
Thanks for clearing that up, Jelle!
 
She still doesn't approve of my superhero lifestyle. Or this shameless plug:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic