首先说明,这是我在实际使用中的个人感受,并不是从官网的指南中翻译或理解的。
总体感觉就是通过使用beanutils这个工具包,我们可以象访问map一样来访问javabean.
BeanUtils这个类,就是允许我们用类似于访问map的方式来操作实际的业已存在的javabean.
ConvertUtils这个类,感觉象对BeanUtils类的一个支撑,因为毕竟map中的key-value是弱类型的数据,而javabean中的各个成员变量是强类型的数据,所以使用弱类型的访问方式访问强类型数据的过程中势必会有数据类型转换的问题,所以ConvertUtils出现了而且存在了.
DynaBean,继承这一接口的一系列类,允许我们从头开始构造一个特殊的bean:可以定义metadata的类型,通过map方式访问.当然,它更能够被BeanUtils操作.
知道写本文的时候,我的个人感觉就是这个包就是为了struts应用的实现而生成的.beanutils这个包的应用范围:面对多样化的需求,我们要构造一种数据结构(数据封装体)及针对这种结构的一系列操作方法,它对于输入并不关心,数量、类型、组合形式可以任意变化,同样还向使用此结构的用户提供统一的操作方法。针对真真正正的javabean的操作的部分,应该是这个工具包为了兼容已有的应用而出现的;如果以前没有javabean出现的话,相信beanutils会推荐大家使用map作为数据传输对象。
将javabean转换为map,我个人总感觉这不是OO的思想,但是如果正如我前面所说--这个工具包就是为了struts而生而存在的话,那就可以完全理解了,所以,beanutils工具包是javabean与map之间的一座桥。
另外,当大家使用这个工具包的时候,要明确考虑下应用的环境是否真的需要beanutils工具包,因为这个beanutils子项目好象现在不再维护了。
下面是apache mail-list 中关于维护的一部分:
On Tue, 2005-07-19 at 19:48 +0200, Dewitte Rémi wrote:
> I wrote this method, can i have your comments for improvements ?
Hi Remi,
Unfortunately, BeanUtils is basically unmaintained. You are unlikely to
get any feedback on suggestions or patches for BeanUtils.
I suggest that you create a bugzilla entry and attach your proposed code
in case beanutils maintenance restarts in the future - but don't depend
on it.
Regards,
Simon
--------------------------------------------------------------------------------------------------------------------------------------
On Wed, 2005-07-20 at 09:45 -0400, Bernard, Shawn wrote:
> Is there any reason why BeanUtils is unmaintained? Is it just waiting for a maintainer?
> Or is it being left to stagnate for a reason (i.e. Java 5).
There just doesn't appear to be any existing jakarta committers
interested in working on it.
I did try to restart interest in it, at least to deal with the large
number of bugzilla entries filed against beanutils but couldn't find
anyone willing to commit a few hours a week to work with me. As it's
pretty dangerous to work alone on this kind of library used by quite a
few other projects (as well as being pretty unrewarding) I've stopped -
and there isn't anyone else.