commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McClanahan <craig...@gmail.com>
Subject Re: [chain] dispatch via lookup
Date Fri, 03 Dec 2004 18:25:52 GMT
How about this?

    Context context = ...; // Commons Chain context for this command
    String catalogName = ...; // Name of catalog containing the command you want
    String commandName = ...; // Name of command you want (from this catalog)
    Catalog catalog = CatalogFactory.getInstance().getCatalog(catalogName);
    Command command = catalog.getCommand(commandName);
    command.execute(context);

Note that it uses a static method, so you don't have to carry around
references to a catalog in your method signatures ... just figure out
what catalog and command you want, and go.

Craig



On Fri, 03 Dec 2004 11:23:40 -0600, Vic <vin@friendvu.com> wrote:
> 
> Craig wrote quote in a struts dev thread on chain "
> 
> In your standard processing chain, do something like this:
> 
>      <command className="org.apache.commons.chain.generic.LookupCommand
>                    catalogName="foo"
>                           name="bar"
>                       optional="true"/>
> 
> What this does, in English, is:
> * Look up a command named "bar" in a catalog named "foo".
> * If such a command exists, delegate control to it
>    (and do all the right stuff about filters if this is a chain)
> * If such a command does not exist, silently continue
> 
> " end quote.
> 
> I do not understand how to do above.  Is that the declaration done in
> chain.xml?
> This assumes that I hard code the name of command I want to go to.
> (if I knew command at decleration I would just name it then, not look up).
> 
> Is there a built in way of dispatching dynamicaly?
> 
> for example: lookUpAndExecute("foo");
> 
> Hint?
> 
> tia,
> .V
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message