ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: DispatchTask
Date Fri, 04 Jun 2004 15:14:02 GMT
> From: Magesh Umasankar [mailto:umagesh@apache.org]
> > > I'd like to introduce the concept of a DispatchTask to Ant.
> >
> > Do you think a task with a mode/action that selects the method to run
> > instead of execute is really that common?
> 
> Well, it is a pretty common pattern used to group closely related
> sub-actions
> together while avoiding messy conditionals (like in our very own FTP).  On
> a
> tangential note, Struts has a similar concept called DispatchAction, which
> is
> popular.  A couple of third-party task implementations that use 'actions'
> instead
> of defining individual tasks are:
> - Weblogic's wlserver that allows startup, shutdown, connect and reboot as
> action options.
> - Dale Anson's Stopwatch task at Ant-contrib (a very nice use-case for
> DispatchTask)
> that allows start, stop, elapsed and total as action options.
> I'm sure there are plenty more...

OK, you've convinced me Magesh ;-) I've just posted a message on another
thread that proposed an alternative, but for the stopwatch example, the
action attribute (or mode, or command) seems like the simpler alternative.

Maybe we just don't need a DispatchTask, but a simple static utility method
that does the dispatching instead?

Could take the form of

public static void dispatchAction(String action, Task target) { ... }

or 

public static void dispatchAction(String action, Object target) { ... }

to make it fully bean friendly.

Then it's just the matter of writer

execute() { TasktUtils.dispatchAction(_action, this); }

And one can use any 'action' attribute one wants.

When it can be avoided, I prefer to keep my single inheritance
choices open. --DD

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message