Building an application that's easy to extend does
not happen by accident. It takes patience, forethought, and effort.
You've got to design your external interfaces well
so programmers can extend your application. You've
got to consider an effective configuration strategy and a plug-in
model so administrators and users can extend your solution after
deployment. You also have to make a deliberate decision about whether
investing in extension makes sense at all.You saw the basic toolkit for extension, including open standards, a
configuration strategy, and class loading. I suggested three tools
for configuration: Java Preferences, Apache Digester, and Spring.
Each of these tools has strong support for the core features that you
need, and each targets a different market. Preferences is the
simplest configuration API, and is most appropriate on the client.
Digester uses a SAX-based XML engine, and lets you specify patterns
that fire rules. It's simple and you can understand
it quickly. Spring is a framework with a unified configuration
strategy. You need not use all of Spring to take advantage of its
services. These basic tools combine nicely to support an extension
model called the plug-in. You saw that plug-ins can use two different
models: the service locator or dependency injection. I favor
dependency injection, though some experts, including Martin Fowler,
prefer the service locator. Each has strengths and weaknesses.Finally, effective configuration and extension depends on an intimate
knowledge of your customer. Your extension paradigm needs to reflect
your cycle time and the needs of your end customer.You've now seen each of the five principles for
better, faster, lighter Java:Keep it simpleDo one thing, and do it wellStrive for transparencyYou are what you eatAllow for extension
I don't want to leave you hanging: in the next
chapters, you'll see these principles in action.
First, you'll see two of my favorite open source
frameworks, written by third-party developers that I know and trust.
Next, you'll see how to build a sophisticated open
source service, using these principles. Along the way,
we'll examine a fantastic variety of traditional
enterprise web applications, a lightweight container, a persistence
engine, and a web crawler. As you internalize these principles
you'll see that they can be used for many different