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