Originally posted by berry westover:
Boy do I need some help....
Need some help with pseudocode here. How does the GUI client get the local or remote database connection? Does it get the connection thru a factory? If that's the case it seems like the factory must return an interface back to the GUI client. That interface must be common to both the local database connection as well as the remote database connection. Since DBAccess can't be modified I don't see how you can do that becuase you need an interface to extend Remote if you plan on using RMI.
Or does the GUI client maintain two different instance variables one for a local database connection and the other for a remote database connection....and it knows which one to reference to get the actual database operation to be performed based upon how it was started or launched.
HELP!!!
The answer is in the reply I posted to the "Local Adapter Issue"
thread. If you are going the orthodox fat client route, you need to provide the DBAccess interface to your client, regardless of whether its local or remote.
You can do this by using two adapters, the first adapter (DataAdapter) is the interface that extends Remote and adds RemoteException to the method signitures in DBAccess, it might need to add some methods to manage the networking as well. The second adapter (DataProxy) readapts the first one to re-implement DBAccess, this can be done by catching the RemoteException and throwing an unchecked exception. You will need to throw unchecked exceptions in your Data class anyway to handle IOException, so just use the one you used there.
I use a Factory Method in my BookingModel to create an instance of DBAccess that is either a Data object or a DataProxy object based on a standAlone property that was set by the startup aguments.
If you are using the thin client model, you would not expose DBAccess to you client. The Business class on the server would wrap a Data object and the Business class would be exposed over RMI to the client, again using the Proxy
pattern and a Factory method. You get to define that one yourself so you can code it as you see fit. People have passed using this model, but I wouldn't risk it since I don't fell I could honestly justify the choice.