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

Sun Microsystems Inc

Overview

Enterprise JavaBeans 2.0, Public Draft

Deployment descriptor

Chapter 21 Deployment descriptor

This chapter defines the deployment descriptor that is part of the ejb-jar file. Section 21.1 provides an overview of the deployment descriptor. Sections 21.2 through 21.4 describe the information in the deployment descriptor from the perspective of the EJB roles responsible for providing the information. Section 21.5 defines the deployment descriptor’s XML DTD.

21.1 Overview

The deployment descriptor is part of the contract between the ejb-jar file producer and consumer. This contract covers both the passing of enterprise beans from the Bean Provider to Application Assembler, and from the Application Assembler to the Deployer.

An ejb-jar file produced by the Bean Provider contains one or more enterprise beans and typically does not contain application assembly instructions. An ejb-jar file produced by an Application Assembler contains one or more enterprise beans, plus application assembly information describing how the enterprise beans are combined into a single application deployment unit.

The J2EE specification defines how enterprise beans and other application components contained in multiple ejb-jar files can be assembled into an application.

425

5/31/00

Sun Microsystems Inc.

Deployment descriptor

Enterprise JavaBeans 2.0, Public Draft

Bean Provider’s responsibilities

The role of the deployment descriptor is to capture the declarative information (i.e information that is not included directly in the enterprise beans’ code) that is intended for the consumer of the ejb-jar file.

There are two basic kinds of information in the deployment descriptor:

Enterprise beans’ structural information. Structural information describes the structure of an enterprise bean and declares an enterprise bean’s external dependencies. Providing structural information in the deployment descriptor is mandatory for the ejb-jar file producer. The structural information cannot, in general, be changed because doing so could break the enterprise bean’s function.

Application assembly information. Application assembly information describes how the enterprise bean (or beans) in the ejb-jar file is composed into a larger application deployment unit. Providing assembly information in the deployment descriptor is optional for the ejb-jar file producer. Assembly level information can be changed without breaking the enterprise bean’s function, although doing so may alter the behavior of an assembled application.

21.2Bean Provider’s responsibilities

The Bean Provider is responsible for providing the structural information for each enterprise bean in the deployment descriptor.

The Bean Provider must use the enterprise-beans element to list all the enterprise beans in the ejb-jar file.

The Bean Provider must provide the following information for each enterprise bean:

Enterprise bean’s name. The Bean Provider must assign a logical name to each enterprise bean in the ejb-jar file. There is no architected relationship between this name, and the JNDI name that the Deployer will assign to the enterprise bean. The Bean Provider specifies the enterprise bean’s name in the ejb-name element.

Enterprise bean’s class. The Bean Provider must specify the fully-qualified name of the Java class that implements the enterprise bean’s business methods. The Bean Provider specifies the enterprise bean’s class name in the ejb-class element.

Enterprise bean’s home interfaces. The Bean Provider must specify the fully-qualified name of the enterprise bean’s home interface in the home element, unless the bean is a Mes- sage-driven bean.

Enterprise bean’s remote interfaces. The Bean Provider must specify the fully-qualified name of the enterprise bean’s remote interface in the remote element, unless the bean is a Message-driven bean.

Enterprise bean’s type. The enterprise bean types are: session, entity, and message-driven. The Bean Provider must use the appropriate session, entity, or message-driven element to declare the enterprise bean’s structural information.

5/31/00

426

Sun Microsystems Inc

Bean Provider’s responsibilities

Enterprise JavaBeans 2.0, Public Draft

Deployment descriptor

Re-entrancy indication. The Bean Provider must specify whether an entity bean is re-entrant or not. Session beans and Message-driven beans are never re-entrant.

Session bean’s state management type. If the enterprise bean is a Session bean, the Bean Provider must use the session-type element to declare whether the session bean is stateful or stateless.

Session or Message-driven bean’s transaction demarcation type. If the enterprise bean is a Session or a Message-driven bean, the Bean Provider must use the transaction-type element to declare whether transaction demarcation is performed by the enterprise bean or by the Container.

Entity bean’s persistence management. If the enterprise bean is an Entity bean, the Bean Provider must use the persistence-type element to declare whether persistence management is performed by the enterprise bean or by the Persistence Manager.

Entity bean’s primary key class. If the enterprise bean is an Entity bean, the Bean Provider specifies the fully-qualified name of the Entity bean’s primary key class in the prim-key-class element. The Bean Provider must specify the primary key class for an Entity with bean-managed persistence.

Entity Bean’s abstract schema name. If the enterprise bean is an Entity Bean with cmp-version 2.x, the Bean Provider must specify the abstract schema name of the entity bean using the abstract-schema-name element.

Container-managed fields . If the enterprise bean is an Entity bean with container-managed persistence, the Bean Provider must specify the container-managed fields using the cmp-fields elements.

Dependent classes. If the enterprise bean is an Entity bean with container-managed persistence, the Bean Provider must specify the dependent object classes involved in container-man- aged relationships using the dependents element.

Container-managed relationships. If the enterprise bean is an Entity bean with con- tainer-managed persistence, the Bean Provider must specify the container-managed relationships using the relationships element.

