aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Calling remote objects toString, equals and hashCode... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Calling remote objects toString, equals and hashCode..." Watch "Calling remote objects toString, equals and hashCode..." New topic
Author

Calling remote objects toString, equals and hashCode...

James Turner
Ranch Hand

Joined: May 10, 2004
Posts: 194
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.




James<br />SCJP 1.4 - 92%<br />SCJD - 93%<br />SCWCD 1.4 - 95%<br />SCBCD 1.3 - 100%<br />SCEA - 92%
James Turner
Ranch Hand

Joined: May 10, 2004
Posts: 194
I'm having a lot of trouble with this so if anyone knows...please help!

Thanx,

James.
peter wooster
Ranch Hand

Joined: Jun 13, 2004
Posts: 1033
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.
James Turner
Ranch Hand

Joined: May 10, 2004
Posts: 194
Thanx for the reply Peter...

I have done exactly what you said with my IOException's. What I want to be able to do is for example call toString() on the database's stub and have the stub call the database's toString and not use it's own implementation.

I'm really stuck here...Help needed...

Thanx,

James.
Andy Zhu
Ranch Hand

Joined: May 26, 2004
Posts: 145
Then I think you need to overwrite the toString() for the class that object instantiated. You may need to serialize that object. I don't know if this is what you are looking for.


--------<br />Andy Zhu<br />scjp 1.4<br />scjd 1.4<br />SAS Certified Programmer 9.0
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling remote objects toString, equals and hashCode...