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

Sun Microsystems Inc.

EJB 1.1 Deployment descriptor

Enterprise JavaBeans 2.0, Public Draft

Deployment descriptor example

<!ATTLIST resource-ref id ID #IMPLIED> <!ATTLIST role-link id ID #IMPLIED> <!ATTLIST role-name id ID #IMPLIED> <!ATTLIST security-role id ID #IMPLIED> <!ATTLIST security-role-ref id ID #IMPLIED> <!ATTLIST session-type id ID #IMPLIED> <!ATTLIST session id ID #IMPLIED> <!ATTLIST small-icon id ID #IMPLIED> <!ATTLIST transaction-type id ID #IMPLIED> <!ATTLIST trans-attribute id ID #IMPLIED>

B.6 Deployment descriptor example

The following example illustrates a sample deployment descriptor for the ejb-jar containing the Wombat’s assembled application described in Section 3.2.

5/31/00

496

Sun Microsystems Inc

Deployment descriptor example

Enterprise JavaBeans 2.0, Public Draft

EJB 1.1 Deployment descriptor

Note: The text in the <description> elements has been formatted by adding whitespace to appear properly indented in this document. In a real deployment descriptor document, the <description> elements would likely contain no extra whitespace characters.

<!DOCTYPE ejb-jar PUBLIC “-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN” “http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd”> <ejb-jar>

<description>

This ejb-jar file contains assembled enterprise beans that are part of employee self-service application.

</description>

<enterprise-beans> <session>

<description>

The EmployeeService session bean implements a session between an employee and the employee self-service application.

</description> <ejb-name>EmployeeService</ejb-name> <home>com.wombat.empl.EmployeeServiceHome</home> <remote>com.wombat.empl.EmployeeService</remote>

<ejb-class>com.wombat.empl.EmployeeServiceBean</ejb-class> <session-type>Stateful</session-type> <transaction-type>Bean</transaction-type>

<env-entry> <env-entry-name>envvar1</env-entry-name> <env-entry-type>String</env-entry-type> <env-entry-value>some value</env-entry-value>

</env-entry>

<ejb-ref> <ejb-ref-name>ejb/EmplRecords</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>

<ejb-ref> <ejb-ref-name>ejb/Payroll</ejb-ref-name> <ejb-ref-type>Entity</ejb-ref-type> <home>com.aardvark.payroll.PayrollHome</home> <remote>com.aardvark.payroll.Payroll</remote> <ejb-link>AardvarkPayroll</ejb-link>

</ejb-ref>

<ejb-ref> <ejb-ref-name>ejb/PensionPlan</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <home>com.wombat.empl.PensionPlanHome</home> <remote>com.wombat.empl.PensionPlan</remote>

</ejb-ref>

<resource-ref> <description>

This is a reference to a JDBC database.

497

5/31/00

Sun Microsystems Inc.

EJB 1.1 Deployment descriptor

Enterprise JavaBeans 2.0, Public Draft

Deployment descriptor example

EmployeeService keeps a log of all transactions performed through the EmployeeService bean for auditing purposes.

</description> <res-ref-name>jdbc/EmployeeAppDB</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth>

</resource-ref> </session>

<session>

<description>

The EmployeeServiceAdmin session bean implements the session used by the application’s administrator.

</description>

<ejb-name>EmployeeServiceAdmin</ejb-name> <home>com.wombat.empl.EmployeeServiceAdminHome</home> <remote>com.wombat.empl.EmployeeServiceAdmin</remote> <ejb-class>com.wombat.empl.EmployeeServiceAdmin-

Bean</ejb-class> <session-type>Stateful</session-type> <transaction-type>Bean</transaction-type>

<resource-ref> <description>

This is a reference to a JDBC database. EmployeeService keeps a log of all transactions performed through the EmployeeService bean for auditing purposes.

</description> <res-ref-name>jdbc/EmployeeAppDB</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth>

</resource-ref> </session>

<entity>

<description>

The EmployeeRecord entity bean encapsulates access to the employee records.The deployer will use container-managed persistence to integrate the entity bean with the back-end system managing

the employee records. </description>

<ejb-name>EmployeeRecord</ejb-name> <home>com.wombat.empl.EmployeeRecordHome</home> <remote>com.wombat.empl.EmployeeRecord</remote> <ejb-class>com.wombat.empl.EmployeeRecordBean</ejb-class> <persistence-type>Container</persistence-type> <prim-key-class>com.wombat.empl.EmployeeID</prim-key-class> <reentrant>True</reentrant>

<cmp-field><field-name>employeeID</field-name></cmp-field> <cmp-field><field-name>firstName</field-name></cmp-field> <cmp-field><field-name>lastName</field-name></cmp-field>

5/31/00

498

Sun Microsystems Inc

Deployment descriptor example

Enterprise JavaBeans 2.0, Public Draft

EJB 1.1 Deployment descriptor

<cmp-field><field-name>address1</field-name></cmp-field> <cmp-field><field-name>address2</field-name></cmp-field> <cmp-field><field-name>city</field-name></cmp-field> <cmp-field><field-name>state</field-name></cmp-field> <cmp-field><field-name>zip</field-name></cmp-field> <cmp-field><field-name>homePhone</field-name></cmp-field> <cmp-field><field-name>jobTitle</field-name></cmp-field> <cmp-field><field-name>managerID</field-name></cmp-field> <cmp-field><field-name>jobTitleHis-

