要提高Java编程水平,一条可以走的路就是学习优秀的开源框架。这又要分两个层面:应用层面和源码层面。从应用来说,开源的框架大都可以给你带来生产力和/或代码质量的大幅提升;从源码来说,Java开源框架,尤其是那些大型的优秀的框架,其源码对广大Java爱好者来说都是一笔巨大的财富,你可以从中学到许多课本上学不到的东西:编码习惯、代码组织、注释、文档、如何用Java解决实际问题、特定问题的算法,等等。而这些对于我们的作为软件开发者的实际工作而言,相当有意义。(此处内容系转载)
今天介绍一个非常实用的开源类库:Apache Commons,具体的类会在接下来继续学习。先大致了解一下都有哪些。
Apache Commons是Apache软件基金会的项目,曾隶属于Jakarta项目。Commons的目的是提供可重用的、开源的Java代码。Commons由三部分组成:Proper(是一些已发布的项目)、Sandbox(是一些正在开发的项目)和Dormant(是一些刚启动或者已经停止维护的项目)。?
Commons Proper
Commons Proper的目的是建立和维护可重用的Java组件库。Commons Proper是一个协作与共享的地方,Commons的开发者努力确保其组件对其他的软件库的依赖最少,以便可以轻松地部署这些组件。此外,Commons组件会尽可能的保持其接口的稳定,因而Apache用户以及其他Apache项目可以实现这些组件,而无需担心未来接口的变化。 Commons Proper上有四十多个项目,主要可以分为五大类:
组件类别 | 示例 |
---|---|
包 | Codec和Modeler |
杂项 | CLI、Discovery、Lang和Collections |
实用程序 | BeanUtils、Configuration、Logging、DBCP、Pool和Validator |
Web相关 | FileUpload和Net |
XML相关 | Betwixt、Digester、Jelly和JXPath |
其中一些组件及其介绍如下:
Components | Description | Latest Version | Released |
---|---|---|---|
BCEL | Byte Code Engineering Library - analyze, create, and manipulate Java class files | 5.2 | 2007-06-14 |
BeanUtils | Easy-to-use wrappers around the Java reflection and introspection APIs. | 1.9.2 | 2014-05-29 |
BSF | Bean Scripting Framework - interface to scripting languages, including JSR-223 | 3.1 | 2010-24-06 |
Chain | Chain of Responsibility pattern implemention. | 1.2 | 2008-06-02 |
CLI | Command Line arguments parser. | 1.2 | 2009-03-19 |
Codec | General encoding/decoding algorithms (for example phonetic, base64, URL). | 1.10 | 2014-11-09 |
Collections | Extends or augments the Java Collections Framework. | 4.0 | 2013-11-24 |
Compress | Defines an API for working with tar, zip and bzip2 files. | 1.9 | 2014-10-09 |
Configuration | Reading of configuration/preferences files in various formats. | 2.0-alpha2 | 2014-12-20 |
CSV | Component for reading and writing comma separated value files. | 1.1 | 2014-11-27 |
Daemon | Alternative invocation mechanism for unix-daemon-like java code. | 1.0.15 | 2013-03-04 |
DBCP | Database connection pooling services. | 2.0.1 | 2014-05-24 |
DbUtils | JDBC helper library. | 1.6 | 2014-07-20 |
Digester | XML-to-Java-object mapping utility. | 3.2 | 2011-12-13 |
Discovery | Tools for locating resources by mapping service/reference names to resource names. | 0.5 | 2011-04-28 |
EL | Interpreter for the Expression Language defined by the JSP 2.0 specification. | 1.0 | 2003-06-18 |
Library for sending e-mail from Java. | 1.3.3 | 2014-07-11 | |
Exec | API for dealing with external process execution and environment management in Java. | 1.3 | 2014-11-06 |
FileUpload | File upload capability for your servlets and web applications. | 1.3.1 | 2014-02-07 |
Functor | A functor is a function that can be manipulated as an object, or an object representing a single, generic function. | N/A | N/A |
Imaging (previously called Sanselan) | A pure-Java image library. | N/A | N/A |
IO | Collection of I/O utilities. | 2.4 | 2012-06-12 |
JCI | Java Compiler Interface | 1.1 | 2013-10-14 |
JCS | Java Caching System | 1.3 | 2007-06-05 |
Jelly | XML based scripting and processing engine. | 1.0 | 2005-06-16 |
Jexl | Expression language which extends the Expression Language of the JSTL. | 2.1.1 | 2011-12-24 |
JXPath | Utilities for manipulating Java Beans using the XPath syntax. | 1.3 | 2008-08-14 |
Lang | Provides extra functionality for classes in java.lang. | 3.4 | 2015-04-06 |
Launcher | Cross platform Java application launcher. | 1.1 | 2004-08-22 |
Logging | Wrapper around a variety of logging API implementations. | 1.2 | 2014-07-11 |
Math | Lightweight, self-contained mathematics and statistics components. | 3.4 | 2014-12-26 |
Modeler | Mechanisms to create Model MBeans compatible with JMX specification. | 2.0.1 | 2007-06-25 |
Net | Collection of network utilities and protocol implementations. | 3.3 | 2013-06-12 |
OGNL | An Object-Graph Navigation Language | N/A | N/A |
Pool | Generic object pooling component. | 2.3 | 2014-12-30 |
Primitives | Smaller, faster and easier to work with types supporting Java primitive types. | 1.0 | 2003-11-05 |
Proxy | Library for creating dynamic proxies. | 1.0 | 2008-02-28 |
SCXML | An implementation of the State Chart XML specification aimed at creating and maintaining a Java SCXML engine.It is capable of executing a state machine defined using a SCXML document, and abstracts out the environment interfaces. | 0.9 | 2008-12-01 |
Validator | Framework to define validators and validation rules in an xml file. | 1.4.1 | 2014-01-13 |
VFS | Virtual File System component for treating files, FTP, SMB, ZIP and such like as a single logical file system. | 2.0 | 2011-08-24 |
Weaver | Provides an easy way to enhance (weave) compiled bytecode. | 1.1 | 2014-09-30 |
Commons Sandbox
Commons Sandbox是Java组件开发的工作区,在Sandbox中Commons的贡献者协作和检验那些被未列入Commons Proper的项目。Sandbox项目在Commons成员的支持下晋升为Commons Proper项目;大量的开发者协作强化Sandbox项目,直到它们符合推广的标准。
Commons Dormant
Commons Dormant是一个当前处于非活动状态的组件库。用户也可以使用这些组件,但必须自己进行组件的构建。一般而言,这些组件不会在近期发布。