Some reader favorites:
EJB fundamentals and session beans
Create a scrollable virtual desktop in Swing
Wizard API updated!
Tim Boudreau has released a new version of the Swing Wizard library (version 0.997) that fixes the WizardException bug reported in JavaWorld's recent Open Source Java Project profile. The article's examples have been reworked to test out the new, improved WizardException. Thanks, Tim, for this helpful fix!
Open Source Java Projects: The Wizard API
The framework concept has been kicking around in software development for a long time in one form or another. In its simplest form, a framework is simply a body of tried and tested code that is reused in multiple software development projects. Smart companies invest formally in frameworks and good developers build up a library of components that they use often. Such actions reduce development time while improving delivered software quality -- which means that developers can spend more time concentrating on the business-specific problem at hand rather than on the plumbing code behind it. A good framework also enhances the maintainability of software through API consistency, comprehensive documentation, and thorough testing.
At one level, the framework showcased in this article does the simple things you need every day: logging, exception handling, JNDI lookup, configuration, and database management. Delving deeper into the design and implementation however, you will see that the framework also provides application server independence, future hooks for adding management services, and a well-defined extension mechanism.
Note: To download the framework's complete source code in zip format, go to the Resources section below.
Before setting out to build the framework, it's worthwhile to set out some basic objectives against which we can measure success:
In order to make our framework easier to maintain, some assumptions are made:
DbConnectionService. Any database that has a JDBC driver will work.
Next, we look at the five core components -- logging, JNDILookup, configuration, database connection management, and exception handling -- that make up the framework. These are the hosted services that can be leveraged by business-specific code, as seen in Figure 1.

Figure 1. The current framework consists of five components.
The logging service serves a core function
in that the other services depend on its existence.
Logging represents the framework's single most important component. Apart from the value it adds to users, it is crucial to debugging the framework itself. Put simply, a system without a logging component and an accompanying set of logging guidelines built into the coding standards will take a long time to develop (and debug) and will be very difficult to maintain.
So what are the requirements for logging?
System.out.println, thus impairing performance. With that in mind, only one import statement and one line should be necessary to use the logging
service, no more.
stdout as well as a file is helpful; in production, this should be turned off to improve performance.
The design and construction of a logging service could take up a complete article in itself. Instead of spending time building one, I have picked one off the shelf that I consider to be best of the breed: log4j (see Resources for more details). Although most vendors (including jBoss and WebLogic) provide a logging service as part of their products, their services aren't used here because they would affect the cross-platform portability of the framework.
In the framework lifecycle, two incarnations of the LogService exist. Initially, the FrameworkManager and the logging service itself use the BootLogger, as neither component can assume that the fully-fledged logging service has been located and bootstrapped. Once the main
logging service has been initialized, the other framework components use it in preference to the BootLogger, which possesses a subset of the main service's functionality.
Next, let's look at the JNDILookup component. JNDI trees serve as the telephone directories of the enterprise Java world.
Looking for that hot new bean in town or the latest connection pool? You will find them in the JNDI environment as named and
configured by the application assembler/deployer. The framework provides a window into this world that hides the vendor- and
location-specific details from developers when they don't need to or want to be aware of them. This service also serves as
an example of how to use the framework's ability to detect the current application server to configure a client service appropriately.
See the JNDIService javadoc for more details on this functionality.
Our third component is the configuration lookup. Although EJBs can use the java:comp/env JNDI context to store information that should live outside the codebase, this is not so easy to do for non-EJB components.
With the ConfigService, all J2EE components can retrieve values from a central file-based repository. Thus, you won't have to hardwire these values
or use J2EE component-specific mechanisms.
We next turn our attention to the framework's fourth component, the database connection manager. Databases are a commodity in the enterprise Java world. Most of the time, developers don't need or want to know where a database is; they simply want a connection to talk to it. As the relational world becomes more in tune with the object world, eventually a service like this will filter completely behind the scenes; knowing that your objects are persisted to a database would be like knowing where a spool file for email lives on a server -- you don't care, you just want to use email. Until that happy day, however, we need a database-connection finder service.
Free Download - 5 Minute Product Review. When slow equals Off: Manage the complexity of Web applications - Symphoniq
![]()
Free Download - 5 Minute Product Review. Realize the benefits of real user monitoring in less than an hour. - Symphoniq