This subsection describes how to search the Enterprise Beans or J2EE resources that are assigned optional names, from the client.
This subsection describes the specification method in the client source and the settings in the search destination object when an Enterprise Bean or J2EE resource that is assigned an optional name is searched.
In the client source, you specify the optional name of the search destination object as the name to be looked up. In the search destination object, you use the annotation or property file to set up the corresponding optional name.
The following figure shows the relation between the coding of the source at the search source and the settings in the search destination object.
Figure 2-8 Relation between the settings for the client source and the search destination object
The following is an example of coding in the client when an optional name is used to search an Enterprise Bean. In this example, an EJB home object specifying an optional name "MyCart" is searched.
... |
The operations after acquiring the EJB home objects are similar to the operations for the EJB home objects acquired without using the optional names.
The following figure shows the procedure of lookup and acquisition of objects when you look up the EJB home object references.
Figure 2-9 Procedure of lookup and acquisition of objects for the EJB home object references
The following is an example of coding in the client when an optional name is used to search a J2EE resource. In this example, a J2EE resource specifying an optional name "jdbc/DBOpt" is searched.
Context initCtx = new InitialContext(); |
Note that the same operations are executed after acquiring the J2EE resource objects that are executed for the objects acquired without using the optional names.