• 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

B&S Required interface

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I'm doing the B&S project and have a question regarding the public interface "DB.java" that we must implement.

The thing is that according to the document (body of the interface is given) the methods in the interface that we need to implement do not show that it throw exceptions such as RemoteException or IOException. I have programmed the network part with RMI and can't make it work without adding one of these 'throws'clauses as part of the method signature of the interface.

Does anybody know if is ok to just add for example 'throws IOExeption' to the methods signature or would this be a reason for automatic failure. Or if there a workaround to bypass this exceptions?.

For example:

Instead of

public String[] read(int recNo) throws RecordNotFoudException;

Change to:

public String[] read(int recNo) throws RecordNotFoudException, IOException;


I appreciate any help.


Thanks.

Simon
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Simon,

When I was working on that version, I decided to try a decorator pattern where the supplied interface by sun is decorated with additional exceptions at a higher level. This will allow you to use high level methods which intern can call lower methods that correspond to your interface. Hope that helps.
 
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Simon,

adding an IOException to one or more method to the DB interface, that would mean you change the interface.

I throw a SystemException in case a IOException occured and document that throwing in my JavaDoc. I hope that SUN like my proposal.
 
Simon Arocha
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,

Adding a new decorated interface with other exceptions worked fine for both RMI and standalone.

Thanks.

Simon
 
reply
    Bookmark Topic Watch Topic
  • New Topic