BEA Home | Events | Solutions | Partners | Products | Services | Download | Developer Center | WebSUPPORT
| WebLogic Server Doc Home | Programming WebLogic EJB | Previous Topic | Next Topic | Contents | View as PDF

Introducing WebLogic Server Enterprise JavaBeans

WebLogic Server 6.1 includes an implementation of Sun Microsystems Enterprise JavaBeans (EJB) architecture as defined by Sun's EJB specification.

Note: WebLogic Server 6.1 is compliant with the Sun J2EE specification and EJB 1.1 specification. It also includes an implementation of the preliminary EJB 2.0 specification. Except where descriptions of EJB features and behaviors make specific mention of EJB 1.1 or EJB 2.0, all information in this guide relates to both implementation. You can deploy existing EJB 1.1 beans in this version of WebLogic Server. However, if you are developing new beans, we recommend that you develop EJB 2.0 beans.

The following sections provide an overview of the EJB features and introduce the changes in the WebLogic Server 6.1 Enterprise JavaBeans implementation:

- Overview of Enterprise JavaBeans

- Implementation of Preliminary Specifications

- WebLogic Server EJB 2.0 Support

- EJB Roles

- EJB Enhancements in WebLogic Server 6.1

- EJB Developer Tools

Overview of Enterprise JavaBeans

Enterprise JavaBeans 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.

EJB Components

An EJB consists of three main components:

- Remote interface. This interface exposes business logic to the client.

- Home interface. The EJB factory. Clients use this interface to create, find, and remove EJB instances.

- Bean class. This interface implements business logic.

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. Client applications can locate the EJB and create an instance of the bean using the bean's home interface. The client can then invoke the methods of the EJB using the EJB's remote interface. WebLogic Server manages the EJB container and provides access to system-level services such as database management, security management, and transaction services.

Types of EJBs

The EJB specification defines the following four types of Enterprise JavaBeans:

- Stateless session. An instance of these non-persistent EJBs provides a service without storing an interaction or conversation state between methods. Any instance can be used for any client. Stateless session beans can use either container-managed or bean-managed transaction demarcation.

- Stateful session. An instance of these non-persistent EJBs maintains state across methods and transactions. Each instance is associated with a particular client. Stateful session beans can use either container-managed or bean-managed transaction demarcation.

- Entity. An instance of these persistent EJBs represents an object view of the data, usually rows in a database. An entity bean has a primary key as a unique identifier. Entity. An instance of these persistent EJBs represents an object view of the data, usually rows in a database. An entity bean has a primary key as a unique identifier. Entity bean persistence can be container-managed or bean-managed, but uses container-managed transaction demarcation only.

- Message-driven. An instance of these EJBs is integrated with the Java Message Service (JMS) to enable message-driven beans to act as a standard JMS message consumer and perform asynchronous processing between the server and the JMS message producer. The WebLogic Server container directly interacts with a message-driven bean by creating bean instances and passing JMS messages to those instances as necessary. Message-driven beans can use either container-managed or bean-managed transaction demarcation.

Note: Message driven beans are part of the Sun Microsystems EJB 2.0 specification. They are not part of the EJB 1.1 specification.

Implementation of Preliminary Specifications

The following sections describe the use of WebLogic Server with non-final implementations of Java specifications.

Preliminary J2EE Specification

WebLogic Server 6.1 is available in two different versions that do one of the following:

- Enables an implementation of advanced J2EE 1.3 features along with the J2EE 1.2 features

- Enables the J2EE 1.2 features only, which is a fully compliant implementation of the J2EE 1.2 specification

These two options comply with the rules governing J2EE. Both versions offer the same container and differ only in the APIs that are available.

Preliminary EJB 2.0 Specification

The Enterprise JavaBeans 2.0 implementation in WebLogic Server is fully supported and can be used in production. However, be advised that the Sun Microsystems EJB 2.0 specification is not yet finalized, and the WebLogic Server implementation of the EJB 2.0 architecture is based on the most current public draft of this specification. Consequently once the specification is finalized, there could be changes to the Enterprise JavaBeans 2.0 implementation in future versions of WebLogic Server. These changes may cause application code developed for WebLogic Server 6.1 to be incompatible with EJB 2.0 implementations supported in future releases.

