Chris Nokleberg's Fizzy Weblog
"A DynaBean is a Java object that supports properties whose names and data types, as well as values, may be dynamically modified. To the maximum degree feasible, other components of the BeanUtils package will recognize such beans and treat them as standard JavaBeans for the purpose of retrieving and setting property values."
The impedance mismatch with JSTL due to not implementing Map is bad enough, but to me the worst thing is that you lock yourself into using BeanUtils and its ilk until the end of time. If you have a JavaBean-oriented library that does not use BeanUtils...tough luck!
BeanGenerator bg = new BeanGenerator(); bg.addProperty("foo", Double.TYPE); bg.addProperty("bar", String.class); Object bean = bg.create();
The generated class is an real JavaBean, which means you can use
standard bean utilities. This includes all of the classes in the
net.sf.cglib.beans package (
BulkBean). Do your part to end the tyranny of
Update: In the comments I was reminded of http://dynclass.sf.net,
which is a standalone library that serves the same purpose. I wonder why it isn't more widely used?
Also, thanks to Juozas Baliuka, the original author of
BeanGenerator and founder of CGLIB!