An EJB reference is a logical
name used by a client (or another bean) to locate the home interface
of an enterprise bean. You can define references to enterprise beans
in EJB modules, J2EE application client modules, and J2EE web modules.
About this task
It is a best practice to use
an EJB reference for any enterprise bean that you need to reference.
Using an EJB reference allows you to safely write Java™ code to look up the home interface of the
target enterprise bean without the worry of the binding changing for
the target enterprise bean. This is necessary if you need to install
the same EJB module on the same server with different bindings.
At deployment, the EJB reference is bound to the enterprise bean's
home in the target operational environment. The container makes the
application's EJB references available in a JNDI naming context.
Note: - EJB 1.1 enterprise beans and application client modules cannot
reference local interfaces of enterprise beans. They must reference
the remote interface.
- In order for a module or a bean to reference the local interface
of an enterprise bean, the referenced bean must be included in the
same enterprise application (EAR) as the module or bean that is referencing
it.
- If either local or remote references are possible, you should
use local references for runtime performance advantages.
For each EJB reference that you define, an ejb-ref element is added to the deployment descriptor.