• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Network vs local - transparent to client

 
ralph michelsen
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I have constructed an interface RMIRemote which extends remote.
My Data class on the RMI network of course implements this interface and throws Remote exceptions.
I have now made some changes to my local Data class. This class now also implements RMIRemote but does not throw any Remote exceptions. I am of course not binding my local Data class to the RMI regestry. Why have I done this then.... ?
Well I wanted to make the choice of connection (local or network) transparent to the client. I have an interface "Connection" which returns an instance of RMIRemote, and this can now be of either local or network, the client cannot tell.
I started out by making a new interface "DataFacade" which actually did the same, but when i make a "lookup" from the RMI registry all that is returned is a RMIRemote instance. So all I have to work on when I return from my "lookup" is an instance of RMIRemote.
I would very much like a comment on this design choice...
Regards
Ralph
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, It is close. Yuo can make the RMIRemote interface into the DataAccess interface extend Remote but throw Exception in the interface, this allows you to throw more specific Exceptions in the two implementation classes you will make.
Then in the Facade it accepts a DataAccess class without needing to know whether it is local or remote implementation of the DataAccess interface.
This is of course called programming to an interface.
But it is really close to what you already have. I think the main difference is that I threw Exception rather than Remote Exceptions in my interface.
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic