This chapter provides an overview of the kinds of information that the bean developer and application assembler must add to the deployment descriptor before an EJB JAR can be deployed. This chapter also includes pointers to the appropriate SilverStream tool to accomplish the related tasks.
This chapter includes the following sections:
The EJB JAR file is the deployment vehicle for Enterprise JavaBeans. The EJB JAR includes one or more EJB Java class files, their home and remote interfaces, and a deployment descriptor.
The deployment descriptor is an XML description of the contents of the EJB JAR. It initially contains information that a bean developer provides about the constituent beans. By the time it is deployed, it will contain all of the information that the EJB deployer and the EJB container need to create the proper runtime environment for the Enterprise JavaBeans contained in the EJB JAR.
The EJB specification defines the structure of the deployment descriptor as an XML file with its own DTD. The deployment descriptor contents consist of two parts:
The deployment descriptor entries that define the bean's structural information allow the application assembler and/or the deployer to customize some of the behavior of the EJB without changing the source code. They also allow the deployment tool to create the necessary home and remote objects for the constituent EJBs.
Required structural information
The deployment descriptor requires these entries for each EJB regardless of its type:
A textual description of the bean. You can provide any information that might be useful for application assemblers or deployers. |
Session beans also require the following additional information
Specifies whether the bean is a stateful or stateless session bean. | ||
Specifies who manages the bean's transactions; the bean or the container. |
Entity beans require this additional information:
Each bean can optionally include entries for the following:
Environment properties
Environment properties allow the application assembler or deployer to map static data or variables to values that are meaningful to the operational environment. The bean developer must add entries and optionally initial values for each environment property that the bean references. The entries are added to the <env-entry> node of the deployment descriptor. They include:
At deployment time, SilverStream registers the environment property with JNDI so it can be located by the bean at runtime.
For more information on creating and setting the value of environment properties using the SilverStream IDE, see the chapter on the JAR Designer in the online Tools Guide. For an example of how environment properties are used, see the EJB section of the online Application Techniques.
Bean references
Bean references allow one or more EJBs to find the home object of other EJBs using a logical reference instead of an actual (and possibly not known) JNDI name. The bean developer must add entries for each of the EJB home objects that a bean references in the <ejb-ref> node of the deployment descriptor
For more information on creating and setting the values of bean references using the SilverStream IDE, see the chapter on the JAR Designer in the online Tools Guide. For an example of how bean references are used, see the EJB section of the online Application Techniques.
Resource references
Resource references allow access to database connections in a connection pool. They allow the application assembler or deployer to customize the reference to a specific database that is available to the SilverStream Server in the operational environment. The values are added to the <resource-ref> node of the deployment descriptor and have the values shown below.
For more information on creating and setting the values of resource references using the SilverStream IDE, see the chapter on the JAR Designer in the online Tools Guide. For an example of how resource references are used, see the EJB section of the online Application Techniques.
Role references
Role references allow the bean developer to use logical role names within the bean's code. The application assembler or deployer can then map the reference to an actual role in the operational environment. The following entries are made in the <security-role-ref> node of the deployment descriptor.
For more information on creating and setting the values of role references using the SilverStream IDE, see the chapter on the JAR Designer in the online Tools Guide. For an example of how role references are used, see the EJB section of the online Application Techniques.
The deployment descriptor entries that define the bean's application assembly information apply to the entire EJB JAR. The application assembler is responsible for providing the information that reflects the values in the operational environment. These values are added to the <assembly-descriptor> node of the deployment descriptor.
Application assembly entries include the following:
Roles provide a way to group security permissions for a type of user (such as managers) or a group of users that will use an application in the same way (such as bank tellers). The application assembler must specify roles if the application requires that you set method permissions or are using role references. At deployment time, the deployer can map the role to an actual entity in the operational environment. The following values are added to the <security-role> node of the deployment descriptor
For more information on creating roles using the SilverStream IDE, see the chapter on the JAR Designer in the online Tools Guide.
Method permissions allow you to specify the methods that users in a specific role can execute.
The following values must be added to the <method-permission> node of the deployment descriptor.
Rules for specifying method permissions
For more information on using the SilverStream IDE, see the chapter on the JAR Designer in the online Tools Guide.
Transaction attributes define a method's ability to participate in a transaction context. They are defined in the <container-transaction> node of the deployment descriptor and include the following entries.
The EJB specification defines the following values for the <trans-attribute> entries.
For more information on setting transaction attributes using the SilverStream IDE, see the chapter on the JAR Designer in the online Tools Guide.
You can create the EJB JAR and deployment descriptor using the SilverStream JAR Designer, or you can create one externally. You can use the JAR Designer to modify the externally created deployment descriptor using the JAR Designer tools.
For more information on importing or creating an EJB JAR using the SilverStream IDE, see the chapter on the JAR Designer. For information on importing an EJB JAR without using the IDE, see the chapter on SilverCmd (specifically the ImportMedia command). Both chapters are included in the online Tools Guide.
During application assembly, you might want to combine EJBs from one or more EJB JARs into an application. Because SilverStream requires that any bean references resolve to beans in the same EJB JAR, you might need to create a new composite EJB JAR that includes the contents of two or more different EJB JARs.
You should create the composite EJB JAR as part of your application assembly and not part of the deployment process.
Importing EJB JARs that include references to other JARs
If you have an EJB JAR file that you created outside of the SilverStream environment and it relies on classes in another EJB JAR or standard JAR, you will encounter an error when trying to import the JAR files.
When you import an EJB JAR file, SilverStream validates all of the classes in the EJB JAR. SilverStream will not be able to find the referenced classes during the import and will fail because there is no way to associate the secondary JAR with the EJB JAR during the import.
To make the import possible, you have the following options:
SilverCmd +cp:a c:\myUtility.JAR ImportMedia...
SilverCmd +cp:a c:\myUtility.JAR DeployEJB...
SilverStream provides the SilverCmd ConvertEJB tool to convert EJB 1.0 serialized deployment descriptors to EJB 1.1 XML deployment descriptors.
What the conversion does not do
The conversion does not change any of the code in your bean classes or interfaces. Because EJB 1.0 relies on JDK1.1 and EJB 1.1 beans rely on JDK1.2. It is possible that your beans use deprecated or unsupported language elements.
If your beans do use unsupported features, they will not run properly in an EJB 1.1 compliant environment. For example, the javax.jts.UserTransaction has been deprecated (in EJB 1.1 it is javax.trans.UserTransaction). Since the javax.jts package has been deprecated, SilverStream does not include it in the classpath for SilverStream 3.0. This means that attempts to use some EJB 1.0 beans might result in NoClassDefFoundErrors.