WebLogic Server EJB 2.0 Support

WebLogic Server supports an implementation of Sun Microsystems's EJB 2.0 specification and is compliant with the Sun Microsystem's EJB 1.1 specification. In most cases, you can use EJB 1.1 beans with this version of WebLogic Server. However, in a few cases you may need to migrate existing EJB deployments from earlier versions of WebLogic Server to this version of the EJB container. If necessary, see the information on DDConverter for instructions on converting the beans.

Sun Microsystem's EJB 2.0 specification supports the following new features:

- New type of EJB called message-driven bean that is a Java Messaging Service (JMS) consumer. See Using Message-Driven Beans, for more information.

- New entity EJB container-managed persistence model that provides a new way of handling container-managed persistence. See WebLogic Server Container-Managed Persistence Services, for more information.

- Model for creating container-managed relationships between entity EJBs allows you to define the relationship between the beans in the implementation classes and the deployment descriptors. See WebLogic Server Container-Managed Persistence Services, for more information.

- New standard query language called EJB-QL which you use to query EJBs and their properties. See WebLogic Server Container-Managed Persistence Services, for more information.

- New ejbSelect methods that allow an entity EJB to internally query for properties using an EJB-QL query defined in a deployment descriptor. See WebLogic Server Container-Managed Persistence Services, for more information.

- Local interfaces for session and entity beans. EJB relationships are now based on the local interface. Any EJB that participates in a relationship must have a local interface. See WebLogic Server Container-Managed Persistence Services, for more information.

- Home methods that allow you to execute a home business method that is not specific to a particular instance of an entity bean. You use the home interface to define one or more home methods for the entity bean See Designing EJBs, for more information.

EJB Roles

The process of developing EJBs is divided into the following distinct roles.

Application Roles

- Enterprise Bean Providers—Enterprise Bean Providers produce the EJBs. Their output is the ejb.jar file that contains one or more EJBs. The providers 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 EJBs.

- Application Assemblers—Application Assemblers combine the EJBs into deployable units such as JARs, EARs, or WARs. Their output is the JAR, EAR, or WAR file that contains the EJB and the application assembly instructions; these instructions are set by the EJB's deployment descriptors. The assemblers use the design process and the EJB deployment descriptor elements to assemble the deployment unit.

  For more information in the design process, see Designing EJBs. For more information in the assembly process, see Packaging EJBs for the WebLogic Server Container. For more information on the deployment descriptors, see weblogic-ejb-jar.xml Document Type Definitions, and weblogic-cmp-rdbms- jar.xml Document Type Definitions.

Infrastructure Roles

- Container Providers—Container Providers supply EJB deployment tools, container monitoring and management tools, and runtime support for deployed EJB instances. This support includes services such as transaction and security management, network distribution of clients, and scalability. The container providers use the container management process documented in this guide to provide the container.

  For more information on the container management process, see The WebLogic Server EJB Container and Supported Services.

- Persistence Manager Providers—Persistence Manager Providers are responsible for persistence support for the Entity EJBs in the container, if the EJB has container-managed persistence. This support is provided during deployment to generate the code that moves data between the EJB and a database. The persistence manager providers use the deploy process and container-managed persistence (CMP) information documented in this guide to provide container-managed persistence.

  For more information on container-managed persistence, see WebLogic Server Container-Managed Persistence Services. For more information on the deploy process, see Packaging EJBs for the WebLogic Server Container.

Deployment and Management Roles

- Deployers—Deployers, following the application assembly instructions in the deployment descriptors, deploy the EJBs contained in the JAR, EAR, or WAR file to the target environment. The target environment includes the WebLogic Server environment and the container. The deployer's output is the EJB customized for the target environment and deployed in a specific EJB container. The deployers use the deploy process documented in this guide to deploy the EJBs.

  For more information on the deploy process, see Deploying EJBs to WebLogic Server.

- System Administrators—System Administrators configure and administer the computing and networking infrastructure that includes WebLogic Server and the container. System Administrators use the administration process documented in the Administration Guide and the WebLogic Server online help to manage the deployed applications at runtime.

  For more information on system administrator's tasks, see the Administration Guide.

