BEA Logo BEA WebLogic Enterprise Release 5.0

  Corporate Info  |  News  |  Solutions  |  Products  |  Partners  |  Services  |  Events  |  Download  |  How To Buy

 

   WLE Doc Home   |   J2EE & Related Topics   |   Previous   |   Next   |   Contents   |   Index

WebLogic EJB Extensions Reference

This topic describes the WebLogic EJB Extensions, which are XML elements used to configure EJBs used in applications that run under WebLogic Enterprise (WLE). This topic includes the following sections:

For more information about deploying EJBs in the WLE environment, see Building and Deploying Enterprise JavaBeans (EJBs).

About the WebLogic EJB Extensions

Sun's Enterprise JavaBeans Specification 1.1 (Public Release 2 dated October 18, 1999) specification defines a standard DTD for describing EJB deployment information. For a list of the standard XML elements, see EJB Deployment Descriptor Reference.

WLE extends the ability to configure EJBs by providing additional, optional XML elements that can be associated with EJBs. The Enterprise JavaBeans Specification 1.1 mandates that these extensions must be specified in a separate file. The WebLogic EJB Extensions reside in a file name weblogic-ejb-extensions.xml , which is included in an ejb-jar file.

The Bean Developer is responsible for creating this file, if needed, and the Application Assembler is responsible for including it in a deployable ejb-jar file. To add this extensions file to an ejb-jar file, an Application Assembler uses the ejbc command line tool, specifying the -x parameter and passing this file name (weblogic-ejb-extensions.xml ). For more information about the ejbc command line tool, see the Command Reference.

Summary of WebLogic EJB Extensions

Table 2-1 WebLogic Enterprise XML Extensions to the EJB Deployment Descriptor  

Element

Description

EJB Role

attribute-map

Specifies an attribute map containing one or more attribute map entries, which define a mapping between an EJB field (a container-managed attribute) and a table column name.

Bean Provider

attribute-map-entry

Specifies the mapping between an EJB field and a table column.

Bean Provider

bean-field-name

Specifies the name of an EJB field in an attribute map entry.

Bean Provider

finder-descriptor

Specifies the finder descriptor for finding one or more EJBs.

Bean Provider

jndi-name

Specifies the name for the EJB home that is registered in the Global WLE JNDI namespace.

Bean Provider

module-initializer-class

Specifies the server implementation class for handling the initialize and release methods.

Bean Provider

module-initializer-class-name

Specifies the name of the server implementation class for handling the initialize and release methods.

Bean Provider

persistence-store-descriptor

Specifies the type of persistence storage (in a flat file or a JDBC-managed database) for container-managed persistence.

Bean Provider

persistence-store-directory-root

If persistent storage is kept in a flat file, specifies the directory root for storing all instances of an EJB. Each ejb-name element is converted to a directory name.

Bean Provider

persistence-store-file

Specifies persistent storage in a flat file.

Bean Provider

persistence-store-jdbc

Specifies persistent storage in a database that is managed by a WLE JDBC connection pool.

Bean Provider

pool-name

Specifies the name of the JDBC connection pool associated with the database used to store EJB state information.

Bean Provider

query-grammar

Specifies the query expression for a finder method.

Bean Provider

table-column-name

Specifies the name of a table column in an attribute map entry.

Bean Provider

table-name

Specifies the name of the table used to store EJB state information.

Bean Provider

trans-timeout-seconds

Specifies the default timeout, in seconds, for container-initiated transactions for this bean. If a transaction duration exceeds this value, the transaction will be rolled back.

Bean Provider

weblogic-deployment-params

Specifies deployment options for the WebLogic Server.

Bean Provider

weblogic-ejb-extensions

Root element of the WLE XML extensions to the deployment descriptor.

Bean Provider

weblogic-enterprise-bean

Specifies deployment information for a bean that is specific to WLE.

Bean Provider

weblogic-version

Specifies the WLE version.

Bean Provider

Description of WebLogic EJB Extension Elements

attribute-map

Synopsis

