commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McClanahan <craig...@gmail.com>
Subject Re: cvs commit:jakarta-commons/digester/src/java/org/apache/commons/digesterSetPropertiesRule.java
Date Wed, 22 Sep 2004 20:37:18 GMT
In case it is not obvious enough from the blatant comments in the
Javadocs, BeanUtils.populate() is ABSOLUTELY, POSITIVELY not
appropriate for general XML processing.  It is finely tuned to dealing
with typical issues you see in processing request parameters in a web
application (which is where this code was originally used in Struts).

If you need property copying with conversion, use
BeanUtils.copyProperties().  If you don't need the conversions,
PropertyUtils.copyProperties() will run substantially faster.

Craig McClanahan


On Tue, 21 Sep 2004 23:58:34 -0400, Hans Gilde
<hgilde-commons@earthlink.net> wrote:
> FTI, Jelly has a feature like just SetPropertiesRule in a tag called
> useBean.
> 
> I converted this tag from BeanUtils.populate to a combination of isWritable
> and copyProperty/copyProperties and all unit tests ran and several big Maven
> script also worked. Although I haven't uploaded the patch for this change.
> 
> Maybe all of commons should release this conversion at once, so that people
> are simply forced to adapt to it across the board. :)
> 
> Seriously, though, I really think that it'll work fine for you. I walked
> through the populate code and all I could find was stuff that honestly
> doesn't apply to XML processing. For instance, populate will handle a
> attribute with a "." in the name: <tag foo.bar="baz" /> will set the bean
> property .getFoo().setBar("baz") where "baz" is converted to the proper
> argument type. This is obviously meant for HTTP variable processing, not XML
> attributes.
> 
> Do you really want this feature? If not, I'd say you should try
> copyProperties with isWritable.
> 
> Hans
> 
> -----Original Message-----
> From: Simon Kitching [mailto:simon@ecnetwork.co.nz]
> Sent: Tuesday, September 21, 2004 12:06 AM
> To: Jakarta Commons Developers List
> Subject: Re: cvs
> commit:jakarta-commons/digester/src/java/org/apache/commons/digesterSetPrope
> rtiesRule.java
> 
> On Tue, 2004-09-21 at 09:59, rdonkin@apache.org wrote:
> > rdonkin     2004/09/20 14:59:23
> >
> >   Modified:    digester build.xml
> >                digester/src/java/org/apache/commons/digester
> >                         SetPropertiesRule.java
> >   Log:
> >   Allows exception throwing for mismatches to be switch on. Patch
> contributed by Gabriele Carcassi.
> 
> I'm worried about this patch.
> 
> The existing code to actually do the assignment to properties calls
> BeanUtils.populate(...) which calls BeanUtilsBean.populate(...) which
> calls BeanUtilsBean.setProperty(...).
> 
> This patch however uses PropertyUtils.isWriteable to check for the
> existence of the property.
> 
> The two code paths are completely different, and I am concerned that
> they may consider different things to be valid properties.
> 
> I would prefer to see either:
> (a) BeanUtils.populate modified to optionally throw an exception if a
> matching property can't be found, or
> (b) SetPropertiesRule be modified to use PropertyUtils methods to do the
> property setting rather than BeanUtils.populate.
> 
> The latter is probably too risky a change to make; too much chance of
> breaking existing digester users like Struts.
> 
> While I very much like this new feature, I am not convinced using
> PropertyUtils methods to implement it is safe.
> 
> Regards,
> 
> Simon
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
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