bea.com | products | dev2dev | support | askBEA
 Download Docs   Site Map   Glossary 
Search

Programming WebLogic Enterprise JavaBeans

 Previous Next Contents Index View as PDF  

Overview of WebLogic Server Enterprise JavaBeans (EJBs)

The following sections provide an overview of EJBs, and how they are implemented in WebLogic Server, as well as a discussion of WebLogic Server EJB features and changes introduced in this release.

 


What Are EJBs?

Enterprise JavaBeans (EJBs) are reusable Java components that implement business logic and enable you to develop component-based distributed business applications. EJBs reside in an EJB container, which provides a standard set of services such as persistence, security, transactions, and concurrency. Enterprise JavaBeans are the standard for defining server-side components. WebLogic Server's implementation of the Enterprise JavaBeans component architecture is based on Sun Microsystems EJB specification.

WebLogic Server is compliant with the Sun J2EE specification and EJB 1.1 and EJB 2.0 specifications. While you can deploy existing EJB 1.1 beans in this version of WebLogic Server, BEA strongly recommends that any new beans you develop be EJB 2.0 beans.

The information in this guide is focused on the EJB 2.0 implementation. Features and behaviors specific to EJB 1.1 are covered in Important Information for EJB 1.1 Users.

Types of EJBs

There are four types of EJBs:

EJB Components

An entity or session EJB consists of these main components:

A message-driven EJB consists only have a bean class. It has neither component interfaces nor a primary key class.

The EJB Container

The EJB container takes care of "behind-the-scenes" system-level work so that beans do not have to. WebLogic Server manages the EJB container, providing EJBs access to system-level services such as database management, lifecycle management, security, and transaction services.

The WebLogic Server EJB Container and Supported Services, examines the WebLogic Server EJB container in detail.

WebLogic Server Container-Managed Persistence Service - Basic Features, and WebLogic Server Container-Managed Persistence Service - Advanced Features, help you design your application to make the best use of the container-managed persistence service the WebLogic Server EJB container provides.

 


Creating EJBs: Main Steps

To create an EJB, you code a distributed application's business logic into the EJB's implementation class; specify the deployment parameters in deployment descriptor files; and package the EJB into a JAR file. You can then deploy the EJB individually from a JAR file, or package it along with other EJBs and a Web application into an EAR file, which you then deploy on WebLogic Server. Finally you monitor the health of your running EJBs and tune them as needed. The following are the specific steps:

  1. Design the EJBs. Decide which type of beans you want your application to use, how many, where they will be deployed, what their behavior will be, etcetera. This process includes choosing values for the elements in the EJB-relevant deployment descriptor files: ejb-jar.xml, weblogic-ejb-jar.xml and weblogic-cmp-rdbms-jar.xml.

    Use the design process documented in this guide to design the EJBs that are deployed in the WebLogic Server environment. For more information on the design process, see Designing Session and Entity EJBs, and Designing Message-Driven Beans.

  2. Write the EJB code. The result of this process is an ejb.jar file that contains one or more EJB java files.
  3. Compile the EJB java files into class files with a Java compiler, typically javac.
  4. Generate deployment descriptors.
  5. Edit the deployment descriptors as needed to fine-tune the behavior of your EJBs.

Note: You have a number of different tools to choose from for generating and editing deployment descriptors. See WebLogic Server EJB Tools.

  1. Generate stub and skeleton files and EJB container classes with the appc tool.
  2. Package the EJB class files and deployment descriptors. This means placing the class files and deployment descriptor files into their proper locations in preparation for deployment. Packaging can also include archiving the class files and deployment descriptors into JARs.

    Packaging EJBs for the WebLogic Server Container, discusses packaging in detail.

    The weblogic-ejb-jar.xml Deployment Descriptor, and The weblogic-cmp-rdbms- jar.xml Deployment Descriptor, examine deployment descriptor files and their elements in detail.

  3. Deploy the EJBs on WebLogic Server from a JAR file or package them along with other EJBs and WebLogic Server components in a EAR file, which you then deploy on WebLogic Server. Packaging EJBs for the WebLogic Server Container, discusses deployment in detail.
  4. Monitor your EJBs via the WebLogic Server Administration console. Tune their behavior as needed by adjusting the appropriate deployment descriptor values and redeploying. See EJB Runtime Monitoring, and the "Tuning WebLogic Server EJBs" chapter of the WebLogic Server Performance and Tuning Guide.

    For more information on the deployment descriptors, see The weblogic-ejb-jar.xml Deployment Descriptor, and The weblogic-cmp-rdbms- jar.xml Deployment Descriptor.

    For more information on container-managed persistence, see WebLogic Server Container-Managed Persistence Service - Basic Features, and WebLogic Server Container-Managed Persistence Service - Advanced Features. For more information on the deploy process, see Packaging EJBs for the WebLogic Server Container.

 


EJB Developer Tools

BEA provides several tools you can use to help you create and configure EJBs.

ANT Tasks to Create Skeleton Deployment Descriptors