Specifies an attribute map containing one or more attribute map entries, which define a mapping between an EJB field (a container-managed attribute) and a table column name.

Syntax

<!ELEMENT attribute-map (description?, attribute-map-entry+)>

EJB Role

Bean Provider

Used In

persistence-store-jdbc

attribute-map-entry

Synopsis

Specifies the mapping between an EJB field and a table column.

Syntax

<!ELEMENT attribute-map-entry (bean-field-name, table-column-name)>

Description

No automatic type conversion between types is performed on primary key columns, and therefore the specified mapping must be between equivalent types.

EJB Role

Bean Provider

Used In

attribute-map

bean-field-name

Synopsis

Specifies the name of an EJB field in an attribute map entry.

Syntax

<!ELEMENT bean-field-name (#PCDATA)>

EJB Role

Bean Provider

Used In

attribute-map-entry

finder-descriptor

Synopsis

Specifies the finder descriptor for finding one or more EJBs.

Syntax

<!ELEMENT finder-descriptor (description?, method?, query-grammar?)>

Valid Values

Description

Finder descriptors are WLE's implementation of the EJB find methods. If an EJB uses container-managed JDBC persistence, you can specify finder methods of the form findMethod() to find either an individual or collection of EJBs.

The finder-descriptor elements are pairs of method signatures and expressions. You specify a method signature in the EJBHome interface and specify the method's expression in the deployment descriptor using the query-grammar element. Expressions contain method parameters and EJB attributes. The EJB Container automatically maps the attributes to the appropriate columns in the persistent store.

For complex SQL lookups, such as a dynamically set WHERE clause, you need to use bean-managed persistence and write custom finders.

EJB Role

Bean Provider

Used In

persistence-store-jdbc

Example

The findBigAccounts method has the following interface:

public interface AccountHome extends EJBHome {
// ...
public Enumeration findBigAccounts(double balanceGreaterThan)
throws FinderException, RemoteException;
// ...
}

The following sample expression associated with the findBigAccounts method is defined in the deployment descriptor:

(> balance $balanceGreaterThan)

where balance is an attribute (field) of the EJB and $balanceGreaterThan is the symbol for the method parameter balanceGreaterThan .

A call in the client application, such as myEJBean.findBigAccounts(amount) , will return a list of all EJBs whose balance attribute is greater than the value of amount .

jndi-name

Synopsis

Specifies the name for the EJB home that is registered in the Global WLE JNDI namespace.

Syntax

<!ELEMENT jndi-name (#PCDATA)>

Description

To allow Java clients to perform a lookup on the JNDI name for the EJB home and gain access to the object, the name of the EJB home must be registered in the Global WLE JNDI namespace.

This name can differ from the ejb-name element specified in the standard EJB XML. Whereas the ejb-name element must be unique only among the names of the EJBs in the same ejb-jar file, however, the JNDI name must be unique among all global factory names in a WLE domain, including EJB homes, CORBA factories, and RMI-named objects.

EJB Role

Bean Provider

Used In

weblogic-deployment-params

Example

<weblogic-ejb-extensions>

<weblogic-enterprise-bean>

<ejb-name>Trader</ejb-name>

<weblogic-deployment-params>

<jndi-name>EJB_TraderHome</jndi-name>

</weblogic-deployment-params>

</weblogic-enterprise-bean>

</weblogic-ejb-extensions>

module-initializer-class

Synopsis

Specifies the server implementation class for handling the initialize and release methods.

Syntax

<!ELEMENT module-initializer-class (module-initializer-class-name)>

Description

The syntax for specifying a Server implementation class for handling the initialize and release methods is specified in the EJB XML deployment descriptor extensions. These XML elements are processed by the ejbc command. The WLE EJB framework parses the XML at run time and performs the startup/shutdown processing.

For a complete description of startup and shutdown handling in WLE, see Starting and Shutting Down Applications.

EJB Role

Bean Provider

Used In

weblogic-ejb-extensions

module-initializer-class-name

Synopsis

Specifies the fully qualified name of the server implementation class for handling the initialize and release methods.

Syntax

<!ELEMENT module-initializer-class-name (#PCDATA)>

EJB Role

Bean Provider

Used In

module-initializer-class

Example

<weblogic-ejb-extensions>

...

<module-initializer-class>

<moduleinitializer-class-name>ServerImpl

</moduleinitializer-class-name>

</module-initializer-class>

</weblogic-ejb-extensions>

persistence-store-descriptor

Synopsis

Specifies the type of persistence storage (in a flat file or a JDBC-managed database) for container-managed persistence.

Syntax

<!ELEMENT persistence-store-descriptor (description?, (persistence-store-file | persistence-store-jdbc)?)>

Description

For container-managed persistence, WLE EJB Container supports storing an EJB in either of the following formats:

The standard EJB XML descriptor provides XML elements for specifying which fields in the entity bean are to be persisted (the cmp-field element), and information about the primary key. The WebLogic XML extensions provide additional information for mapping to the persistent store.

The code for implementing the persistence is generated by the EJB compiler, based on the bean's deployment descriptors.

EJB Role

Bean Provider

Used In

weblogic-deployment-params

Example

Using JDBC persistence, the following sample XML code shows how to define the automatic saving of two fields (accountId , balance ) in an entity bean to a database table (ejbAccounts ) using a connection pool (ejbPool ):

<weblogic-ejb-extensions>

<weblogic-enterprise-bean>

<ejb-name>Account</ejb-name>

<weblogic-deployment-params>

<jndi-name>EJB_AccountHome</jndi-name>

<persistence-store-descriptor>

<persistence-store-jdbc>

<pool-name>ejbPool</pool-name>

<table-name>ejbAccounts</table-name>

<attribute-map>

<attribute-map-entry>

<bean-field-name>accountId</bean-field-name>

<table-column-name>id</table-column-name>

</attribute-map-entry>

<attribute-map-entry>

<bean-field-name>balance</bean-field-name>

<table-column-name>bal</table-column-name>

</attribute-map-entry>

</attribute-map>

</persistence-store-jdbc>

</persistence-store-descriptor>

</weblogic-deployment-params>

</weblogic-enterprise-bean>

</weblogic-ejb-extensions>

persistence-store-directory-root

Synopsis

If persistent storage is kept in a flat file, specifies the directory root for storing all instances of an EJB. Each ejb-name element is converted to a directory name.

Syntax

<!ELEMENT persistence-store-directory-root (#PCDATA)>

Description

For EJBs with container-managed persistence, stateful session beans are stored using file persistence when they are passivated. The persistence-store-directory-root element defines the storage location for these instances. By default, the root directory is pstore , which WLE creates in the directory where the JavaServer is run.

The default file name for a passivated instance is the fully qualified name of the bean, with underscores replacing the periods, plus additional information to ensure uniqueness. For example, if persistence-store-directory-root is c:\weblogic\mystore , all instances of the EJB examples.ejb.AccountBean might be stored in:

c:\weblogic\mystore\examples_ejb_AccountBean\SRVGRP_GROUPX_SRVID_Y_Z_examples.ejb.AccountBean_someBigNumber.db

EJB Role

Bean Provider

Used In

persistence-store-file

persistence-store-file

Synopsis

Specifies persistent storage in a flat file.

Syntax

<!ELEMENT persistence-store-file (description?, persistence-store-directory-root)>

Description

File persistence for EJBs is intended primarily for development and prototyping. For an EJB to fully cooperate in a WLE global transaction, use persistence-store-jdbc instead.

EJB Role

Bean Provider

Used In

persistence-store-descriptor

persistence-store-jdbc

Synopsis

Specifies persistent storage in a database that is managed by a WLE JDBC connection pool.

Syntax

<!ELEMENT persistence-store-jdbc (description?, pool-name, table-name, attribute-map, finder-descriptor*)>

Description

EJB instances are stored in a database that has been previously set up with the JDBC connection pool specified in the pool-name element. The table-name and attribute-map elements map the EJB fields to the appropriate table columns in the database.

EJB Role

Bean Provider

Used In

persistence-store-descriptor

pool-name

Synopsis

Specifies the name of the JDBC connection pool associated with the database used to store EJB state information.

Syntax

<!ELEMENT pool-name (#PCDATA)>

EJB Role

Bean Provider

Used In

persistence-store-jdbc

query-grammar

Synopsis

Specifies the query expression for a finder method.

Syntax

<!ELEMENT query-grammar (#PCDATA)>

Description

The query grammar syntax has an expression prefix notation of:

[operator operand1 operand2]

Valid operators include:

Valid operands include:

EJB Role

Bean Provider

Examples

The following examples show sample query expressions in finder methods.

The following expression determines whether balance exceeds amount.

"(> balance $amount)"

The following example shows the use of compound expressions. Note that single quotes are used to denote strings.

"(& (> bal $amount) (! (= accountType 'checking')))"

The following example is a method signature and an expression that is converted to a findBigAccounts method in the generated persistent storage class. The method returns an enumeration of beans of this class that satisfy this expression.

"findBigAccounts(double amount)" "(> balance $amount)"

The following example finds all the EJBs in a table.

"findAll()" "(= 1 1)"

The following example finds all EJBs whose lastName fields starts with M .

"findNamesStartingWithM()" "(like lastName M%)"

The following example finds all EJBs whose firstName field is null .

"findNullFirstNames()" "(isNull firstName)"

The following example finds all EJBs whose firstName field is not null .

"findNullFirstNames()" "(isNotNull firstName)"

The following expression finds all EJBs in which the value of the balance field exceeds balanceGreaterThan and returns the beans ordered by the id database column. Notice that this expression should all contained in a single line and that no column mapping is performed. The database column must be specified directly.

"findOrderedAccounts(double balanceGreaterThan)"
"(orderBy 'id' (> balance $balanceGreaterThan))"

The following expression is identical to the previous one except that it returns the beans in descending order:

"findOrderedAccounts(double balanceGreaterThan)"
"(orderBy 'id desc' (> balance $balanceGreaterThan))"

Used In

finder-descriptor

table-column-name

Synopsis

Specifies the name of a table column in an attribute map entry.

Syntax

<!ELEMENT table-column-name (#PCDATA)>

EJB Role

Bean Provider

Used In

attribute-map-entry

table-name

Synopsis

Specifies the name of the table used to store EJB state information.

Syntax

<!ELEMENT table-name (#PCDATA)>

EJB Role

Bean Provider

Used In

persistence-store-jdbc

trans-timeout-seconds

Synopsis

Sets the default timeout, in seconds, for container-initiated transactions for this bean. If a transaction duration exceeds this value, the transaction will be rolled back.

Syntax

<!ELEMENT trans-timeout-seconds (#PCDATA)>

EJB Role

Bean Provider

Used In

weblogic-deployment-params

weblogic-deployment-params

Synopsis

Specifies deployment options for the WebLogic Server.

Syntax

<!ELEMENT weblogic-deployment-params (trans-timeout-seconds?, jndi-name?, persistence-store-descriptor?)>

EJB Role

Bean Provider

Used In

weblogic-enterprise-bean

weblogic-ejb-extensions

Synopsis

Root element of the WLE XML extensions to the deployment descriptor.

Syntax

<!ELEMENT weblogic-ejb-extensions (description?, weblogic-version?, weblogic-enterprise-bean*, module-initializer-class*)>

EJB Role

Bean Provider

weblogic-enterprise-bean

Synopsis

Specifies deployment information for a bean that is specific to WLE.

Syntax

<!ELEMENT weblogic-enterprise-bean (ejb-name, weblogic-deployment-params?)>

EJB Role

Bean Provider

Used In

weblogic-ejb-extensions

weblogic-version

Synopsis

Specifies the WLE version.

Syntax

<!ELEMENT weblogic-version (#PCDATA)>

EJB Role

Bean Provider

Used In

weblogic-ejb-extensions