This week's giveaway is in the Beginning Java forum.
We're giving away four copies of Bad Programming Practices 101 (e-book) and have Karl Beecher on-line!
See this thread for details.
Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Diffrence between narrowing and casting  RSS feed

 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When we get the remote reference we narrow the reference to the remote interface. Why is the narrowing done and how is it diffrent from object casting ?
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of the prime differences between EJB1.0 and EJB1.1 is EJB1.1 uses RMI-IIOP. Now, IIOP is not specific to a particular language. Many of the languages that IIOP supports (for ex: COBOL) do not have the concept of inheritance or polymorphism, so explicit Java casting is out of question.
However converting a more general interface to a more specific interface is necessary in object oriented programming. In CORBA this is achieved by the PortableRemoteObject which abstracts the mechanism in a protocol independent manner.
What PortableRemoteObject.narrow() returns is the stub that implements the remote interface. Since this stub is known to implement the correct type, you can now use Java's casting mechanism to cast if to the correct interface.
This is why you could use direct casting in EJB1.0 but not in EJB1.1
 
I'm still in control here. LOOK at this tiny ad!
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!