
EJB 1.1 Casting
• In version 1.1 of the EJB spec a significant change to the underlying protocol was made.
- EJB 1.0 uses Java RMI when dealing with communications to EJBeans.
- EJB 1.1 uses RMI-IIOP, which is very similar to the end user, but requires a few changes.
• RMI over IIOP or RMI-IIOP is RMI changed to use a more universal standard.
- IIOP is Internet Inter-Orb Protocol, a standard communication protocol for ORB or CORBA vendors.
- Using RMI-IIOP allows developers to interface with Java Virtual Machines using C++, SmallTalk or
other CORBA compliant languages.
- RMI-IIOP makes it easier to integrate legacy applications with new J2EE architectures.
- RMI-IIOP introduces a few limitations because of its language independence.
• When you obtain an object reference from JNDI you will have to narrow the object instead of doing a
standard Java cast.
- The following code from our earlier example.
Foo foo = (Foo)o;
- Will be replaced with this code.
Foo foo = (Foo)PortableRemoteObject.narrow(o,Foo.class);
- The narrow method takes two parameters
1. The object to be cast.
2. A java.lang.Class reference to the type you are casting the object to.
- PortableRemoteObject is part of the javax.rmi package and will have to be imported.
- The old style casting will work for pure Java, but you might as well get used to the new more powerful
(and ugly) style.
EJB Casting
Table of Contents
Copyright (c) 2008. Intertech, Inc. All Rights Reserved. This information is to be used exclusively as an
online learning aid. Any attempts to copy, reproduce, or use for training is strictly prohibited.
Courseware
Training Resources
Tutorials