permaculture playing cards*
The moose likes EJB and other Java EE Technologies and the fly likes Question on java.rmi.PortableRemoteObject Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Question on java.rmi.PortableRemoteObject" Watch "Question on java.rmi.PortableRemoteObject" New topic
Author

Question on java.rmi.PortableRemoteObject

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Why do we use the narrow() method of the PortableRemoteObject when accessing RemoteObjects? Is this a dependency on the protocol (IIOP, CORBA) for Remote access?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30076
    
149

Jothi,
You hit it right on the head. The returned object has links to CORBA/IIOP. Calling narrow() gives you an object that is safe to use locally and can be cast to your interface type.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Thanks Jeanne but can you please elaborate a bit on it?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30076
    
149

Jothi,
A couple years ago I was curious and set my debugger to the line of PortableRemoteObject.narrow() in my code and looked at the fields in the object. I saw a bunch of networking related stuff. I don't recall exactly what is in there anymore so it's hard to elaborate. You could try the same experiment if you are really curious.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Jeanne, thanks for the hint. I just want to ask you one more thing is that did you ever come across a line that talks about this in the Head First EJB? If yes could you please tell me which page is that?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Question on java.rmi.PortableRemoteObject
 
Similar Threads
Access denied Error in the Ant
access specifier and access modifier
Constructors
Summary of book
database in netbeans