Other Enterprise Bean Features

The topics that follow apply to both session and entity beans.

Accessing Environment Entries

Stored in an enterprise bean’s deployment descriptor, an environment entry is a name-value pair that allows you to customize the bean’s business logic without changing its source code. An enterprise bean that calculates discounts, for example, might have an environment entry named Discount Percent. Before deploying the bean’s application, you could run deploytool and assign DiscountPercent avalue of .05 on the Env. Entries tab. (See Figure 4-2.) When you run the application, the enterprise bean fetches the .05 value from its environment.

Figure 4-2. Env. Entries Tab of CheckerBean

In the following code example, the ...

Get J2EE™ Tutorial, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.