Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

NX: Interface Patterns (Once more with feeling)  RSS feed

Posts: 29
  • Mark post as helpful
  • send pies
  • 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!