This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about camerlengo's book

 
Gabriel Ozeas
Ranch Hand
Posts: 30
Google App Engine Hibernate jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys,

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?

Thanks Ranchers

 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not Terry, but I'll take a stab at this one.
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.
 
Matt Pavlovich
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Gabriel,

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.

Hope that helps.
Matt
 
Matt Pavlovich
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay I TRIED to attach something but to no avail. Here is the link for the RMI tutorial. http://www.slideshare.net/junyuo/a-short-java-rmi-tutorial This site has other tutorials on RMI as well, just FYI.

Matt
 
Gabriel Ozeas
Ranch Hand
Posts: 30
Google App Engine Hibernate jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Andrew and Matt,

Thanks a lot, i understood now what's going on in the example. I just forgot about RemoteException hierachy.
I will look for RMI tutorial and try to master it . It's not so difficult.

Thanks again,
Nice weekend for both of you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic