Commons BeanUtils2Most Java developers are used to creating Java classes that conform to the JavaBeans naming patterns for property getters and setters. It is natural to then access these methods directly, using calls to the corresponding getXxx and setXxx methods. However, there are some occasions where dynamic access to Java object properties (without compiled-in knowledge of the property getter and setter methods to be called) is needed. Example use cases include:
The Java language provides Reflection and Introspection APIs (see the java.lang.reflect and java.beans packages in the JDK Javadocs). However, these APIs can be quite complex to understand and utilize. The BeanUtils2 component provides easy-to-use wrappers around these capabilities. BeanUtils And BeanUtils2BeanUtils2 is a complete rewrite of the Commons BeanUtils library. It is designed as a fluent API, allowing users to chain method calls one after another: import static org.apache.commons.beanutils2.BeanUtils.on; ... on( myBean ).set( "stringProperty" ).with( "Hello from BeanUtils2!" ); In addition to that, BeanUtils2 provides unchecked exception wrappers for the checked exceptions that are used by the Java Reflection and Introspection APIs. This releases users from the burden to catch those exceptions, that in most cases result from programmatic errors rather than runtime failures that could be reasonable handled and recovered from. To allow backwards compatibility, BeanUtils2 lives in its own package so that it can be used side by side with BeanUtils. DocumentationThe User Guide is part of the package JavaDocs. The Release Notes document the new features and bug fixes that have been included in this release. The JavaDoc API documents are available online. In particular, you should note the property reference syntax options described in the PropertyUtils class description. Status
SupportThe commons mailing lists act as the main support forum. The user list is suitable for most library usage queries. The dev list is intended for the development discussion. Please remember that the lists are shared between all commons components, so prefix your email by [beanutils2]. Issues may be reported via ASF JIRA. |