The Business Layer

Next in the design process is the task of creating a business layer. This portion of the application is wedged between presentation (what the user sees) and data (what the application depends on). The business layer, then, does just what it implies: it performs business (logic). Data on its own is rarely relevant, and often makes no sense without some context applied to it. In the same fashion, the presentation layer must have something to present (no rocket science here!). In this business layer, then, data is manipulated, transformed, and converted into content suitable for presentation.

The core of this layer is the code that actually executes business logic. This code maps to a company’s business processes; in the best case, a single module of code represents a single business process. These modules can then be called to obtain a client’s outstanding balance, for example. This figure is rarely stored in the database, but instead is calculated from the client’s purchases subtracted from his or her assets. This allows the raw data to be masked from the presentation layer of an application; instead of asking for data and performing calculations, the application needs to request only the business process that results in a client’s account balance, and format the result.

Business Logic

With entity beans in place for handling data access to most of our application, it makes sense to continue to leverage EJB for the business logic in our application. In this case, ...

Get Building Java Enterprise Applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.