A very good example of coding this sort of thing is the DispatchAction
class in the Struts Action package.

http://jakarta.apache.org/struts/api/org/apache/struts/actions/DispatchAction.html

If you are worried about performance, it would be very easy to use
DispatchAction to combine several of your existing Actions together, and
then use jMeter to run some load tests. At this time, things like the
cost of reflection can be vary by setup. 


Jon Brisbin wrote:
> 
> I use a BaseAction class that does all my normal struts stuff like setting
> the request, doing authentication checking, managing the object cache,
> etc...and have been contemplating implementing this architecture:
> 
> In my form, I already use an "action" variable that tells me what i'm doing
> in my action class...probably the way most folks do it...but I'd like to
> have an action variable that might be like:
> "addSomething,addAnother,editSomethingElse"...the action class would then
> reflect those methods and call them in order...that way my "real" action
> classes only subclass my base class and implement any of the methods i
> choose to call from the action variable...i use object-wide variables for
> stuff like the request, mapping, etc...
> 
> my question, though, is if this would violate any major design concepts, or
> introduce an unweildy performance bottleneck in my action classes...i
> already use reflection in my form validation code, but that's just
> getReadMethod stuff, so no big deal...i was wondering if anyone has
> experience with all-around performance with reflection in action classes??
> i know someone posted a while back that they had done some testing and found
> an insignificant difference between static method calls and reflected stuff,
> but i didn't know what *types* of reflection that entailed...i would
> basically have to do a lot of getMethod()s, which i've heard can be quite
> expensive...
> 
> any thoughts/help would be appreciated! :-)
> 
> Jon Brisbin
> www.jbrisbin.net

Reply via email to