• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt on PortableRemoteObject.narrow()

 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand the need for doing a narrow on the object that we obtained through the JNDI lookup. My question is would the code below works (assuming the vendor uses IIOP):



I got the above code from the EJB Cookbook. I thought we shouldn't be doing a normal casting at the lookup code. But the next line does the narrowing as mandated by the EJB specifications.

Also, can we do this:



I thought the purpose of narrowing is to ensure that the object we obtained from the lookup is really EJB home that we want. Is it safe enough to do create an EJB & narrow this bean to what we want? Again, this code comes from the EJB Cookbook.
 
Tom Kucharski
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems that they made mistake in this book.
This code :

is not allowed with remote interfaces.
You can do it this way:
 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I made an effort to search for the errata, but no luck so far. I felt something amiss too. But then again, they did used the narrow() eventually, so I'm not very sure if it would work or break.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic