• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DataInterface extends Remote?

 
Aaron Dressin
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I am using a connection manager, binded to the RMI registry, to return client connections to remote clients. In order to do this, I am extending Remote with DataInterface. I have a class tree as follows:

Data is to be used in local mode and also by my connection manager to create the 1 and only "Data" used by ClientConnection for remote access.
All is dandy when I am running in network mode (using ClientConnection)... but is it okay to have a local implementation of DataInterface (Data)that implements Remote??
Am I missing something here?
Also, this forces me to specify RemoteExceptions being thrown from every method of DataInterface... and thus catching them even when the Data is local.
Thanks,
[ May 10, 2002: Message edited by: Aaron Dressin ]
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest you make the methods in DataInterface to throw both RemoteException and DatabaseException.
It is OK for the Data class to throw DatabaseException in local mode and your connection object to throw RemoteException during network mode.
When you define a method in an interface which throws couple of exceptions, it it not required for the class implementing that interface to throw both the exceptions.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First off, Data implementing Remote is OK. If you'd search this forum, you'll find old fluff from yours truly stating the opposite, but I was wrong; I had misread the Remote contract & the conditions under which RMI serializes classes.
Second, as pointed out above, Data implementing DataInterface does not mean that its methods need to throw RemoteException.
Finally, the fact that you still have to catch RemoteException in local mode is simply an expression of the fact that your client code doesn't know or care whether the database it works with is local or remote. It works with a DataInterface implementation which may be local, or remote, or interfaced to a semi-intelligent Event Horizon[tm] quantum computer orbiting a supergiant in a nearby galaxy.
Now that's what I call future-proofing your software
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic