|
|
||||||||||||||||||||||||||||||||||||||||||||||||
There has been some
discussion
recently that has touched on the idea of immutable beans. In a lot of
frameworks beans are used for configuration (for example
the Spring framework), but
often you want to "lock down" the beans after they have been
initialized. I've added a new ImmutableBean class
to CGLIB CVS that generates a new
version of the bean where any call to a setter will throw an
exception:
MyBean readWrite = new MyBean(); readWrite.setFoo(42); MyBean readOnly = (MyBean)ImmutableBean.create(readWrite); readOnly.setFoo(42); // this will throw an exception
I also added a BeanCopier class, see
my message
to the Jakarta commons-devel mailing list for details. In summary it is
800 times faster than the BeanUtils version ![]()