File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Local and remote interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Local and remote interfaces" Watch "Local and remote interfaces" New topic
Author

Local and remote interfaces

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi, all the java gurus around the world!
Does this solution sound ok?
I have DataInterface that includes all the public methods of Data class (+ criteriaFind). Every method throw IOException because RemoteException extends IOException. (In the original Data class only one public method (lock) throws IOException.)
Those methods that throw DatabaseException in the original Data class throw both IOException and DatabaseException in the DataInterface.
Then I have RMIDataInterface that extends both DataInterface and Remote. RMIDataInterface does not have any new or modified methods so it looks like an empty interface.
Regards,
Jukka
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Jukka Palom�ki:
I have DataInterface that includes all the public methods of Data class (+ criteriaFind). Every method throw IOException because RemoteException extends IOException.
My first, knee-jerk thought was: why are you unnecessarily broadening your RemoteExceptions to IOExceptions. Then I realised that, if you define the interface with IOExceptions, it suddenly becomes completely transport-agnostic. Declaring it with RemoteException more or less binds you into an RMI implementation for client/server communications. Broadened to IOException, it could just as well be raw sockets. You could change your implementation without modifying the client code, which is a Good Thing in my book. I like it.
Then I have RMIDataInterface that extends both DataInterface and Remote. RMIDataInterface does not have any new or modified methods so it looks like an empty interface.
You don't need it -- DataInterface can extend Remote directly (yes, I know this flies in the face of what I've stated in the past). But it won't hurt either.
- Peter
[ April 13, 2002: Message edited by: Peter den Haan ]
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Thank you for your answer. I tested and it works. DataInterface which extends Remote works both locally and remotely.
I am still thinking... If DataInterface extends Remote doesn't this make it also more tied to RMI? Well, maybe there are two good and nice alternatives:
1. DataInterface extends Remote and all the methods throw RemoteException. RMIDataInterface is not needed.
2. DataInterface does not extend anything and all the methods throw IOException. RMIDataInterface extends both DataInterface and Remote.
It is not important which alternative is better because there is not only one correct answer. You just give reasons for your choices in the documents.
Jukka
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Local and remote interfaces
 
Similar Threads
Remote/local database design. Please comment this.
FBN : Exception in High level Data Interface
Design questions (with RMI)
Can I Defend this Design? Help Peter, Mark
Final design