Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Enterprise JavaBeans™ Specification, Version 2.0 - Sun Microsystems.pdf
Скачиваний:
14
Добавлен:
24.05.2014
Размер:
2.71 Mб
Скачать

Sun Microsystems Inc.

Enterprise bean environment

Enterprise JavaBeans 2.0, Public Draft

EJB references

19.3.2 Application Assembler’s responsibilities

The Application Assembler can use the ejb-link element in the deployment descriptor to link an EJB reference to a target enterprise bean. The link will be observed by the deployment tools.

The Application Assembler specifies the link between two enterprise beans as follows:

The Application Assembler uses the optional ejb-link element of the ejb-ref element of the referencing enterprise bean. The value of the ejb-link element is the name of the target enterprise bean. (It is the name defined in the ejb-name element of the target enterprise bean.) The target enterprise bean can be in any ejb-jar file in the same J2EE application as the referencing application component.

Alternatively, to avoid the need to rename enterprise beans to have unique names within an entire J2EE application, the Application Assembler may use the following syntax in the ejb-link element of the referencing application component. The Application Assembler specifies the path name of the ejb-jar file containing the referenced enterprise bean and appends the ejb-name of the target bean separated from the path name by # . The path name is relative to the referencing application component jar file In this manner, multiple beans which may have the same name are uniquely identified as the Application Assembler cannot change ejb-names.

The Application Assembler must ensure that the target enterprise bean is type-compatible with the declared EJB reference. This means that the target enterprise bean must be of the type indicated in the ejb-ref-type element, and that the home and remote interfaces of the target enterprise bean must be Java type-compatible with the interfaces declared in the EJB reference.

5/31/00

388

Sun Microsystems Inc

EJB references

Enterprise JavaBeans 2.0, Public Draft

Enterprise bean environment

The following illustrates an ejb-link in the deployment descriptor.

...

<enterprise-beans> <session>

...

<ejb-name>EmployeeService</ejb-name> <ejb-class>

com.wombat.empl.EmployeeServiceBean </ejb-class>

...

<ejb-ref> <ejb-ref-name>ejb/EmplRecord</ejb-ref-name> <ejb-ref-type>Entity</ejb-ref-type> <home>com.wombat.empl.EmployeeRecordHome</home> <remote>com.wombat.empl.EmployeeRecord</remote> <ejb-link>EmployeeRecord</ejb-link>

</ejb-ref>

...

</session>

...

<entity> <ejb-name>EmployeeRecord</ejb-name>

<home>com.wombat.empl.EmployeeRecordHome</home>

<remote>com.wombat.empl.EmployeeRecord</remote>

...

</entity>

...

</enterprise-beans>

...

The Application Assembler uses the ejb-link element to indicate that the EJB reference “EmplRecord” declared in the EmployeeService enterprise bean has been linked to the EmployeeRecord enterprise bean.

The following example illustrates using the ejb-link element to indicate an enterprise bean reference to the ProductEJB enterprise bean that is in the same J2EE application unit but in a different ejb-jar file.

<entity>

...

<ejb-name>OrderEJB</ejb-name> <ejb-class>

com.wombat.orders.OrderBean </ejb-class>

...

<ejb-ref> <ejb-ref-name>ejb/Product</ejb-ref-name> <ejb-ref-type>Entity</ejb-ref-type> <home>com.acme.orders.ProductHome</home> <remote>com.acme.prders.Product</remote>

<ejb-link>../products/product.jar#ProductEJB</ejb-link> </ejb-ref>

...

</entity>

389

5/31/00