On 7/16/07, richard head <[EMAIL PROTECTED]> 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="com.bs.email.Emailer"
smtpServer="xyz.abc.com" .../>


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.

Niall

Thank You.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to