Java Reference
In-Depth Information
At this point a member variable of type
EchoRemote
(our bean's remote interface)
is added to the client, this variable is annotated with the
@EJB
annotation. This
annotation is used to inject the instance of the remote interface at runtime.
In the previous versions of J2EE, it was necessary to perform a JNDI
lookup to obtain a reference to the home interface of the bean, and
then use the home interface to obtain a reference to the remote or local
interface. As we can see, the procedure to obtain a reference to an EJB has
been greatly simplified in Java EE.
Now we simply need to add a call to the
echo()
method on the remote interface,
and our client will be complete.