This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes why no is the same !? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "why no is the same !?" Watch "why no is the same !?" New topic

why no is the same !?

no more user
Ranch Hand

Joined: Aug 07, 2002
Posts: 39
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

Joined: Oct 08, 2001
Posts: 2937

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

How about overriding the equals() method of the RemoteClient class and using
if (dbInterface.equals(dbInterface2)) instead?
no more user
Ranch Hand

Joined: Aug 07, 2002
Posts: 39
but the references no refer to the same object?!
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Because the actual references are pointing to the stubs(proxy), not the actual object on the server.

Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: why no is the same !?
It's not a secret anymore!