tory</field-name></cmp-field> </entity>

<entity>

<description>

The Payroll entity bean encapsulates access to the payroll system.The deployer will use container-managed persistence to integrate the entity bean with the back-end system managing payroll information.

</description>

<ejb-name>AardvarkPayroll</ejb-name> <home>com.aardvark.payroll.PayrollHome</home> <remote>com.aardvark.payroll.Payroll</remote> <ejb-class>com.aardvark.payroll.PayrollBean</ejb-class> <persistence-type>Bean</persistence-type> <prim-key-class>com.aardvark.payroll.Accoun-

tID</prim-key-class> <reentrant>False</reentrant>

<security-role-ref> <role-name>payroll-org</role-name> <role-link>payroll-department</role-link>

</security-role-ref> </entity>

</enterprise-beans>

<assembly-descriptor> <security-role>

<description>

This role includes the employees of the enterprise who are allowed to access the employee self-service application. This role is allowed only to access his/her own information.

</description> <role-name>employee</role-name>

</security-role>

<security-role> <description>

This role includes the employees of the human resources department. The role is allowed to view and update all employee records.

</description> <role-name>hr-department</role-name>

</security-role>

<security-role>

499

5/31/00

Sun Microsystems Inc.

EJB 1.1 Deployment descriptor

Enterprise JavaBeans 2.0, Public Draft

Deployment descriptor example

<description>

This role includes the employees of the payroll department. The role is allowed to view and update the payroll entry for any employee.

</description> <role-name>payroll-department</role-name>

</security-role>

<security-role> <description>

This role should be assigned to the personnel authorized to perform administrative functions for the employee self-service application.

This role does not have direct access to sensitive employee and payroll information.

</description> <role-name>admin</role-name>

</security-role>

<method-permission> <role-name>employee</role-name> <method>

<ejb-name>EmployeeService</ejb-name> <method-name>*</method-name>

</method> </method-permission>

<method-permission> <role-name>employee</role-name> <method>

<ejb-name>EmployeeRecord</ejb-name> <method-name>findByPrimaryKey</method-name>

</method>

<method> <ejb-name>EmployeeRecord</ejb-name> <method-name>getDetail</method-name>

</method>

<method> <ejb-name>EmployeeRecord</ejb-name> <method-name>updateDetail</method-name>

</method> </method-permission>

<method-permission> <role-name>employee</role-name> <method>

<ejb-name>AardvarkPayroll</ejb-name> <method-name>findByPrimaryKey</method-name>

</method>

<method> <ejb-name>AardvarkPayroll</ejb-name> <method-name>getEmployeeInfo</method-name>

</method>

<method> <ejb-name>AardvarkPayroll</ejb-name>

<method-name>updateEmployeeInfo</method-name> </method>

</method-permission>

5/31/00

500

Sun Microsystems Inc

Deployment descriptor example

Enterprise JavaBeans 2.0, Public Draft

EJB 1.1 Deployment descriptor

<method-permission> <role-name>admin</role-name> <method>

<ejb-name>EmployeeServiceAdmin</ejb-name> <method-name>*</method-name>

</method> </method-permission>

<method-permission> <role-name>hr-department</role-name> <method>

<ejb-name>EmployeeRecord</ejb-name> <method-name>create</method-name>

</method>

<method> <ejb-name>EmployeeRecord</ejb-name> <method-name>remove</method-name>

</method>

<method> <ejb-name>EmployeeRecord</ejb-name> <method-name>changeManager</method-name>

</method>

<method> <ejb-name>EmployeeRecord</ejb-name> <method-name>changeJobTitle</method-name>

</method>

<method> <ejb-name>EmployeeRecord</ejb-name>

<method-name>findByPrimaryKey</method-name> </method>

<method> <ejb-name>EmployeeRecord</ejb-name> <method-name>getDetail</method-name>

</method>

<method> <ejb-name>EmployeeRecord</ejb-name> <method-name>updateDetail</method-name>

</method> </method-permission>

<method-permission> <role-name>payroll-department</role-name> <method>

<ejb-name>AardvarkPayroll</ejb-name> <method-name>findByPrimaryKey</method-name>

</method>

<method> <ejb-name>AardvarkPayroll</ejb-name> <method-name>getEmployeeInfo</method-name>

</method>

<method> <ejb-name>AardvarkPayroll</ejb-name>

<method-name>updateEmployeeInfo</method-name> </method>

<method> <ejb-name>AardvarkPayroll</ejb-name> <method-name>updateSalary</method-name>

</method> </method-permission>

501

5/31/00

Sun Microsystems Inc.

EJB 1.1 Deployment descriptor

Enterprise JavaBeans 2.0, Public Draft

Deployment descriptor example

<container-transaction> <method>

<ejb-name>EmployeeRecord</ejb-name> <method-name>*</method-name>

</method> <trans-attribute>Required</trans-attribute>

</container-transaction>

<container-transaction> <method>

<ejb-name>AardvarkPayroll</ejb-name> <method-name>*</method-name>

</method> <trans-attribute>Required</trans-attribute>

</container-transaction> </assembly-descriptor>

</ejb-jar>

5/31/00

502