Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PortableRemoteObject narrowing

 
Pedro Erencia
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When - and why ? - it's necessary to use javax.rmi.PortableRemoteObject.narrow ?
 
Dinuka Arsakularatne
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well why it is used is to find out whether the object found through the lookup can be casted to a particular object type which is passed as the second parameter in the narrow method. If it cannot, then this method basically throws a ClassCastException.

Hope this helps
 
Pedro Erencia
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dinuka,

but what i'm asking is why it is necessary..
 
Moayad Abu Jaber
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
is necessary when the destination object need to lookup is Remote.
Now when to need to lookup referance for local component need to use context.lookup(); rather than you need to use PortableRemoteObject.narrow


I hope my information is helpful for you.
 
Dinuka Arsakularatne
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is needed to support requirements of RMI over IIOP. because CORBA supports different languages , casting is not native to CORBA. Also some languages do not support casting.

This is the explanation given in the O'reilly book.

And i disagree with the previous answer.

Hope this helps
 
Benoît de Chateauvieux
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And when do you need it ?
It's in the specs 3.2.3:
When the EJB 2.1 and earlier remote home and remote component interfaces are used, the narrowing of remote types requires the use of javax.rmi.PortableRemoteObject.narrow rather than Java language casts.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic