I am finishing up the assignment and I am uncertain about a couple of things. First of all, the directions indicate that the 'client' must implement all of the methods that the Data class does. When they speak of the client I assume that they are talking about the adapter class (local or remote). Is this what everyone else thinks too? Also, many of the methods that are implemented on the client side don't do anything. For instance, the lock and unlock methods in the local data adapter don't do anything. Is this a design flaw? Finally, I am not sure about my design structure for the connections. This is what I have: <pre> Local Mode: Data ^ | (uses) | LocalDataAdapter implements -> DataBehaviorIF ^ | (uses) | GUIController Remote Mode: Data ^ | (uses) | DataServer implements -> RemoteDataBehaviorIF ^ | (uses) | RemoteDataAdapter -> implements DataBehaviorIF ^ | GUIController </pre> The reason for the RemoteDataBehaviorIF is that the methods can throw RemoteException(s). The names of the methods are all the same in the remoteDataBehaviorIF except they have an added Remote in their name. For instance, <code>find</code> becomes <CODE>findRemote</code>. Does this look fine to everyone else?
posted 18 years ago
It seems that many people are using a single interface for communicating remotely or locally. Is it o.k. to use an interface that is extends the Remote interface and declares methods that could throw a RemoteException if they are going to be used locally? Really could use the help so I can get this baby done!
Here's what I did: interface Connection class FileConnection implements Connection class RMIConnection implements Connection when client class executes static Connection ConnectionFactory.getConnection(RMI|File); it does not care specifically which connection it uses. It polimorfically executes all methods, including lock() and unlock(). also, it's clear that in local mode your connection should not use locking, however I reused my FileConnection class the way that RMIServer uses it in threa-safe mode. To achieve that I extended Data(no locks) to SafeData(usues locks) and pass one or the other to FileConnection's constructor dending on whether it is running in local mode or being uses by RMI server in remote mode. Also, RemoteExcepton is really subclass of IOException, so your Connection interface can throws IOExceptions. My client catches IOExceptions (that are IOExceptions or RemoteException depending on mode) and throws my own ConnectionException to my business methods -- just to be politically correct.
I hope it's not too confusing. The code is really simple. [This message has been edited by Gennady Shapiro (edited October 29, 2001).]
It means our mission is in jeapordy! Quick, read this tiny ad!
Devious Experiments for a Truly Passive Greenhouse!