9.1 What Are Extension Points?

Think of a framework as a house that comes with part of the structure already complete, but gives you the option to modify certain characteristics, such as the wallpaper and paint colors. If the default characteristics already suit your needs, you don't have to change anything. If you like the paint job, for example, that's one less thing to worry about.

This is similar to how a framework functions, and that's a big advantage when building applications. If functionality that suits the needs of your application is present in the framework, you don't have to worry about that aspect of the application. This, in turn, frees up developers to focus on the core application rather than the infrastructure.

This is not a perfect analogy, but the point is that a good framework should provide much of the infrastructure—the foundation and the plumbing, for example. The most important aspect of a framework, however, is that it should provide extension points throughout.

Framework extension points, also referred to as "hooks," allow you to extend the framework in specific places to adapt it to meet the application's requirements. Where and how a framework provides these hooks is very important. If they're provided incorrectly or in the wrong locations, it becomes very hard for an application to adapt the framework, which makes the framework less useful. The rest of this chapter focuses on where the Struts framework provides these extension points and how you can take advantage of them to build out specialized functionality for your application.