Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g (10.1.3.5.0) Part Number E13981-01 |
|
|
View PDF |
In a clustered OC4J architecture or a single-instance OC4J architecture with both Web tier and EJB tier on the same OC4J instance, you can define an EJB reference to the remote interface of a target enterprise bean using one of the following approaches (in increasing order of assembly and deployment flexibility):
Configure an <ejb-ref>
element in the appropriate client EJB deployment descriptor that specifies the actual name of the target bean (see "Configuring ejb-ref in the Client: No Indirection").
Configure an <ejb-ref>
element in the appropriate client EJB deployment descriptor that specifies a logical name and an <ejb-link>
element that associates this logical name with the actual bean (see "Configuring ejb-ref in the Client: Using ejb-link to Resolve Indirection").
Configure an <ejb-ref>
element in the appropriate client EJB deployment descriptor that specifies a logical name and an <ejb-ref-mapping>
in the appropriate OC4J-specific deployment descriptor that associates this logical name with the actual bean (see "Configuring ejb-ref in the Client: Using orion-ejb-jar.xml ejb-ref-mapping to Resolve Indirection").
Note:
In EJB 3.0, an environment reference to a target enterprise bean is not needed. You can access a target enterprise bean directly using resource injection (see "Accessing an EJB 3.0 Enterprise Bean").For an unclustered architecture, in which the Web tier and EJB tier are deployed to separate OC4J instances on different hosts, see "Configuring an Environment Reference to a Remote EJB: Unclustered Separate Web Tier and EJB Tier".
For information on looking up a target enterprise bean, see "Accessing an Enterprise Bean From a Client".
Choose this option if the bean interfaces are unique (for example, only one session bean uses the interface Cart.class
), or you do not want to use indirection that offers some assembly and deployment flexibility:
Define an <ejb-ref>
element in the appropriate client deployment descriptor (see "Where do you Configure an EJB Environment Reference?") and configure the following subelements, as Example 19-1 shows:
<ejb-ref-name>
: the actual name of the target enterprise bean.
<ejb-ref-type>
: the type of the target enterprise bean, one of Session
or Entity
.
<home>
: the package and class name of the target enterprise bean's remote home interface.
<remote>
: package and class name of the target enterprise bean's remote component interface.
Choose this option if the bean interfaces are not unique or, if you want to use indirection that offers some assembly and deployment flexibility:
Define an <ejb-ref>
element in the appropriate client deployment descriptor (see "Where do you Configure an EJB Environment Reference?") and configure the following subelements, as Example 19-2 shows:
<ejb-ref-name>
: the logical name of the target enterprise bean.
<ejb-ref-type>
: the type of the target enterprise bean, one of Session
or Entity
.
<home>
: the package and class name of the target enterprise bean's remote home interface.
<remote>
: package and class name of the target enterprise bean's remote component interface.
<ejb-link>
: the actual name of the target bean.
Choose this option, if the following is true:
The bean interfaces are not unique.
You want to use indirection that offers the most assembly and deployment flexibility.
Define an <ejb-ref>
element in the appropriate client deployment descriptor (see "Where do you Configure an EJB Environment Reference?") and configure the following subelements, as Example 19-3 shows:
<ejb-ref-name>
: the logical name of the target enterprise bean.
<ejb-ref-type>
: the type of the target enterprise bean, one of Session
or Entity
.
<home>
: the package and class name of the target enterprise bean's remote home interface.
<remote>
: package and class name of the target enterprise bean's remote component interface.
Within the orion-ejb-jar.xml
deployment descriptor, define an <ejb-ref-mapping>
element that maps the logical name to the actual name of the target bean, as Example 19-4 shows.
Example 19-4 Mapping Logical Name to Actual Name With ejb-ref-mapping
<ejb-ref-mapping name="ejb/nextVal" location="myBeans/BeanA"/>
As Figure 19-1 shows, in the <ejb-ref-mapping>
element, configure the name
attribute to match the <ejb-ref-name>
and configure the location
attribute with the actual name of the target bean. In Example 19-4, the logical name ejb/nextVal
is mapped to the actual name of the target bean myBeans/BeanA
.
Figure 19-1 Associating ejb-ref-name and ejb-ref-mapping
OC4J maps the logical name to the actual JNDI name on the client side. The server side receives the JNDI name and resolves it within its JNDI tree.