Originally posted by James Turner:
Hi guys,
I have a problem with invoking RMI toString, equals and hashCode methods on my remote database. When I invoke them I get the toString, equals and hashCode implementations of the stub and not the actual database.
I cannot make the toString, equals or hashCode methods remote because I cannot add a RemoteException to the method signatures.
I have found that RMI provides a RemoteRef class that is encapsulated within the stub which implements remoteToString, remoteEquals and remoteHashCode methods these, in my understanding will call the remote objects corresponding methods and not that of the stub itself.
Does anyone know how to use this method of calling the remote objects toString, equals and hashCode? As all the code samples I have seen don't seem to work.
Any RMI experts out there??...
Below is a code sample I have found and tried to use, it dosn't work and seems overly complicated. I hope anyone here knows about how this is done.
Thanx for your help.
James.
The usual solution to this to to write an adapter that adds the required exceptions and possibly tidies up a lot of other sins in that interface provided with the project. Then you can use the adapter over RMI.
Do a search on IOException for lots of discussion on this. Some people take this so far that they don't even expose the provided interface to the client. They call this a "thin client" solution.
My choice is to go with the rich client and use sockets. I use a runtime exception to wrap the IOExceptions.