commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: [Chain] examples XML file available?
Date Sun, 21 Sep 2003 21:53:42 GMT
On Sun, 21 Sep 2003, Sgarlata Matt wrote:

> Date: Sun, 21 Sep 2003 13:45:37 -0400
> From: Sgarlata Matt <>
> Reply-To: Jakarta Commons Developers List <>
> To:
> Subject: [Chain] examples XML file available?
> I'm interested in possibly using the Chain package in some of my projects
> and I was hoping I could get an example XML file to feed to the Digester?  I
> don't need the Command classes associated with the file or anything like
> that, I'd just like to see an example so I don't have to reverse-engineer
> its structure from the ConfigRuleSet.

There's an example in the unit tests of the source module


although, in truth, this is only a test of the default rules -- you
actually get to configure what element and attribute names are recognized
by setting properties on your own copy of ConfigRuleSet instead of using
the default one (unit tests for this would be definitely appreciated :-).

There's another example in the CVS HEAD sources of Struts, where we are
experimenting with building a replacement for the current RequestProcessor
class to assemble the request processing pipeline:


This is probably more typical of how chain might get used in real life.

If you don't want to download the entire source distros (or use anonymous
CVS), you can access these files individually (from the
"jakarta-commons-sandbox" and "jakarta-struts" repositories,
respectively), via ViewCVS:

> If I play with the package some more and like it, I could provide a DTD for
> the XML file and documentation for it.  That should save Craig and Ted from
> some boring work :)

While we definitely appreciate the help :-), I don't think a DTD (or a
schema) that captures all of the possible functionality of the XML based
configuration.  Consider one of the examples in the unit test:

    <!-- Configurable command with settable properties -->
    <command   name="Configurable"
                foo="Foo Value"
                bar="Bar Value"/>

Besides actually instantiating TestCommand and inserting it into the
parent Catalog, this leverages Digester's "Set Properties Rule" ability to
match attributes to writeable propertes and configure them.  The entry
above, then, calls setFoo() and setBar() on the instantiated bean -- but
this is the same <command> element that is used to configure a different
type of command, with different properties, later on:

    <command      id="1"

I'm not a total guru on XML, but I don't see how one can define a DTD that
covers this case, since the set of possible attributes is not limited.

Tomcat users who are familiar with the server.xml file are undoutedly
smiling right now, because they're in pretty much the same boat, for the
same reasons.

> Thanks,
> Matt

Craig McClanahan

View raw message