I though that's what I did in my first mail? Anyhow, Here's how this could be handled
in eXist:
Assuming a variable configurationDocument with the following content:
<exist>
<db-connection database="native" files="data"
buffers="128" words_buffers="5120" collection_buffers="256"
elements_buffers="1024" free_mem_min="2000000"
grow="32" compress="false" pageSize="4096"/>
<indexer batchLoad="true" tmpDir="tmp"
stemming="false" controls="ctl" caseSensitive="false"
suppress-whitespace="both">
<stopwords file="stopword"/>
<index doctype="users" default="none" />
<entity-resolver>
<catalog file="samples/xcatalog.xml"/>
</entity-resolver>
</indexer>
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j">
<appender name="simple" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{DATE} %-5p> %m\n"/>
</layout>
</appender>
<root>
<appender-ref ref="console"/>
<priority value="debug"/>
</root>
<category name="org.exist.xmldb">
<appender-ref ref="simple"/>
<priority value="warn"/>
</category>
</log4j:configuration>
</exist>
An eXist db could be started as follows:
Class driver = Class.forName("org.exist.xmldb.DatabaseImpl");
Database db = (Database)driver.newInstance();
db.configure(configurationDocument);
DatabaseManager.registerDatabase(db);
An alternative would be to let configurationDocument point out the location of
configuration
resources e.g. have the following content:
<configuration>
<eXist>file:///home/per/eXist/config.xml</eXist>
<log4j>file:///home/per/eXist/log4j.xml</log4j>
</configuration>
This makes it flexible in supporting different approaches to configure a database with
a common api
but proprietary content. Flattening this structure out with key value pairs that the
Configurable
interface provides is clunky IMO, that's what I meant with "not provide a very good
support".
For Xindice it could be used as follows:
configurationDocument contains the following data:
<xindice>
<root-collection dbroot="./db/" name="db">
<queryengine>
<resolver autoindex="false"
class="org.apache.xindice.core.query.XPathQueryResolver" />
<resolver class="org.apache.xindice.core.xupdate.XUpdateQueryResolver" />
</queryengine>
</root-collection>
</xindice>
Class c = Class.forName("org.apache.xindice.client.xmldb.DatabaseImpl");
Database database = (Database) c.newInstance();
db.configure(configurationDocument);
DatabaseManager.registerDatabase(database);
Then the implementation of configure in org.apache.xindice.client.xmldb.DatabaseImpl
could perhaps
do something like the following:
public void configure(org.w3c.Document) {
Element serverConfig = (Element)
configurationDocument.getDocumentElement().getElementsByTagName("root-collection").item(0);
Database db = new org.apache.xindice.core.Database();
db.setConfig(new Configuration(serverConfig, false));
}
This makes it hard to shutdown properly since this is done by calling close() on
org.apache.xindice.core.Database. There are other ways to support this but as (I
think) Vladimir
hinted, what would be even better is startup() and shutdown() (or init() and stop())
on a Database.
Preferably but not necessarily , startup() is different from configure() since that
would allow for
more fine grained control of setting up the database versus controlling its life
cycle, but that's
for another mail...
Hope that makes things clearer?
Best regards,
Per
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Lars Martin
> Sent: Tuesday, November 12, 2002 3:31 PM
> To: [EMAIL PROTECTED]
> Subject: Re: FW: Configuring an XML:DB database
>
>
> On Mon, 11 Nov 2002 10:11:28 -0800
> "Vladimir R. Bossicard" <[EMAIL PROTECTED]> wrote:
>
> > > What about the "Configurable" interface? "Database" extends this
> > > interface. What do you mean by a "very good support"?
> >
> > but after setting several properties (like database location), you
> > usually still need an 'init()' method. Maybe an 'Initializable'
> > interface could solve the problem?
>
> Normally you should use "getCollection()" right after setting your
> properties with "setProperty()".
> Wolfgang can you send an example of usage to the mailing list so
> that every interested developer can read/understand your intention
> to introduce an "configure()" method!?
> Thanks, Lars.
> --
> ______________________________________________________________________
> Lars Martin mailto:[EMAIL PROTECTED]
> SMB GmbH http://www.smb-tec.com
> D-04347 Leipzig Rohrteichstrasse 18
> Tel: +49-(0)341-699 46 04 Fax: +49-(0)341-699 47 04
> Product Management BusinessServer BS1
>
> ----------------------------------------------------------------------
> Post a message: mailto:[EMAIL PROTECTED]
> Unsubscribe: mailto:[EMAIL PROTECTED]
> Contact administrator: mailto:[EMAIL PROTECTED]
> Read archived messages: http://archive.xmldb.org/
> ----------------------------------------------------------------------
>
>
----------------------------------------------------------------------
Post a message: mailto:[EMAIL PROTECTED]
Unsubscribe: mailto:[EMAIL PROTECTED]
Contact administrator: mailto:[EMAIL PROTECTED]
Read archived messages: http://archive.xmldb.org/
----------------------------------------------------------------------