Hi, I'd like to introduce the concept of a DispatchTask to Ant. This class may be subclassed by tasks that perform multiple operations depending upon a parameter. Currently, the task-writer would be using if...else if...else constructs. Extending from this class would make it more elegant. Use cases include tasks that take in same set of parameters but perform different operations based on needs.
Example usage would be: <somecompoundtask param1="..." param2="..." mode="list"/> In the above example, the custom task writer extends from DispatchTask instead of Task and implements a method with the signature: public void list() throws BuildException instead of the traditional public void execute() throws BuildException ..and the list() method would be invoked. A scratch-pad implementation follows. ================== package org.apache.tools.ant; public abstract class DispatchTask extends Task { private String mode; public final void setMode(final String mode) { this.mode = mode; } public void execute() throws BuildException { if (mode != null) { Method m = this.getClass().getMethod(mode, null); m.invoke(this, null); } } } ================== Comments? --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]