commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kris Nuttycombe" <Kris.Nuttyco...@noaa.gov>
Subject [beanutils] PropertyUtils & DynaBeans
Date Sat, 04 Dec 2004 00:55:39 GMT
Hi, all,

As it currently stands, PropertyUtils doesn't support DynaBeans for a 
number of its methods. It doesn't make much sense to return 
PropertyDescriptors for DynaBeans, but it's no great pain to use 
WrapDynaClass on an ordinary class and thereby be able to introspect 
either regular beans or DynaBeans using the same interface. To support 
this, I'd like to add a method with the signature:

DynaProperty[] getDynaProperties(Object bean)

to PropertyUtilsBean, with a corresponding static method in PropertyUtils.

Now, one of the other advantages of using PropertyUtilsBean is that it 
caches the introspected data. Conceivably, this would also be a useful 
feature for the getDynaProperties method. However, here we have a 
problem: since DynaClass doesn't have any way to enforce that its 
implementations implement HashCode, there's no way to use the same map 
caching strategy as is used for the PropertyDescriptors. This 
illustrates a larger issue, which is that DynaClass objects aren't 
singletons like Class objects are.

To resolve this, I propose adding an AbstractDynaClass base class that 
implements hashCode() and equals() based upon the public methods 
available in DynaClass. This way, even if DynaClasses aren't singletons, 
they can be used for hash keys. It might be also useful to implement a 
registry for DynaClasses in this abstract class to provide 
singleton-like functionality. Existing DynaClass implementations would 
be modified to extend AbstractDynaClass.

Any thoughts?

Kris


-- 
=====================================================
Kris Nuttycombe
Associate Scientist
Geospatial Data Services Group
CIRES, National Geophysical Data Center/NOAA
(303) 497-6337
Kris.Nuttycombe@noaa.gov
=====================================================



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message