On Fri, 10 May 2002, Adolfo Miguelez wrote:
> Date: Fri, 10 May 2002 08:55:26 +0000
> From: Adolfo Miguelez <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: �DynaBeans performance?
>
> Hi All,
>
> despite, AFAIK, Struts propose usual JavaBeans as value objects to be sent
> to JSPs, we are using general hashmaps to hold the results from database
> queries to JSP. It allow as skipping to create a particular bean for each
> result from the database, and making a general mechanism rather than a
> specific one.
>
> The backward of that is that custom tags assume that data holders in JSP are
> beans and they allow just to render info stored in them rather than in
> hashmaps so, in some cases, we need to provide a customized custom tag to
> introspects hashmaps info from the JSP.
>
> We have just met DynaBeans days ago, and I was wondering if we could modify
> our value objects to be DynaBeans rather than hashmaps. In that way, we
> would not need to patch Struts custom tags. they seems to be available since
> Struts 1.1b1, is not it?
>
Yes, in terms of using DynaActionForm. You can also use standard
DynaBeans directly (for instance, to create value objects) by grabbing
version 1.3 of the commons-beanutils package.
http://jakarta.apache.org/commons/beanutils/
The JavaDocs have pretty thorough coverage of DynaBeans, as well as the
alternative implementations that are available in the standard package.
> My question is which one is performance impact of creating DynaBeans on the
> fly, and filling them with results from database queries. Since DynaBeans
> are created by introspection techniques, I am afraid they could slow down
> the application performance.
>
Have you looked inside the DynaBeans implementation classes by chance?
It's just using HashMaps underneath :-)
In fact, if you use the BasicDynaBean implementation class for your value
objects, there is *no* reflection going on in the get() and set() methods.
The only difference, compared to maintaining your own HashMap, is that
BasicDynaBean will do property name and property type checking for you.
> Does anyone have made any test in this area or any opinion in this concern?
>
> Thanks in advance,
>
> Adolfo
>
Craig
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>