Quoting Marco Mistroni <[EMAIL PROTECTED]>: > Hi all, > I have a question about using BeanUtils in Struts. > For saving me from writing lot of code, I am using DynaActionForms in my > pages. > In the backend, I have some DTOs, so I decided in order to make > My app more 'extensible' without rewriting too much code, to use > BeanUtils to populate my DTOs with values from DynaActionForm, and to > Use the same mechanism to populate DynaActionForm from DTO. > > Now, pls correct me if I am wrong, but BeanUtils uses reflection in > Order to populate properties..
It uses reflection on POJOs (plain old Java objects) but not on DynaBeans -- the implementation inside DynaActionForm is a HashMap with typesafe getters and setters. > I have read from some books ('Effective Java') that using reflection > Is much slower than invoking methods normally.. > In my app, Depends totally on what JVM you are using -- the answer changes with every version. Whether it's visible to you (in terms of increased response time) is even more variable, but in most web based environments the database is the primary cause for delays, followed by network traffic. The only way that reflection can make any difference at all is if you're CPU bound on your web tier server. > I will gain flexibility (I don't need to write methods for > Populating dtos from form and vice versa), but am I going to lose much > In tems of performance? > Depends on your application environment (as described above), but it's pretty unikely to cause a problem -- especially if you use dynabeans, which don't use reflection at all :-). > Anyone can give his comments? I think BeanUtils is of great help,and it > would be a pity to give up the benefits that I get from it... > The only way to know if this matters in your application is to benchmark your application. But there are thousands of Struts-based webapps in the world, many using traditional ActionForms (and therefore heavily dependent on reflection). Aiming for "fastest possible" is the wrong target. Aiming for "fast enough" lets you focus on other goals about your app (less code, easier maintenance, and so on) also. > Best regards > marco > Craig McClanahan --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]