天天看點

初識 Apache Commons jar 包

長篇預警 ,要有耐心才能看下去

1.1. 開篇

      在Java的世界,有很多(成千上萬)開源的架構,有成功的,也有不那麼成功的,有聲名顯赫的,也有默默無聞的。在我看來,成功而默默無聞的那些架構值得我們格外的尊敬和關注,Jakarta Commons就是這樣的一個架構。如果你至少參與了一個中型規模的Java項目,那麼我想有超過一大半的機會你都接觸和使用到了Jakarta Commons,不管你自己有沒有察覺。就我所知,除了Apache Jakarta其他許多開源架構之外,不少所謂的商業架構其實内部有些子產品是借用Commons的,甚至有一些完全就是對Commons的類進行了簡單的封裝。如果真的沒有接觸過也不要緊,當你看到它時,你自然會被它的簡單而強大所吸引。

      要提高Java程式設計水準,一條可以走的路就是學習優秀的開源架構。這又要分兩個層面:應用層面和源碼層面。

          從應用來說,開源的架構大都可以給你帶來生産力和/或代碼品質的大幅提升;

          從源碼來說,Java開源架構,尤其是那些大型的優秀的架構,其源碼對廣大Java愛好者來說都是一筆巨大的财富,你可以從中學到許多課本上學不到的東西:編碼習慣、代碼組織、注釋、文檔、如何用Java解決實際問題、特定問題的算法,等等。而這些對于我們的作為軟體開發者的實際工作而言,相當有意義。

      熟悉Jakarta Commons的朋友可能會覺得現在是不是有點過時,因為有很多功能在J2SE 5.0中已經包含了。其實這個問題看你怎麼去看,一方面,J2SE 5.0畢竟是剛出現不久的Java版本,實際應用中,很多時候我們需要把代碼相容等級維持在1.3或者1.4,是以很多5.0的功能我們暫時還不能放開手腳去使用;另一方面,鑒于Jakarta在一定程度上反映了一線Java開發人員的實際需求,而目前5.0已經采納了其中許多特性,我們當然也有理由相信未來的Java版本還會繼續參照Jakarta Commons的内容。有這麼一套開發源碼、免費使用、商業友好的優秀API作為Java自帶API的補充,何樂而不為呢?

我打算在近期陸續做一些Jakarta Commons的學習筆記放上來,供大家參考。

有關Jakarta的最新動态和詳細資訊,可以參考:https://commons.apache.org/

1.2.簡介

Apache Commons是一個非常有用的工具包,解決各種實際的通用問題

現在最新的jar 包是 

Welcome to Apache Commons

    Apache Commons is an Apache project focused on all aspects of reusable Java components.

     Apache Commons是一個Apache項目,專注于可重用Java元件的所有方面。

The Apache Commons project is composed of three parts:  Apache Commons項目由三部分組成:

  • The Commons Proper - A repository of reusable Java components.  可重用Java元件的存儲庫。
  • The Commons Sandbox - A workspace for Java component development.    用于Java元件開發的工作區。 
  • The Commons Dormant - A repository of components that are currently inactive.    目前停止開發的元件庫。

    You may also read our charter, which spells out the goals of the project in greater detail.

    您還可以閱讀我們的章程,其中詳細說明了項目的目标。

      The Apache Commons source code repositories are writable for all ASF committers. While Apache Commons is a Commit-Then-Review community, we would consider it polite and helpful for contributors to announce their intentions and plans on the dev mailing list before committing code. All contributors should read our contributing guidelines. We accept patches as SVN diff files uploaded to the Apache bugtracker or as pull request via our github mirrors.

      所有ASF送出者都可以編寫Apache Commons源代碼存儲庫。雖然Apache Commons是一個送出後檢查的社群,但是我們認為,在送出代碼之前,貢獻者應該在dev郵件清單上宣布他們的意圖和計劃,這是禮貌的,也是有幫助的。所有貢獻者都應該閱讀我們的貢獻指南。我們接受更新檔作為SVN diff檔案上傳到Apache bugtracker或通過我們的github鏡像拉請求。

