Tuesday, October 16, 2007

EJB Reference Definiton and Lookup in Oracle Application Server 10g

EJB Reference Definition

There are two way for EJB reference definition in Oracle AS:

One is define the (ejb-ref-name) together with (ejb-link) within the (ejb-ref) element. Configure (ejb-ref-name) with a logical name and configure (ejb-link) with the actual name of the target bean as shown below:

Example: Configuring ejb-ref-name with a Logical Name Resolved by ejb-link

(ejb-ref)
(ejb-ref-name)ejb/nextVal(/ejb-ref-name)
(ejb-ref-type)Session(/ejb-ref-type)
(home)myBeans.BeanAHome(/home)
(remote)myBeans.BeanA(/remote)
(ejb-link)myBeans/BeanA(/ejb-link)
(/ejb-ref)

This option provides indirection that offers assembly and deployment flexibility.

Another way is to Configure (ejb-ref-name) with a logical name and in 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 shown below:

Example: Configuring ejb-ref-name with a Logical Name Resolved by ejb-ref-mapping

(ejb-ref)
(ejb-ref-name)ejb/nextVal(/ejb-ref-name)
(ejb-ref-type)Session(/ejb-ref-type)
(home)myBeans.BeanAHome(/home)
(remote)myBeans.BeanA(/remote)
(/ejb-ref)

Example: Mapping Logical Name to Actual Name with ejb-ref-mapping

(ejb-ref-mapping name="ejb/nextVal" location="myBeans/BeanA"/)

This option provides indirection that offers the most assembly and deployment flexibility.


EJB Reference Lookup

To lookup EJB in the OAS, there are two ways too. One is using the ejb-ref (logical name in the web.xml/ejb-jar.xml) and second way is using the real location (jndi name in the server).

For sample code snippet, refer to links below:

http://download.oracle.com/docs/cd/B25221_04/web.1013/b14428/servjndi.htm#CHDGBAFJ
http://download.oracle.com/docs/cd/B25221_04/web.1013/b14427/jndi.htm#i1084614
http://download.oracle.com/docs/cd/B25221_04/web.1013/b14427/jndi.htm#CIHGAHFF

No comments:

´