You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by Henrik Vendelbo <hv...@bluprints.com> on 2003/10/15 23:40:27 UTC

Re: Which database am I using?

Was this ever discussed. I am trying to make embedded Xindice to work with
the right directory, with little luck.

Even if it works, defining a property on the command line is not an option,
so I tried

DatabaseManager.setProperty(DB_HOME_PROP,"C:\\demo\\db");

Database database = (Database) Class.forName(driver).newInstance();


System.setProperty(DB_HOME_PROP,"C:\\demo\\dspc\\db");

DatabaseManager.registerDatabase(database);



Neither works when using the xindice-embed.



So perhaps I should sub-class the DatabaseImpl ?





----- Original Message ----- 
From: "Mark R. Diggory" <md...@latte.harvard.edu>
To: <xi...@xml.apache.org>
Sent: Saturday, April 12, 2003 1:40 AM
Subject: Which database am I using?


> Here's an interesting issue I've bounced across.
>
> If I'm using the embedded driver to access the database locally. The
> embedded driver looks for the db location in the system property if it
> can't find it it goes for a default local to the current working
> directory (which I suspect can vary across OS's and Servlet Containers).
>
> <!-- Snip from embeded DataBaseImpl -->
>    public static final String PROP_XINDICE_CONFIGURATION =
> "xindice.configuration";
>
>    // Default configuration if a system.xml file isn't available.
>    public static final String DEFAULT_CONFIGURATION = "<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>";
>
> Now, If I'm using the XindiceServlet to startup xindice it first looks in
>
> <!-- snip from web.xml-->
>          <param-name>xindice-configuration</param-name>
>          <param-value>/WEB-INF/system.xml</param-value>
>
> then if thats not set it goes to
> <!-- Snip from XindiceServlet -->
> Xindice.DEFAULT_CONFIGURATION
>
> then this all can get overridden if the following is set.
> <!-- Snip from XindiceServlet -->
> // Let's see if the property was specified.
> String home = System.getProperty("xindice.db.home");
>
>
> How can I make sure that the embedded driver and and my servlet config
> are always working with the same database?
>
> 1.) It looks like if the embedded driver is defaulting to
> DEFAULT_CONFIGURATION while the Servlet Config could run off and
> establish its db at "xindice.db.home" instead of at DEFAULT_CONFIGURATION.
>
> 2.) It looks like to really make sure both are using the same config I
> need to set the System.property "xindice.configuration" to be the same
> as my <param-name>xindice-configuration</param-name>. Setting the system
> property may not be possible in some containers. This would make it
> impossible to have separate db instances in separate webapplications
> wouldn't it?
>
> Not sure of a solution, I've noticed some comments in the source that
> xmldb group is working on a new configuration interface?
>
>    /**
>     * Creates new <code>DatabaseImpl</code> instance. The configuration is
>     * loaded from the file defined in the PROP_XINDICE_CONFIGURATION
system
>     * variable.
>     *
>     * This is only a temporarly solution since the question of a new init
>     * method is raised in the xmldb:api group. Another solution could be
to
>     * use the Configurable interface and only create the database when the
>     * getCollection method is called.
>     */
>
> Vladimir, You may get a patch or two out of me soon!  ;-)
> -Mark
>
>
>
>