File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "why no is the same !?" Watch "why no is the same !?" New topic
Author

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?
Eugene.
no more user
Ranch Hand

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

Joined: Feb 05, 2001
Posts: 17250
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
 
subject: why no is the same !?