You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Michael Rasmussen <ra...@gmail.com> on 2005/03/10 05:07:40 UTC

Commons Chain And Branching/Iterating

I am new to using commons chain, so if this is a basic question, feel
free to tell me RTFM.  I am wondering if there is a way to create a
command that branches conditionally or iterates over a collection in
the context, and executes whatever is down chain from it based on that
collection or iteration.  Best I can tell right now, chain does not
allow a command ot influence the execution except by returning a true
or false from execute.   Am I missing out on something?  Is there a
way to add in flow control?

Thanks,
Michael

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: Commons Chain And Branching/Iterating

Posted by Craig McClanahan <cr...@gmail.com>.
Sorry for the late response on this -- I was in Tokyo all of last week
and not able to stay current on mailing list emails.

Out of the box, the closest any of the commands come to performing
conditional behavior is
org.apache.commons.chain.generic.LookupCommand, which executes a
specified command only if it can be found.  It would not be difficult
to write a command that did branching instead, based on some condition
-- the branch would be implemented as execution of an alternative
chain (or command) *instead of* continuing down the current chain.

Likewise, there's no built in support for iteration, but building a
Command that takes (say) a List of Context objects plus a command name
(or catalog + command name) and implements "execute this command for
each Context in the list" would be very easy to build.

Craig


On Wed, 9 Mar 2005 22:07:40 -0600, Michael Rasmussen
<ra...@gmail.com> wrote:
> I am new to using commons chain, so if this is a basic question, feel
> free to tell me RTFM.  I am wondering if there is a way to create a
> command that branches conditionally or iterates over a collection in
> the context, and executes whatever is down chain from it based on that
> collection or iteration.  Best I can tell right now, chain does not
> allow a command ot influence the execution except by returning a true
> or false from execute.   Am I missing out on something?  Is there a
> way to add in flow control?
> 
> Thanks,
> Michael
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org