This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Hi, i know there are a number of similar threads, but i just dont get it! Im using RMI. My calls to the Data class may be remote or local, i think i have to make these calls transparent of location. So i need a toplevel interface with public methods throwing Exception...ok i did this. Then i Have LocalDataInterace which extends my toplevel interace to throw DataBaseExceptions and IOexceptions instead of Exception. my LocalData class can now implement this. Now the probelem is the remote version. what the hell do i do? If i extend the toplevel interace to create a new interface that throws RemoteException..but stop, i need to also extend Remote!! ugrgh bugger! Thanks For Help! Joe
Matt Cannata
Greenhorn
Joined: Mar 23, 2001
Posts: 23
posted
0
You could have an interface (I called it Database) that extends Remote, defines all Database methods and throws RemoteException and in the appropriate cases DatabaseException. Then create a RemoteServer interface that extends that interface. Have your Data class implement the Database interface, and your RMI Server class implement the RemoteServer interface. On the client side, you can treat everything as type Database. This way, you don't even have to throw Exception. Hope this helps, Matt
ruilin yang
Ranch Hand
Joined: Feb 25, 2001
Posts: 334
posted
0
Matt, It seems to me we do not need go through an interface for local access. In local access, I would just initiate a Data object locally that proceed from there. Then the remote access will go through interface according to RMI protocol. Please comments Ruilin
Aleksey Matiychenko
Ranch Hand
Joined: Apr 03, 2001
Posts: 178
posted
0
So all you need is another class (adaptor or proxy) that hides remote exceptions from client
olivier roussille
Greenhorn
Joined: May 02, 2001
Posts: 4
posted
0
I have only one interface: "RemoteData" and only one class "Data" I put the same files on the client and on the server. RemoteData extends Remote. The methods throw RemoteException, DatabaseException and IOException (not all of them). Data extends UnicastRemoteObject implements RemoteData In my program client, I have (roughly): RemoteData data; if (LocalMode) { data = Data(path of the file Db.db); } else { data = bind(the server,the data); } You know what? It works. Of course, in local mode, the methods are allowed to throw remoteException (because of the interface) but they never throw RemoteException. It is not a problem for me. Is it a problem for you? Regards, Olivier
J Hartley
Ranch Hand
Joined: Mar 29, 2001
Posts: 52
posted
0
Hmm I think I may try Oliviers Method, it looks pretty simple. I was finding it difficult to understand this problem because I was incorrectly assuming that my localData class had to be pure!, and not involoved with any fancy RMI( my LocalData would be releated to my RemoteData class because of my Top Level Interface, but it would not know about RMI). Does anyone think there is anything seriously wrong with Oliviers Method?(Dont take offense Olivier ). Cheers Joe
ruilin yang
Ranch Hand
Joined: Feb 25, 2001
Posts: 334
posted
0
I would just define another class (different name or so) for the local access doing the same thing as Data class, except not extending Remote and not extending UnicastRemote. It is very simple to implement. Please comment on my approach Thanks Ruilin
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.