In a nonweb world, it's pretty easy to load up a chain config file:
import org.apache.commons.chain.config.ConfigParser;
ConfigParser parser = new ConfigParser();
URL url = ...; // URL of your config resource, could be file: or
http: or whatever
parser.parse(url);
Craig
On Fri, 03 Dec 2004 16:24:40 -0600, Vic <[EMAIL PROTECTED]> wrote:
> Sorry for so many questions. One more.
>
>
>
>
> Craig McClanahan wrote:
> > On Fri, 03 Dec 2004 15:30:59 -0600, Vic <[EMAIL PROTECTED]> wrote:
> >
> >>Craig McClanahan wrote:
> >>
> >>>How about this?
> >>>
> >>> Context context = ...; // Commons Chain context for this command
> >>
> >>Just a Map in my case.
> >>
> >>
> >>> 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);
> >>
> >>How does above catalog know to read my Xml catlog file, when it does not
> >>know the url to my xml file where the catalog is defined. Is there a
> >>certian place it looks at?
> >>
> >
> >
> > Simplest thing is to use org.apache.commons.chain.web.ChainListener.
> > Configure it is a <listener> in web.xml and it will load up the
> > specified config files (see the Javadocs for this class to see how to
> > tell it which resources to read) at webapp startup.
> >
>
> Some of the time, I do not have a container. For example I do cron
> trigered async processing. They to use a chain.
> So if this is the only way... I will use my catalog extension that reads
> an xml file via digester. If there is something else, plz let me know.
>
> THANKS AGAIN!
>
> .V
>
>
>
>
> > My favorite feature of this class is if you have a JAR file (in
> > WEB-INF/lib) that has a "META-INF/chain-config.xml" resource in it,
> > this will get loaded automatically, without being explicitly listed in
> > web.xml. That way, you can package up a bunch of commands and chains
> > in a JAR, with a configuration resource, and it gets automatically
> > registered.
> >
> >
> >>> Command command = catalog.getCommand(commandName);
> >>
> >>Since I do not think it read the catalog of commands from my xml, it
> >>won't get the command. But if the catalog could read it, I see how this
> >>would work.
> >>How to read a catalog from XML?
> >>
> >
> >
> > See above.
> >
> >
> >>> 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
> >>
> >>This is what my implementation does, but I'd like to upgrade, there are
> >>some deprecated chain methods now.
> >>
> >>Of course ... I had to extend catalog to have a way of
> >>populating/initilzing self from XML.
> >>
> >>.V
> >>
> >>
> >>
> >>
> >>... just figure out
> >>
> >>>what catalog and command you want, and go.
> >>>
> >>>Craig
> >>>
> >>>
>
>
> ---------------------------------------------------------------------
>
>
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]