Finder and select queries. If the enterprise bean is an Entity bean with cmp-version 2.x, the Bean Provider must use the query element to specify each EJB QL finder or select query.

Environment entries. The Bean Provider must declare all the enterprise bean’s environment entries as specified in Subsection 19.2.1.

Resource manager connection factory references.The Bean Provider must declare all the enterprise bean’s resource manager connection factory references as specified in Subsection 19.4.1.

Resource environment references. The Bean Provider must declare all the enterprise bean’s references to administered objects that are associated with resources as specified in Subsection 19.5.1.

427

5/31/00

Sun Microsystems Inc.

Deployment descriptor

Enterprise JavaBeans 2.0, Public Draft

Application Assembler’s responsibility

EJB references. The Bean Provider must declare all the enterprise bean’s references to the homes of other enterprise beans as specified in Subsection 19.3.1.

Security role references. The Bean Provider must declare all the enterprise bean’s references to security roles as specified in Subsection 20.2.5.3.

Enterprise bean’s transaction scope. The Bean Provider may use the transac- tion-scope element to provider information to the container as to whether a local or distributed transaction should be used by the container for the enterprise bean and the methods that it invokes.

Message-driven bean’s destination. The Bean Provider may provide advice to the Deployer as to the desination type to which a message-driven bean should be assigned.

Message-driven bean’s message selector. The Bean Provider may declare the JMS message selector to be used in determining which messages the Message-driven bean is to receive.

Message-driven bean’s acknowledgment mode. The Bean Provider may declare the JMS acknowledgment mode option that should be used for a message-driven bean with bean managed transaction demarcation.

The deployment descriptor produced by the Bean Provider must be well formed in the XML sense, and valid with respect to the DTD in Section 21.5. The content of the deployment descriptor must conform to the semantics rules specified in the DTD comments and elsewhere in this specification. The deployment descriptor must refer to the DTD using the following statement:

<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_2_0.dtd">

[Note: Will need to update the version number used in the PUBLIC id to match the J2EE version, if different.]

21.3 Application Assembler’s responsibility

The Application Assembler assembles enterprise beans into a single deployment unit. The Application Assembler’s input is one or more ejb-jar files provided by one or more Bean Providers, and the output is also one or more ejb-jar files. The Application Assembler can combine multiple input ejb-jar files into a single output ejb-jar file, or split an input ejb-jar file into multiple output ejb-jar files. Each output ejb-jar file is either a deployment unit intended for the Deployer, or a partially assembled application that is intended for another Application Assembler.

The Bean Provider and Application Assembler may be the same person or organization. In such a case, the person or organization performs the responsibilities described both in this and the previous sections.

The Application Assembler may modify the following information that was specified by the Bean Provider:

5/31/00

428

Sun Microsystems Inc

Application Assembler’s responsibility

Enterprise JavaBeans 2.0, Public Draft

Deployment descriptor

Values of environment entries. The Application Assembler may change existing and/or define new values of environment properties.

Description fields . The Application Assembler may change existing or create new description elements.

Relationship names. If multiple ejb-jar files use the same names for relationships, it is the responsibility of the Application Assembler to modify the relationship names defined in the ejb-relation-name elements if the ejb-jar files are merged into a single ejb-jar file.

The Application Assembler must not, in general, modify any other information listed in Section 21.2 that was provided in the input ejb-jar file. In particular, the following must not be changed by the assembler.

Enterprise bean’s name. The Application Assembler should not change the enterprise bean’s name defined in the ejb-name element since EJB QL finder queries may depend on the content of this element.

Dependent class names. The value of the dependent-name element should not be changed by the Application Assembler since EJB QL finder queries may depend on the content of this element.

Remote enterprise bean’s name. The Application Assembler should not change a remote enterprise bean’s name designated by the remote-ejb-name element since EJB QL finder queries may depend on the content of this element.

Role source element. The Application Assembler should not change the content of an ejb-name, remote-ejb-name or a dependent-name element in the role-source element since they are used as references.

If the Application Assembler needs to modify the names of these elements in order to resolve name clashes during the merging two ejb-jar files into one, all ejb-ql query strings that depend on the values of these elements must be modified.

In addition, the Application Assembler may, but is not required to, specify any of the following application assembly information:

Binding of enterprise bean references. The Application Assembler may link an enterprise bean reference to another enterprise bean in the ejb-jar file or in the same J2EE application unit. The Application Assembler creates the link by adding the ejb-link element to the referencing bean. The Application Assembler uses the ejb-name of the referenced bean. If there are multiple enterprise beans which have the same name, the Application Assembler uses the path name specifying the location of the ejb-jar file that contains the referenced component. The path name is relative to the referencing ejb-jar file. The Application Assembler appends the ejb-name of the referenced bean to the path name separated by “#”. In this manner, multiple beans which may have the same name are uniquely identified.

Security roles. The Application Assembler may define one or more security roles. The security roles define the recommended security roles for the clients of the enterprise beans. The Application Assembler defines the security roles using the security-role elements.

429

5/31/00