| CONTENTS | PREV | NEXT | INDEX | Designing Enterprise Applications with the J2EETM Platform, Second Edition |
The J2EE platform is a layered set of system services that are consistently available to J2EE applications across implementations. It is the top layer of a "stack" of services that support an application, shown in Figure 4.1. The J2EE platform runs on top of the J2SE platform, which itself runs on top of the host operating system. In the Web tier, a J2EE Web container provides services related to serving Web requests.
Just as the J2EE platform has layers, J2EE applications can benefit from architectural layering. The highest-level division between layers in an application's Web tier is between functions that are specific to a particular application and those that occur in all Web applications.
All Web-tier applications share a common set of basic requirements that are not provided by the J2EE platform itself. A software layer called an application framework can meet these requirements and can be shared between applications. As shown in Figure 4.1, application-specific code is written in terms of the application framework layer.
A Web-tier application framework sits on top of the J2EE platform, providing common application functionality such as dispatching requests, invoking model methods, and selecting and assembling views. Framework classes and interfaces are structural; they are like the load-bearing elements of a building, forming the application's underpinnings. Application developers extend, use, or implement framework classes and interfaces to perform application-specific functions. For example, a framework may offer an abstract class that a developer may extend to execute business logic in response to application events. A Web-tier application framework makes Web-tier technologies easier to use, helping application developers to concentrate on business logic.
The BluePrints recommended best practice is to choose an existing, proven Web-tier application framework for a J2EE application rather than designing and building a custom framework layer. A Web-tier application framework can provide the following benefits to your application:
- Decouples presentation and logic into separate components--Frameworks encourage separating presentation and logic because the separation is designed into the extension interfaces.
- Separates developer roles--Application frameworks generally provide different interfaces for different developers. Presentation component developers tend to focus on creating JSP pages using custom tags, while logic developers tend to write action classes, tag handlers, and model code. This separation allows both types of developers to work more independently.
- Provides a central point of control--Most frameworks provide a rich, customizable set of application-wide features, such as templating, localization, access control, and logging.
- Facilitates unit testing and maintenance--Because framework interfaces are consistent, automated testing harnesses are easy to build and execute.
- Can be purchased instead of built--Time not spent developing structural code is available for developing business logic.
- Provides a rich set of features--Adopting a framework can leverage the expertise of a group of Web-tier MVC design experts. The framework may include useful features that you do not have the experience to formulate or the time to develop.
- Encourages the development and use of standardized components--Over time, developers and organizations can accumulate and share a toolbox of preferred components. Most frameworks incorporate a set of custom tags for view construction.
- Provides stability--Frameworks are usually created and actively maintained by large organizations or groups, and are used and tested in a large installed base. Accordingly, framework code tends to be more stable than custom code.
- Has community support--Popular frameworks attract communities of enthusiastic users who report bugs, provide consulting and training services, publish tutorials, and produce useful add-ons. Open frameworks are particularly strong in this regard.
- May reduce training costs and time--Developers already trained and experienced in using a framework get up to speed more quickly and are more productive.
- May simplify internationalization--Most frameworks support a flexible internationalization strategy.
- May support input validation--Many frameworks have consistent ways to specify input validation. Validation is commonly available on the client side, on the server side, or both.
- May be compatible with tools--Good tools can improve productivity and reliability. Some frameworks are integrated with rapid application development tool sets.
All of these benefits come at a cost, of course. You always have less control over a design you have acquired rather than created yourself. Some frameworks must be purchased, although these are usually bundled with a tool set. Other people's code in your application means other people's bugs in your application. Still, most development projects find that a Web-tier framework improves design and implementation quality.