Apache Commons Proper   

      Commons Proper is dedicated to one principal goal: creating and maintaining reusable Java components. The Commons Proper is a place for collaboration and sharing, where developers from throughout the Apache community can work together on projects to be shared by the Apache projects and Apache users.

      Commons Proper緻力于一個主要目标:建立和維護可重用的Java元件。Commons Proper是一個協作和共享的場所,整個Apache社群的開發人員可以共同協作Apache項目和Apache使用者共享的項目。

      Commons developers will make an effort to ensure that their components have minimal dependencies on other libraries, so that these components can be deployed easily. In addition, Commons components will keep their interfaces as stable as possible, so that Apache users (including other Apache projects) can implement these components without having to worry about changes in the future.

      Commons開發人員将努力確定他們的元件對其他庫具有最小的依賴性,以便可以輕松地部署這些元件。此外,Commons元件将使其接口盡可能保持穩定,以便Apache使用者(包括其他Apache項目)可以實作這些元件,而無需擔心将來的更改。

      This article gives an overview of (some of) the components which can be found here.

      該文章 給出了(一些),它可以在這裡找到的元件的概述。

      We welcome participation from all that are interested, at all skill levels. Coding, documentation and testing are all critical parts of the software development process. If you are interested in participating in any of these aspects, please join us!

      我們歡迎所有感興趣的,不同技術水準的人參加。編碼、文檔和測試都是軟體開發過程的關鍵部分。如果你有興趣參與其中任何一個方面,請加入我們!

Components Description Latest Version Released
BCEL

Byte Code Engineering Library - analyze, create, and manipulate Java class files

位元組代碼工程庫 - 分析,建立和操作Java類檔案

6.2 2017-11-08
BeanUtils

Easy-to-use wrappers around the Java reflection and introspection APIs.

Commons-BeanUtils 提供對 Java 反射和自省API的包裝

1.9.3 2016-09-26
BSF

Bean Scripting Framework - interface to scripting languages, including JSR-223

Bean Scripting Framework - 腳本語言的接口,包括JSR-223

3.1 2010-06-24
Chain

Chain of Responsibility pattern implemention.

Chain 提供實作組織複雜的處理流程的“責任鍊模式”.    

1.2 2008-06-02
CLI

Command Line arguments parser.

CLI 提供針對指令行參數,選項,選項組,強制選項等的簡單API.

1.4 2017-03-09
Codec

General encoding/decoding algorithms (for example phonetic, base64, URL).

Codec 包含一些通用的編碼解碼算法。包括一些語音編碼器, Hex, Base64, 以及URL encoder.  

1.11 2017-10-20
Collections

Extends or augments the Java Collections Framework.

Commons-Collections 提供一個類包來擴充和增加标準的 Java Collection架構

4.1 2015-11-27
Compress

Defines an API for working with tar, zip and bzip2 files.

定義用于處理tar,zip和bzip2檔案的API。

1.17 2018-06-03
Configuration

Reading of configuration/preferences files in various formats.

Commons-Configuration 工具對各種各式的配置和參考檔案提供讀取幫助.

2.2 2017-10-12
Crypto

A cryptographic library optimized with AES-NI wrapping Openssl or JCE algorithm implementations.

使用AES-NI優化的加密庫包裝Openssl或JCE算法實作。

1.0.0 2016-07-22
CSV

Component for reading and writing comma separated value files.

用于讀寫逗号分隔值檔案的元件。

1.5 2017-09-03
Daemon

Alternative invocation mechanism for unix-daemon-like java code.

一種 unix-daemon-like java 代碼的替代機制 

1.0.15 2013-04-03
DBCP

Database connection pooling services.

Commons-DBCP 提供資料庫連接配接池服務

2.3.0 2018-05-12
DbUtils

JDBC helper library.

DbUtils 是一個 JDBC helper 類庫,完成資料庫任務的簡單的資源清除代碼.

1.7 2017-07-20
Digester

XML-to-Java-object mapping utility.

Commons-Digester 是一個 XML-Java對象的映射工具,用于解析 XML配置檔案.

3.2 2011-12-13
Email

Library for sending e-mail from Java.

用于從Java發送電子郵件的庫。

