• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error in my Adapter pattern implementation?

 
Sean Gildea
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,

Here is my Adapter Pattern design for my project.



When I define the DBAccessRemote interface as below


I get many errors, all regarding the methods of DBAccess

Exception RemoteException is not compatible with throws clause in DBAccess.deleteRecord(long, long)DataAdapterImpl.javaURLyBird/suncertify/rmiline 41
Exception RemoteException is not compatible with throws clause in DBAccess.findByCriteria(String[])DataAdapterImpl.javaURLyBird/suncertify/rmiline 46
...



My Question Is:Did I extend it correctly in my adapter pattern design using rmi?
[ November 15, 2004: Message edited by: Sean Gildea ]
 
Anton Golovin
Ranch Hand
Posts: 527
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Sean.

Will be glad if this info is useful to you.

The way to handle the lack of the RemoteException in the Data class is by hiding the Data class behind the DataAdapter class which should implement some interface A which methods throw the IOException, along with what exceptions you need. Then, the DataAdapterImpl class can implement B interface, which extends A and Remote. Since RemoteException is a subclass of the IOException, it works. Max describes it in his book. So in your implementation, you may wish to insert the DataAdapter class in between the Data and DataAdapterImpl classes. This will allow you to use RemoteException in your DataAdapterImpl class.

Sean, wish you success in your project!
[ November 15, 2004: Message edited by: Anton Golovin ]
 
Sean Gildea
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anton,

Thank you for your reply.

Instead I will implement my DBAccessRemote interface like this.



One Question: Why cant I just setup my DataAdapterImpl class this way (below)? Why would I need a DataAdapter class? Any more light you can shed on this will probably clear up my remaining confusion.



Thanks again!
[ November 15, 2004: Message edited by: Sean Gildea ]
 
Anton Golovin
Ranch Hand
Posts: 527
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Sean. This version where the interface extends only the Remote interface will work. This way the Adapter implementation will work. However, consider that you are interested in providing local access as well, and DataAdapter is exactly the class to enable local access.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic