Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why no is the same !?

 
no more user
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in my early design, there are one object named DBConnection, exposed with rebind method.
this obj encapsulate de data class which accessing the database directly to satisfy the clients requests..
if all clients accessing data class for the same object ..

dbInterface = (RemoteClient)Naming.lookup("rmi://"+url+"/dbConn");
dbInterface2 = (RemoteClient)Naming.lookup("rmi://"+url+"/dbConn");
if (dbInterface == dbInterface2) { System.out.println("equals"); }

the objects no have to be the same?
why equals not printed?
thanks all again
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

if (dbInterface == dbInterface2) { System.out.println("equals"); }

How about overriding the equals() method of the RemoteClient class and using
if (dbInterface.equals(dbInterface2)) instead?
Eugene.
 
no more user
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hein
but the references no refer to the same object?!
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because the actual references are pointing to the stubs(proxy), not the actual object on the server.
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic