When PortableRemoteObject.narrow() function should be called?

Discussions

EJB design: When PortableRemoteObject.narrow() function should be called?

  1. hai all., When the PortableRemoteObject.narrow() funciotn should be called to the reference of the Home interface .,
    Thanks in advance
    sundharc

  2. According to the Spec, this should always be used:

    5.9 Type narrowing
    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 home and remote interface.
    Note: Programs using the cast operator for narrowing the remote and home interfaces are likely to fail
    if the Container implementation uses RMI-IIOP as the underlying communication transport.


    In other words, your client applications *may* work if you simply cast your remote references to the home and remote interfaces, but if your environment later changes to use RMI-IIOP you will have to recode your clients to use PortableRemoteObject.narrow. So why not just do it correctly up front and avoid the trouble?
  3. 100% Correct!

    Dave Wolf
    Internet Applications Division
    Sybase