In this book, you'll find information about a set of libraries developed within the Apache Commons (also referred to as "Commons"). Commons is a set of small, popular components which forms a Top-level Project at the Apache Software Foundation. Ranging from the elementary to the complex, many would consider some of these libraries indispensable to any Java project. These components are so widespread, they may already be on your classpath. If you develop an application using Wicket, Maven, Struts, Tomcat, Spring, Hibernate, or any other popular Java library, you likely have Commons Lang and Commons BeanUtils in your classpath. If you just installed Red Hat Enterprise Linux with the default configuration, you've got Commons libraries somewhere in /usr . While Apache Commons may be everywhere, many are still unaware of the capabilities these components provide. This book is an attempt to provide some documentation for these popular components.
This book focuses on tactical implementation details, answering such questions as: How do we parse XML? How do we serialize beans? Is there an easier way to work with Collections? How do we work with HTTP and keep track of cookies? In enterprise software development, the tactical is often sacrificed for the strategic. Consider a complex enterprise-scale system with a solid, well-conceived architecture. The strategic (or high-level) design appears reasonable from 40,000 feet, but as soon as you drill into the details, you notice that every component contains pages upon pages of unmaintainable and unnecessary code because the developers were not aware of some valuable time-saver like BeanUtils, Collections, or the Digester. Or, worse, the developer may have spent a week reimplementing most of the capabilities of Commons BeanUtils even though BeanUtils was already in the classpath. While a familiarity with Apache Commons may not directly affect the architecture of your application, knowing what Apache Commons can do often helps to inform decisions made at the class level.
This open book is licensed under a Creative Commons License (CC BY-NC-ND). You can download The Common Java Cookbook ebook for free in PDF format (3.0 MB).