Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 22370 invoked from network); 3 Dec 2004 22:19:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 3 Dec 2004 22:19:59 -0000 Received: (qmail 64328 invoked by uid 500); 3 Dec 2004 22:19:36 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 64277 invoked by uid 500); 3 Dec 2004 22:19:36 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 64263 invoked by uid 99); 3 Dec 2004 22:19:36 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=RCVD_BY_IP,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of craigmcc@gmail.com designates 64.233.170.201 as permitted sender) Received: from rproxy.gmail.com (HELO rproxy.gmail.com) (64.233.170.201) by apache.org (qpsmtpd/0.28) with ESMTP; Fri, 03 Dec 2004 14:19:35 -0800 Received: by rproxy.gmail.com with SMTP id g11so160101rne for ; Fri, 03 Dec 2004 14:19:34 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=OXtgJFO+ebnYWr70OmiaDcgc6BdhF9kkH+Q97tLDtsIC1oVcYauQtqiWb2ekHRoEKgqEU0y/mzVWFT24chCl9c8VmHNU8OC7nDuRPvhC3KNd5z1Tyksp79qjI9ja7TfUCwC1bXezyyeUK295DPFzxsemxj1zaaNn3/5Wrmj2svE= Received: by 10.38.90.7 with SMTP id n7mr846772rnb; Fri, 03 Dec 2004 14:19:30 -0800 (PST) Received: by 10.38.72.38 with HTTP; Fri, 3 Dec 2004 14:19:29 -0800 (PST) Message-ID: Date: Fri, 3 Dec 2004 14:19:29 -0800 From: Craig McClanahan Reply-To: craigmcc@apache.org To: Jakarta Commons Users List Subject: Re: [chain] dispatch via lookup In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N On Fri, 03 Dec 2004 15:30:59 -0600, Vic 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 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. 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 > > > > > > > > On Fri, 03 Dec 2004 11:23:40 -0600, Vic wrote: > > > >>Craig wrote quote in a struts dev thread on chain " > >> > >>In your standard processing chain, do something like this: > >> > >> >> 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 > > --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org