The Artima Developer Community
Sponsored Link

I agree

Advertisement

Advertisement

This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

I agree

Posted by Bill Venners on 17 Feb 1999, 6:26 AM

> I've used code such as:

> this.getClass().getMethod(methodName, null).invoke(this, null);

> in a servlet where 'methodName' is a CGI parameter. I agree that
> runtime info should be avoided if possible, but I think that in
> this case it is justified. What does anyone else think?

I agree that this is a perfectly appropriate and fine use of
run time class info, given that you've got a method name as
a string. I don't know anything about what it is you are trying
to accomplish with your servlet, but I wonder if there was some
other way to define it such that you can customize not by
adding a method then giving a method name, but by simply adding
a subclass and giving the class name as a CGI parameter.
I usually think of customization by type.

bv






Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us