EJB Enhancements in WebLogic Server 6.1

The following EJB enhancements are new to this release of WebLogic Server.

Changed EJB Deployment Elements

For information about new and changed deployment elements in WebLogic Server 6.1, see Changed EJB Deployment Elements in WebLogic Server 6.1;

Read-Only Multicast Invalidation Support

Non-transactional entity bean caching provides a better way to invalidate or update cached data. You invalidate a read-only entity bean by using an invalidate method on your home interface. For more information on non-transactional entity bean caching, see Read-Only Multicast Invalidation.

Automatic Generated Primary Key Support

The WebLogic Server EJB container can provide automatically generated primary keys. This feature uses the native automatic key generation facilities provided by Oracle or SQLServer databases. If you are not using one of those databases, you can enable key generation through a user-designated key table. For more information on automatically generated primary keys, see Automatic Primary Key Generation for EJB 2.0 CMP.

Automatic Table Creation

You can automatically create tables based on the deployment descriptions in the deployment files and the bean class, if the table does not already exist. This feature is for use during the development phase and does not provide production quality support. However, it is very helpful for testing your designs prior to deployment in a production environment. For more information on automatic table creation, see Automatic Table Creation.

Oracle SELECT HINTS

You can pass your INDEX usage hints to the Oracle Query optimizer in WebLogic QL queries, which provide hints to the Oracle database engine. This feature is most helpful if you know that the database you are searching would benefit from these hints. For more information on Oracle SELECT HINTS, see Using Oracle SELECT HINTS.

EJB Deployment Descriptor Editor

The EJB Deployment Descriptor Editor is a an extension of the WebLogic Server Administration Console that enables you to edit the deployment descriptors for your EJBs in a graphical environment. For more information on this editor, see Specifying and Editing the EJB Deployment Descriptors and the Administration Console online help.

ejb-client.jar Support

Use the ejb-client.jar file to package required classes to compile the client into one JAR file. The ejb-client.jar file contains the EJB interfaces necessary to call an EJB. You specify that the WebLogic EJB compiler (weblogic.ejbc) automatically create the ejb-client.jar file in the bean's deployment descriptor file. For more information on ejb-client .jar files, see Specifying an ejb-client.jar.

BLOB and CLOB Support

Use BLOBs and CLOBs to translate large objects into byte arrays or strings, with Oracle. For more information on BLOBs and CLOBs, see BLOB and CLOB DBMS Column Support for the Oracle DBMS.

Cascade Delete Support

The Cascade Delete feature enables you to remove entity objects. You can specify Cascade Delete for one-to-one and one-to-many relationships; many-to-many relationships are not supported. For more information on Cascade Delete, see Cascade Delete.

Local Interface Support

WebLogic Server's EJB container provides support for local interfaces. The EJB container makes the local home interface accessible to local clients through JNDI. Support for remote interfaces with container-managed persistence (CMP) relationships is still available in this release, but not recommended for new development. For more information on local interface support, see Using the Local Client.

Flushing the CMP Cache Support

You can specify that the container-managed persistence (CMP) cache be flushed before every query so that the changes show up in the results. For more information on this feature, see Flushing the CMP Cache.

Tuned CMP 1.1 Support

This release enables the EJB container to support tuned updates for container-managed persistence (CMP) 1.1 entity beans. The EJB container automatically determines and writes back to the database only those container-managed fields that have been modified in the transaction. If no fields are modified, there is no database update.This feature is enabled by default and can be disabled; however, its use is recommended for performance reasons. For more information on tuned CMP support, see Tuned EJB 1.1 CMP Updates in WebLogic Server.

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 .

EJB Deployment Descriptor Editor

The WebLogic Server Administration Console has an integrated EJB deployment descriptor editor. You must create at least a skeleton of the following deployment descriptor files that you add to the ejb.jar file before using this integrated editor:

- ejb-jar.xml

- weblogic-ejb-jar.xml

- weblogic-cmp-rdbms-jar.xml

For more information, see Web Application Deployment Descriptor Editor Help.

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 BEA dev2dev.

Copyright © 2001 BEA Systems, Inc. All rights reserved. Required browser: Netscape 4.0 or higher, or Microsoft Internet Explorer 4.0 or higher.