1.5 2017-08-01
Exec

API for dealing with external process execution and environment management in Java.

用于在Java中處理外部流程執行和環境管理的API。

1.3 2014-11-06
FileUpload

File upload capability for your servlets and web applications.

FileUpload 使得在你可以在應用和Servlet中容易的加入強大和高性能的檔案上傳能力

1.3.3 2017-06-13
Functor

A functor is a function that can be manipulated as an object, or an object representing a single, generic function.

仿函數是可以作為對象操作的函數,或者是表示單個通用函數的對象。

1.0 2011-??-??
Geometry

Space and coordinates.

空間和坐标。

1.0 2018-??-??
Imaging (previously called Sanselan)

A pure-Java image library.

純Java圖像庫。

0.97-incubator 2009-02-20
IO

Collection of I/O utilities.

IO 是一個 I/O 工具集

2.6 2017-10-15
JCI

Java Compiler Interface

Java編譯器接口

1.1 2013-10-14
JCS

Java Caching System

Java緩存系統

2.2 2017-08-02
Jelly

XML based scripting and processing engine.

Jelly是一個基于 XML 的腳本和處理引擎。 Jelly 借鑒了 JSP 定名額簽,Velocity, Cocoon和Xdoclet中的腳本引擎的許多優點。

Jelly 可以用在指令行, Ant 或者 Servlet之中。

1.0.1 2017-09-27
Jexl

Expression language which extends the Expression Language of the JSTL.

Jexl是一個表達式語言,通過借鑒來自于Velocity的經驗擴充了JSTL定義的表達式語言。.

3.1 2017-04-14
JXPath

Utilities for manipulating Java Beans using the XPath syntax.

Commons-JXPath 提供了使用Xpath文法操縱符合Java類命名規範的 JavaBeans的工具。

也支援 maps, DOM 和其他對象模型。.

1.3 2008-08-14
Lang

Provides extra functionality for classes in java.lang.

Commons-Lang 提供了許多許多通用的工具類集,提供了一些java.lang中類的擴充功能

3.6 2017-06-08
Logging

Wrapper around a variety of logging API implementations.

Commons-Logging 是一個各種 logging API實作的包裹類.

1.2 2014-07-11
Math

Lightweight, self-contained mathematics and statistics components.

Math 是一個輕量的,自包含的數學和統計元件,解決了許多非常通用但沒有及時出現在Java标準語言中的實踐問題.

3.5 2015-04-17
Net

Collection of network utilities and protocol implementations.

Net 是一個網絡工具集,基于 NetComponents 代碼,包括 FTP 用戶端等等。

3.6 2017-02-15
Numbers

Number types (complex, quaternion, fraction) and utilities (arrays, combinatorics).

數字類型(複數,四元數,分數)和實用程式(數組,組合數學)。

1.0 2017-??-??
OGNL

An Object-Graph Navigation Language

對象圖導航語言

4.0 2013-??-??
Pool

Generic object pooling component.

Commons-Pool 提供了通用對象池接口,一個用于建立子產品化對象池的工具包,以及通常的對象池實作.

2.5.0 2017-12-19
Proxy

Library for creating dynamic proxies.

用于建立動态代理的庫。

1.0 2008-02-28
RDF

Common implementation of RDF 1.1 that could be implemented by systems on the JVM.

可以由JVM上的系統實作的RDF 1.1的通用實作。

0.3.0-incubating 2016-11-15
RNG

Implementations of random numbers generators.

随機數發生器的實作

1.0 2016-12-13
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.

旨在建立和維護Java SCXML引擎的State Chart XML規範的實作。

它能夠執行使用SCXML文檔定義的狀态機,并抽象出環境接口。

0.9 2008-12-01
Statistics

Statistics.

統計。

0.1 ????-??-??
Text

Apache Commons Text is a library focused on algorithms working on strings.

Apache Commons Text是一個專注于處理字元串的算法的庫。

1.3 2018-03-21
Validator

Framework to define validators and validation rules in an xml file.

The commons-validator提供了一個簡單的,可擴充的架構來在一個XML檔案中定義校驗器 (校驗方法)和校驗規則。支援校驗規則的和錯誤消息的國際化。

