• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about camerlengo's book

 
Ranch Hand
Posts: 30
Hibernate jQuery Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Hibernate jQuery Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Just let me do the talking. Ahem ... so ... you see ... we have this tiny ad...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic