Most 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
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
packages in the JDK Javadocs). However, these APIs can be quite complex to
understand and utilize. The proposed BeanUtils component provides
easy-to-use wrappers around these capabilities.
This proposal is to create a package of Java utility methods for accessing and modifying the properties of arbitrary JavaBeans. No dependencies outside of the JDK are required, so the use of this package is very lightweight.
getCustomer().getAddress(2).getStreet()(access to indexed properties also works if the underlying property is an array rather than providing indexed getter and setter methods).
BeanUtils relies only on standard JDK 1.2 (or later) APIs for production deployment. It utilizes the JUnit unit testing framework for developing and executing unit tests, but this is of interest only to developers of the component. BeanUtils will also be a dependency for several future proposed components for the Jakarta Commons subproject.
No external configuration files are utilized.
The three original Java classes (
PropertyUtils) are an integral
part of the Struts Framework.
However, they have very few dependencies on other aspects of Struts, and
those dependencies have been removed in the proposed code base.
Once accepted and released as a Jakarta Commons component, Struts will
be modified to use the Commons version of these classes, and its internal
versions will be deprecated.
The proposed package name for the new component is
jakarta-commonsCVS repository. All initial committers are already committers on
jakarta-commons, so no additional user setups are required.
The initial committers on the BeanUtils component shall be Craig McClanahan and Geir Magnusson Jr.