• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

B&S Required interface

 
Simon Arocha
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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
 
Michael Vargenstien
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • 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.
 
Lucy Hummel
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks,

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

Thanks.

Simon
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic