This subsection describes the mechanism of JNDI name space mapping, and the relationship of the name specified for lookup with the JNDI name space and DD.
To invoke the Enterprise Beans with the applications executed in J2EE servers, you need to resolve the names of the Enterprise Bean references. To be precise, you resolve the names such as the names of the EJB home interface, EJB local home interface, and business interface corresponding to the Enterprise Beans.
The following two types of operations are required for resolving the names of the EJB home interfaces or business interfaces:
The mapping mechanism differs based on whether the referencing J2EE application is the same as or differs from the referenced J2EE application. The examples of resolving the names of the EJB home interface when you reference the Enterprise Bean of a different J2EE application and when you reference the Enterprise Bean of the same J2EE application are as follows:
The following figure shows an example of referencing the Enterprise Beans included in a J2EE application from a different J2EE application.
Figure 2-1 Example of referencing the Enterprise Beans included in a J2EE application from a different J2EE application
When using java:comp/env, the reference name in java:comp/env that is specified in the lookup argument of the referencing program, and the lookup name that is actually registered in the JNDI Name Space are linked by default (linked-to). Note that to specify a lookup name that is different from the name registered in the JNDI Name Space, you must use the server management commands for customization. The above figure shows a case of customization for invoking PetShopEB as ejb/PetShopBean.
When using the user-specified name space functionality, you can specify the optional name in the lookup argument of the referencing program. You need not define <ejb-ref>.
The following figure shows an example of referencing the Enterprise Beans included in a J2EE application from the same J2EE application.
Figure 2-2 Example of referencing the Enterprise Beans included in the same J2EE application
To invoke the Enterprise Beans of the same application, resolve the references by linking (linked-to) <ejb-ref-name> and ejb-name instead of resolving the references with the lookup name. Note that for the same J2EE applications, the information required for referencing is identified when the application is developed, so you can directly write ejb-name in the <ejb-link> tag of the DD.
To use a resource adapter in the applications executed on a J2EE server, you need to use lookup to resolve the names of the resource references. To be precise, you resolve the name of the factory that creates a connection to the resource manager.
The following two types of operations are required for resolving the names of the factory that creates the connection to the resource manager:
The following figure shows an example of accessing the database via DB Connector.
Figure 2-3 Example of accessing the database via DB Connector
In this example, the reference name and the display name of the resource are linked.