1.6 2017-02-21
VFS

Virtual File System component for treating files, FTP, SMB, ZIP and such like as a single logical file system.

虛拟檔案系統元件,用于将檔案,FTP,SMB,ZIP等處理為單個邏輯檔案系統。

2.2 2017-10-06
Weaver

Provides an easy way to enhance (weave) compiled bytecode.

提供一種增強(編織)編譯位元組碼的簡便方法。

1.3 2016-10-18

The Commons Sandbox

      The Commons project also contains a workspace that is open to all Apache committers. It's a place to try out new ideas and prepare for inclusion into the Commons portion of the project or into another Apache project. Users are free to experiment with the components developed in the sandbox, but sandbox components will not necessarily be maintained, particularly in their current state.

      Commons項目還包含一個對所有Apache送出者開放的工作空間。這是一個嘗試新想法并準備包含在項目的Commons部分或另一個Apache項目的地方。使用者可以自由地嘗試沙箱中開發的元件,但不一定要維護沙箱元件,特别是在目前狀态下。

有關Sandbox元件,請參見此處。

See here for Sandbox components.

The Commons Dormant

      These are Commons components that have been deemed inactive since they have seen little recent development activity. If you wish to use any of these components, you must build them yourselves. It is best to assume that these components will not be released in the near future.

      這些Commons元件被認為是非活動的,因為他們最近幾乎沒有看到開發活動。如果您想使用這些元件中的任何一個,您必須自己建構它們。最好假設這些元件不會在不久的将來釋出。

請參閱此處了解休眠元件。

See here for Dormant components.

Where do I get releases?

The individual components have independent releases. Some releases for some components may be available only through the mirroring system. Some releases for some components (typically the older ones) are not available through the mirroring system.

      各個元件都有獨立的版本。某些元件的某些版本隻能通過鏡像系統使用。某些元件(通常是較舊的元件)的某些版本無法通過鏡像系統獲得。

      有關特定下載下傳内容,請參閱上面列出的各個網站,或使用“ 版本” 菜單選項。

See the individual websites listed above for the specific downloads, or use the Releases menu option.

How do I contribute, give feedback, fix bugs and so on?

我如何貢獻,提供回報,修複錯誤等等?

      The Commons project really needs and appreciates any contributions, including documentation help, source code and feedback.

      Commons項目确實需要并贊賞任何貢獻,包括文檔幫助,源代碼和回報。

  • Discussion occurs on the Commons mailing list.      讨論發生在 Commons郵件清單中。
  • We have an IRC channel on freenode - join #apache-commons.          我們在freenode上有一個IRC頻道 - 加入#apache-commons。
  • Access to the SVN commons/proper repository is available both online and with a svn client.        可以線上和使用 svn用戶端 通路SVN 公共/适當的存儲庫 。
  • Access to the SVN commons/sandbox repository is available both online and with a svn client.      
  • Access to the SVN commons/dormant repository is available both online and with a svn client.

Related Components @Apache   

 相關元件@Apache

      The Commons HttpClient project used to be a part of Commons, but is now part of Apache HttpComponents - see Jakarta Commons HttpClient

      Commons HttpClient項目曾經是Commons的一部分,但現在是Apache HttpComponents的一部分 - 請參閱 Jakarta Commons HttpClient

      最後:Jakarta Commons這個類庫中非常重要的三個子項目:Commons Lang、Commons BeanUtils和Commons Collections,這些工具包在無數開源或商業架構中都可以找到,可以說應用範圍非常廣。

      當然,Jakarta Commons提供的API遠不止我們提到的這些,除了上述三個核心項目之外,還有讀取和映射XML文檔的Digester/Betwixt、處理指令行參數的CLI、提供常用編碼算法的Codec、用于讀取多種格式的配置檔案的Configuration、發送電子郵件的Email、上傳檔案的FileUpload、模拟HTTP用戶端的HttpClient、處理日志的Logging等等等等,實在是相當的豐富。

參考: http://www.cnblogs.com/jimcsharp/p/8872144.html  

            https://commons.apache.org/