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
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 ]
Joined: Nov 22, 2008
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