You can use the WebLogic ANT utilities to create skeleton deployment descriptors. These utilities are Java classes shipped with your WebLogic Server distribution. The ANT task looks at a directory containing an EJB and creates deployment descriptors based on the files it finds in the ejb.jar file. Because the ANT utility does not have information about all of the desired configurations and mappings for your EJB, the skeleton deployment descriptors the utility creates are incomplete. After the utility creates the skeleton deployment descriptors, you can use a text editor, an XML editor, or the EJB Deployment Descriptor Editor in the Administration Console to edit the deployment descriptors and complete the configuration of your EJB.

For more information on using ANT utilities to create deployment descriptors, see Packaging Enterprise JavaBeans .

WebLogic Builder

WebLogic Builder is a development tools that provides a visual environment for you to edit an application's deployment descriptor XML files. You can use WebLogic Builder's interface to view these XML files as you edit them, but you will not need to make textual edits to the XML files. For instructions on how to use the WebLogic Builder tool, see WebLogic Builder.

EJBGen

EJBGen is an Enterprise JavaBeans 2.0 code generator. You can annotate your Bean class file with javadoc tags and then use EJBGen to generate the Remote and Home classes and the deployment descriptor files for an EJB application. For more information on EJBGen and a list of the supported javadoc tags, see EJBGen.

DDInit

DDInit examines the contents of a staging directory and builds the standard J2EE and WebLogic-specific deployment descriptors based on the EJB classes. See DDInit.

weblogic.Deployer

The weblogic.Deployer command-line tool allows you to initiate deployment from the command line, a shell script, or any automated environment other than Java.

For instructions on using weblogic.Deployer and a list of the commands, see Deploying Using weblogic.Deployer.

XML Editor

The XML editor is a simple, user-friendly tool from Ensemble for creating and editing XML files. It can validate XML code according to a specified DTD or XML Schema. You can use the XML editor on Windows or Solaris machines and download it from the Dev2Dev Online.

 


Implementation of Java Specifications

WebLogic Server is compliant with the following Java Specifications.

 


EJB Features and Changes in this Release

The following EJB features and changes are introduced in this release of WebLogic Server.

Performance Monitoring Improvements

This release introduces greatly improved monitoring of performance, via new tab pages in the WebLogic Server Administration Console.

Performance monitoring is discussed in detail in EJB Runtime Monitoring.

appc

appc provides a single tool for compiling and validating a J2EE ear file, an ejb-jar file or war file for deployment. Previously, a user wanting to compile all modules within an ear file had to extract the individual components of an ear and manually execute the appropriate compiler (jspc or ejbc) to prepare the module for deployment. appc automates this process and performs additional pre-deployment validation checks not previously performed.

appc is discussed in detail in appc.

Batch Operations

WebLogic Server now supports batch updates and deletes, in addition to the existing batch insert (previously known as "bulk insert") support. In addition, the EJB container now prevents exceptions by performing dependency checks between batch operations. See Batch Operations.

Automatic Database Detection

As application developers develop their entity beans, the underlying table schema must change. With the automatic database detection feature enabled, WebLogic Server automatically changes the underlying table schema as entity beans change. See Automatic Database Detection for more information on automatic database detection.

EJB QL Compiler Enhancements

Compiler error messages in EJB QL now provide a visual aid to identify which part of the query is in error and allow the reporting of more than one error per compilation. See EJB QL Error-Reporting Enhancements for more information on this feature.

Performance Improvements

WebLogic Server provides improved performance for EJB bulk updates, optimistic concurrency, field groups, relationship caching, and EJB redeployment.

Reloadable EJB Modules

With the Reloadable J2EE Modules feature, you can also redeploy EJBs independently of other components in an Enterprise Application. For more information, see Developing WebLogic Server Applications.

EJB Deployment Assistants

The Administration Console provides an EJB Module Deployment Assistant to help you deploy EJBs. For more information, see the EJB section of the Administration Console Online Help.

New dbms-column-type Values

WebLogic Server supports two additional values for the dbms-column-type element in weblogic-cmp-rdbms.xml: LongString and SybaseBinary. See dbms-column-type for details.

sql-select-distinct Deprecated

This version of WebLogic Server deprecates the sql-select-distinct element in weblogic-cmp-rdbms-jar.xml. Use the DISTINCT clause directly in finder queries instead of this XML element. For finder queries that have a DISTINCT clause, the container defers duplicate elimination to the database if FOR UPDATE is not used and filter duplicates if used.

If sql-select-distinct is set to true, but the finder query does not have a DISTINCT clause, it is equivalent to not specifying sql-select-distinct but having a DISTINCT clause in the finder query.

If sql-select-distinct is set to false, but the finder query has a DISTINCT clause, the value of sql-select-distinct is ignored.

For more information on sql-select-distinct, see sql-select-distinct.

For more information on the SELECT DISTINCT clause in EJB QL, see Using SELECT DISTINCT.

ejbc Deprecated

The ejbc compiler has been deprecated. Use appc in its place.

 

Back to Top Previous Next