Sorry if someone already post a similar questions, but i didn't find.
I'm reading the book, and stopped at RMI part. I don't know if i'm doing some confusing. They said in the book that DVDDatabaseRemote implements Remote and DBClient.
So far so good, but when they implement DvdDatabaseImpl, they say that it extends UnicastRemoteObject and implements DVDDatabateRemote.
So DvdDatabaseImpl needs to implement every methos of DBClient because it's not an abstract class. But some methods like getDVD, and modifyDVD of source code of it throw RemoteException. But DBClient don't throw any RemoteException. How they can do this?
If i'm not wrong, it's not permitted to throw others checked exceptions that weren't declared in the above hierarchy. Am i right?
Gabriel Ozeas wrote:If i'm not wrong, it's not permitted to throw others checked exceptions that weren't declared in the above hierarchy. Am i right?
One of the many things that we did in our project, in order to make it different from the Sun assignment, was to have a significant change in the method signatures in the provided interface. In particular, we have every method in the interface throw IOException. Since IOException is the parent of RemoteException (or to put it another, RemoteException IS-A IOException) we can easily throw RemoteException later and still meet the contract specified by the interface.
I don't have a copy of my book handy, or I would look up some more details - from memory we called this out to readers since it was very specifically different to the real project.
Every method that is going to be used remotely must throw a RemoteException (it's a rule). However, your original interface from Oracle will not change. Remember, you are actually creating new methods in a different interface, (even though they have the same names), so adding RemoteExceptions to your new methods is no big deal. Calling these methods then should forward the call to your original database methods (which throw your original exceptions) given to you by Oracle. I have attached a tutorial about RMI that I found on the web. Together with the book, I was able to put it all together. Also, check out youtube for RMI Tutorials as there are a couple decent ones on there.
I am no expert at RMI, so take this with a grain of salt and reference the tutorial.