Dear all, I've got the following choices for my server: Data ==== public class Data extends UnicastRemoteObject RemoteData (Interface) ========== public interface RemoteData extends Remote DataServer =========== public class DataServer extends Data implements RemoteData Question ######## Is there a way to avoid extending UnicastRemoteObject in the initial Data class? Please help Thanks
Mark, Thank for your quick and witty reply I found out that I can get around that problem by calling the following in my constructor of my DataServer class UnicastRemoteObject.exportObject(this); What do you think?
Yes that works. But.. have you gotten to local mode yet? I think you will want to abstract this out farther, or is it decoupling it out farther? Well, one or the other. You might find later one, that this won't work for you. However, I am also one to go down a path, and realize later that I didn't think of something, or maybe not That's why this project is a great learning experience. On how to do things, and what works and what doesn't. Mark
Joined: Dec 18, 2001
Dear Mark, Thanks a lot for taking the time in answering, you're definitely the Red Cross of this group! I am in the process of revisiting my desing, cause all the functionality is there on the server and on the client. It's just a matter of tidying up things, and, as you said, loosening the coupling a bit. I do use a factory method to decide what to instantiate, so I'm still adament about that. However I've changed the layout on the server. Inspired by your response. I left the initial Data class intact (apart from changing the deprecated methods). Data server is my local server it extends data and has all the implementation needed (booking, criteria, locking, ... ). RemoteDataServer instantiates Data server, extends unicast (thanks mark), and provide wrapper functions around the DataServer. RemoteDataServer implements RemoteDataServerInterface that has all public methods + throwing RemoteException Now here is my problem (maybe it isn't), on the client I declare an instance of RemoteDataServerInterface and call the factory method which based on local or remote, either directly instantiates DataServer, or returns RemoteDataServer via RMI lookup.
The problem is DataServer and RemoteDataServer have to both implement RemoteDataServerInterface in order for the factory to work!. I was hoping to have a purer super interface that both sides could implement and that doesn't mention Remote, and that the factory could use. But the implementation of that sound impossible, I'm always running into class cast exception when I try it. Does this make sense or am I talking rubbish again. Thanks Najib
I was hoping to have a purer super interface that both sides could implement and that doesn't mention Remote, and that the factory could use. But the implementation of that sound impossible, I'm always running into class cast exception when I try it.
What about a DataAccess interface that has all the public methods of Data, it can extend Remote and only throw Exception. It is ok that it extends Remote and also used in the local implementation. Then have two class one for local and one for remote that implements this interface. In the remote version you can havae the methods throw the more specific RemoteException. Mark Mark
Joined: Dec 18, 2001
Mark, How about DataAccess (methods in it all throw Exception ) but doesn't extend remote. DataServer can directly implement the above. RemoteDataAccess interface extends DataAccess (methods in it throw RemoteException ) and it extends Remote. RemoteDataServer can now extends unicast and implement RemoteDataAccess. In the Factory it just returns DataAccess. It works I've tested it, but I'd still like your generous contribution on that. [ February 12, 2002: Message edited by: NAJIB COUTYA ]