You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Joel Gluth <jo...@ping.net> on 2001/02/15 02:12:21 UTC

Valid XML config file in Avalon (was Re: [LONGISH] the thorny problem of MailetConfig.getInitParameterNames())

Federico Barbieri wrote:
> 
> Joel Gluth wrote:
<SNIP/>
> > I know this is strictly an Avalon question now, but is there a reason
> > you're allowed to specify config parameters that way, other than the
> > fact that it's a neat DOM hack?
> 
> ?... miss the question...

Sorry. For example, I can configure my Mailet through Avalon's XML file
like this:

<mailet match="All" class="Prototype">
                        
    <driver>org.postgresql.Driver</driver>
    <url>jdbc:postgresql://test01/rweiler</url>
    <username>rweiler</username>
    <password>rweiler</password>
    <port>1235</port>
    <debug>true</debug>
    <nConnections>2</nConnections>

</mailet>

The problem is, the document containing such an element can't be valid
XML without knowing all the names of the configuration options of all
the subcomponents, because it's impossible to write a DTD for.

Right now, it works because you can make a DOM tree from a well-formed
but invalid XML document, and then do
Element.getElementsByTagName("nConnections").item(1), for example, to
get the value of the nConnections option. Which is cute, but it's a hack
(BTW, I have to admit that I haven't looked at the Avalon code to see if
this is what happens). The convention

<mailet match="All" class="Prototype">
                        
    <param name="driver" value="org.postgresql.Driver"/>
    <!-- ... -->

</mailet>

Means that you can write a DTD for JAMES' .conf.xml file. As well as
satisfying our need to be able to do discovery on a list of parameters
;)

Having said all that, I understand that being able have
sub-Configurations with arbitrary names, like <mailet></mailet> is
pretty nice, and would be much harder to do if you enforced valid XML on
the Avalon config as a whole.

So. We're back with JAMES. Since JAMES' MailetConfig interface is
basically a very simple map of String keys to String values, it doesn't
need (or even allow) all the flexibility of its underlying
avalon.Configuration. It would be a good thing, I think, if JAMES
enforced the second kind of <mailet> tag layout.

Is such a thing acceptable to the JAMES team?
-- 
Joel Gluth \\ Disintegration Engineer, Ping.Net     http://www.ping.net
TCL - what a misnomer that is. For a language with such a fun name,
                                           it's pretty damn humourless.