• 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

NX: Interface Patterns (Once more with feeling)

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are several threads on how we are implementing our design patterns and interfaces, each with a slightly different angle. Figured I would throw one more into the mix and ask for opinions:
Data class is the workhorse that actually does the job of searching, reading, writing. Implements DBMain interface, per Sun requirement.
RemoteMap (extends Remote) is an interface to allow DBMain to be used as a remote object. RemoteAdapter class extends UnicastRemoteObject and implements RemoteMap. The implementation contains an instance of Data (through DBMain) and simply maps remote methods to the DBMain methods.
(Server instantiates the RemoteAdapter and does RMI binding stuff)
On the client side, there is a Factory class that always returns a DBMain interface, which the client model uses to search, update, etc. There are two possible classes that can be used by the Factory to produce the instance: One is simply the Data class itself when running in standalone mode; the other is another class called RemoteData that implements DBMain, and acquires a reference to the RemoteMap interface from RMI. This class maps its own DBMain methods to this acquired RemoteMap object's methods.
So, the advantage is that the client uses the original DBMain interface regardless of whether the Database is local or remote. Local mode is very straighforward. For remote mode, is it strange to do this double conversion? Once on the client to map from DBMain calls to RemoteMap calls, then once on the server to adapt back from RemoteMap to DBMain.
Any comments are appreciated.
 
reply
    Bookmark Topic Watch Topic
  • New Topic