Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

PortableRemoteObject.  RSS feed

 
aakash bath
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does PortableRemoteObject.narrow does.
Can i have some breif overview of it.
Regards,
aakash
 
Praveen Kumar KR
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
When using RMI-IIOP, u can't simply cast an object u recieve over the network, because the stub class file may not exist with the client.RMI-IIOP does not allow downloadable class files as CORBA does not support it.
So u need to safe cast by calling PortableRemoteObject.narrow(). This static method converts the object to the desired remote interface 4 u.Pass to narrow() the object u desire to cast and the class to which u wish to cast.The narrow() method returns the resultant object or will throw an exception.
Hope this answer ur query.
Praveen
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The narrow method returns a java.lang.Object instead of an OMG object. it is needed to call this method to hold some additional needed informations like the
IOR(reference to the remote object).
If you simply cast the object there can appear some strange errors cause he calls wrong objects and so on
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!