commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton" <>
Subject Re: Chain of Responsibility Catalog, Adding Command Element Attributes
Date Mon, 16 Jul 2007 23:01:25 GMT
On 7/16/07, richard head <> wrote:
> Hi,
> I've been playing around with the Commons Chain of Responsibility
> implementation and have a question or two. Maybe a chain is not the right
> approach, I'd appreciate any suggestions.
>         I'd like to make a Chain that retrieves an XML document, transforms it, and
> emails the results.  3 Commands as I see it. Each of these Commands requires
> information that is independent of the others. XML file's URL, XSLT
> transformation's output path, SMTP server etc…
> I understand that the preferred method of retaining state is to use the
> Chain's Context. Yet in this situation is seems inflexible, as the class
> instantiating the chain will be tightly bound to it because it would have to
> anticipate each link and what each link's Context requirements are.
> What I would like to do is use a catalog.xml file to store the chain, and
> add the appropriate attributes to the given command element.
> i.e. <command name="EmailUser" className=""
> smtpServer="" .../>
> In order to achieve such functionality, what would I have to do, set the
> appropriate rules in the ConfigParser's Digester?
> i.e.
> config.getDigester().addSetProperties("/catalog/chain/command","smtpServer","smtpServer")

You don't have to change the configured digester rules at all -  just
add getters/setters as appropriate - so in your case adding
setSmtpServer() and getSmtpServer() methods to your Emailer command
and when the xml is parsed they will get called with the values you've
specified in your xml.

> I would prefer to do this via the Emailer's constructor, but it appears that
> it's not possible and one must use getters and setters.

No its not possible with the XML/Digester configuration provided by
Commons Chain.


> Thank You.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message