• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PortableRemoteObject.narrow

 
Amieya Prabhaker
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What stuff do I need to know about PortableRemoteObject.narrow with regards RMI and (/vs) RMI/IIOP.

How does PortableRemoteObject.narrow behave differently?

Looking at the EJB2.0 spec section 6.10 the last statement states: "Programs using the cast operator for narrowing the remote and remote home interfaces are likely to fail if the Container implementation uses RMI-IIOP as the underlying communication transport."
 
paresh vernekar
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wasn't able to understand your first question.The answer to your second one would be :
The lookup operation may not necessarily return an object that implements the home interface.The duty of the narrow operation is to take the object returned by the lookup operation and return something that implements the specified home interface.Hence the need to perform the narrow operation
 
Amieya Prabhaker
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first question was how/why this object behaves differently in RMI/IIOP.

As per the spec it says narrow will fail in RMI/IIOP.
 
prasad kulkarni
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you want to ask exactly?
Do you want to know difference between RMI & RMI-iiop ?
 
Amieya Prabhaker
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The difference between the behaviour of the narrow method in RMI vs RMi-IIOP.
 
Rajesh Chande
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think Ameiya is trying to get the understanding for the following statement from specification Refer the "Note":

===========================

A client program that is intended to be interoperable with all compliant EJB Container implementations
must use the javax.rmi.PortableRemoteObject.narrow(...) method to perform
type-narrowing of the client-side representations of the remote home and remote interfaces.
Note: Programs using the cast operator for narrowing the remote and remote home interfaces are likely
to fail if the Container implementation uses RMI-IIOP as the underlying communication transport.

===========================

What does the Note imply?

Ameiya correct me, if I am wrong.
 
Patrick Williams
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's see if I understand the question correctly.

Using straight RMI utilizes a protocol called JRMP and you can make a safe assumption that both the object producer and consumer are both using Java. In this case, you could do a direct cast and not have to use narrow. Using the local interfaces on EJB is an example of this.

Using RMI-IIOP can be used when the object producer is using CORBA. A Java consumer would perform the cast by perform after using the narrow method on the remote CORBA producer object. This is required when using the remote interfaces over EJB.

HTH and I invite anyone to please correct me if I am inaccurate in any way.
 
Rajesh Chande
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am confused here..

At one place in the specification it says...
Pg: 385 section 19.1
==============
The EJB specification further constrains the Java RMI types that can be used by enterprise beans to be legal RMI-IIOP types [7]. This makes it possible for EJB Container implementors to use RMI-IIOP as the object distribution protocol.
==============

and at other place we have the above Note:
==============
Note: Programs using the cast operator for narrowing the remote and remote home interfaces are likely to fail if the Container implementation uses RMI-IIOP as the underlying communication transport.
==============

Is it not contradicting?
 
Patrick Williams
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tiro, I don't think that it is contradicting the way I read that (I could be wrong). I think that the second note is saying that "If you do an explicit cast instead of using PortableRemoteObject.narrow() when trying to use an object transferred over RMI-IIOP then it will fail". The first note simply says to use RMI-IIOP compliant types across the board so that there are no unforeseen problems when using RMI-IIOP in conjunction with EJB.

HTH
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic