I've finally made a decent design after reading so many valuable topics and discussions in this forum, and books. I think I finally have something I could share with you so you could comment or criticize. I'll appreciate any feedback :-)
DB
- DataInterface: Extends Remote. Interface defines all public Data methods but throws DatabaseException and RemoteException.
- Data: Implements DataInterface. Implements criteriaFind(), but not lock() and unlock().
CLIENT
- FBNServices: Interface used by the GUI, provides business services. Methods: book(), searchFlights(), etc.
- FBNServicesImpl: Implements FBNServices and its methods. Uses DataClient instance in all business methods.
- FBNServicesLocal: Extends FBNServicesImpl. Overrides constructor to get DataClient (local DataInterface).
- FBNServicesRemote: Extends FBNServicesImpl. Overrides constructor to get DataClient (via remote DataInterface) and overrides book() by calling DataClient instance methods lock()-> super.book()->unlock().
- DataClient: Class in client side that has same methods of DataInterface but throw DataClientException (Deal with RemoteException and DataException and throw DataClientException). Uses DataInterface instance (locally or remotelly instantiaded via a DataFactory).
- DataFactory: Creates DataInterface by methods getLocal() or getRemote().
REMOTE
- RemoteDataImpl: Extends UnicastRemoteObject implements DataInterface. Implements lock() and unlock(). Uses LockManager.
- LockManager: Holds HashSet of locked records. Methods: lock() and unlock().
- RegisterDataServer: Creates registry and binds RemoteDataImpl.
GUI
- ConnectionDialog: Uses FBNServices by instantiating FBNServicesLocal or FBNServicesRemote, depending on the user choice. Send instance to MainWindow.
- MainWindow: Uses FBNServices instance created in the ConnectionDialog. Inner classes BookFlight and SearchFlight (ActionListeners who play the controller in the MVC design pattern) use FBNServices instance to execute business services.
I'm deciding on using a Client ID and looking a mechanism to get an unique identified of every connection.
Thank you for spending your time reading this topic :-)
Best regards.
[ October 14, 2005: Message edited by: Azbel Eden ]