• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Calling remote objects toString, equals and hashCode...

 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 Turner
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having a lot of trouble with this so if anyone knows...please help!

Thanx,

James.
 
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic