You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-dev@xml.apache.org by vg...@apache.org on 2004/02/12 04:12:18 UTC
cvs commit: xml-xindice/java/tests/src/org/apache/xindice IntegrationManagedTests.java
vgritsenko 2004/02/11 19:12:18
Modified: . build.xml status.xml
java/src/org/apache/xindice/client/xmldb DatabaseImpl.java
java/src/org/apache/xindice/client/xmldb/embed
DatabaseImpl.java
Added: java/src/org/apache/xindice/client/xmldb/managed
DatabaseImpl.java
Removed: java/src/org/apache/xindice/client/xmldb/managed
ManagedDatabaseImpl.java
java/tests/src/org/apache/xindice
IntegrationManagedTests.java
Log:
Add managed mode to embedded driver, improve javadoc.
Managed driver exteds embedded driver, set to managed mode.
Revision Changes Path
1.73 +14 -41 xml-xindice/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-xindice/build.xml,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- build.xml 8 Feb 2004 01:07:57 -0000 1.72
+++ build.xml 12 Feb 2004 03:12:18 -0000 1.73
@@ -19,7 +19,7 @@
-->
<!--
- - Build file for the Xindice Project.
+ - Build file for the Xindice Project.
-
- This script should be started from the xml-xindice directory with the
- following command line:
@@ -150,7 +150,7 @@
<fileset dir="${test.src.dir}" excludes="*.java"/>
</copy>
</target>
-
+
<target name="test-validate">
<taskdef name="testClassValidator" classname="junitx.ant.TestClassValidatorTask">
<classpath>
@@ -168,7 +168,7 @@
</fileset>
</testClassValidator>
</target>
-
+
<target name="test-unit" depends="test-build, test-validate">
<junit fork="yes" printsummary="yes" haltonfailure="no">
<jvmarg value="-Djava.endorsed.dirs=${basedir}/build/endorsed"/>
@@ -187,14 +187,14 @@
<exclude name="**/*Integration*.class"/>
<exclude name="**/integration/**"/>
</fileset>
- </batchtest>
+ </batchtest>
<classpath>
<path refid="project.class.path"/>
<pathelement location="${test.build.dir}"/>
</classpath>
</junit>
</target>
-
+
<target name="test-integration-embed" depends="test-build, test-validate">
<junit fork="yes" printsummary="yes" haltonfailure="no">
<jvmarg value="-Djava.endorsed.dirs=${basedir}/build/endorsed"/>
@@ -215,7 +215,7 @@
</classpath>
</junit>
</target>
-
+
<target name="test-integration-xmlrpc" depends="test-build, test-validate">
<echo message="XML-RPC driver='${test.xmlrpc.driver}'"/>
<echo message="XML-RPC host/port='${test.xmlrpc.hostport}'"/>
@@ -241,32 +241,11 @@
</classpath>
</junit>
</target>
-
- <target name="test-integration-managed" depends="test-build, test-validate">
- <junit fork="yes" printsummary="yes" haltonfailure="no">
- <jvmarg value="-Djava.endorsed.dirs=${basedir}/build/endorsed"/>
- <jvmarg value="-Dxindice.home=${basedir}"/>
- <jvmarg value="-Dxindice.db.home=${basedir}/build/test-managed"/>
- <jvmarg value="-Dxindice.configuration=${basedir}/config/system.xml"/>
- <jvmarg value="-Dorg.apache.commons.logging.Log=${test.logger}"/>
- <jvmarg value="-Dorg.apache.commons.logging.simplelog.defaultlog=${test.loglevel}"/>
-
- <formatter type="plain" usefile="no"/>
- <formatter type="xml"/>
-
- <test name="org.apache.xindice.IntegrationManagedTests"
- outfile="${test.result.dir}/org.apache.xindice.IntegrationManagedTests.xml"/>
- <classpath>
- <path refid="project.class.path"/>
- <pathelement location="${test.build.dir}"/>
- </classpath>
- </junit>
- </target>
<target name="test-all"
- depends="test-unit, test-integration-embed, test-integration-xmlrpc, test-integration-managed">
+ depends="test-unit, test-integration-embed, test-integration-xmlrpc">
</target>
-
+
<target name="test-report" depends="init">
<mkdir dir="${test.report.dir}"/>
<junitreport todir="${test.result.dir}">
@@ -276,7 +255,7 @@
<report format="frames" todir="${test.report.dir}"/>
</junitreport>
</target>
-
+
<target name="test" depends="test-all, test-report"
description="Run all tests and generate all test reports">
</target>
@@ -335,12 +314,6 @@
<target name="tomcat-deploy" depends="war-release" description="Deploys the Xindice webapp into the Tomcat installation">
<copy file="${dist.dir}/${project.filename}-${project.version}.xml" todir="${tomcat.home}/webapps"/>
<copy file="${dist.dir}/${project.filename}-${project.version}.war" todir="${tomcat.home}/webapps"/>
- <!-- TODO: Currently try to test the use of the xindice.xml file for the
- Tomcat installation.
- <unjar src="${dist.dir}/${project.filename}-${project.version}.war"
- dest="${tomcat.home}/webapps/${webapp.name}"
- overwrite="true"/>
- -->
</target>
<target name="tomcat-clean" description="Removes the deployed Xindice webapp from the Tomcat installation">
<delete dir="${tomcat.home}/webapps/${webapp.name}"/>
@@ -383,7 +356,7 @@
</target>
<target name="gump-target" depends="release"/>
-
+
<!-- clover -->
<target name="with.clover">
<taskdef resource="clovertasks"/>
@@ -392,8 +365,8 @@
<target name="clover.report" depends="with.clover">
<clover-report>
<current outfile="${build.dir}/clover_report">
- <format type="html"/>
- </current>
+ <format type="html"/>
+ </current>
</clover-report>
</target>
</project>
1.31 +18 -4 xml-xindice/status.xml
Index: status.xml
===================================================================
RCS file: /home/cvs/xml-xindice/status.xml,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- status.xml 11 Feb 2004 14:03:09 -0000 1.30
+++ status.xml 12 Feb 2004 03:12:18 -0000 1.31
@@ -7,7 +7,7 @@
<person name="Vadim Gritsenko" email="vgritsenko@apache.org" id="VG"/>
</developers>
<todo>
- <actions priority="high">
+ <actions priority="Long Term">
<action context="xml" dev="open">
<strong>Compressed DOM: Huge document support</strong> We need to
create a virtualized byte array class to drive the compressed DOM
@@ -48,6 +48,15 @@
</actions>
<actions priority="medium">
<action context="code" dev="open">
+ <strong>Authentication</strong> Xindice server should support: server
+ level authentication configured in the web.xml, and collection level
+ authentication as per XML:DB API getCollection method.
+ </action>
+ <action context="code" dev="open">
+ <strong>Authorization</strong> Xindice should support collection level
+ and document level authorization of users and groups.
+ </action>
+ <action context="code" dev="open">
<strong>Specifications</strong> We need to continue fleshing out our
technical specifications for the core.
</action>
@@ -61,6 +70,11 @@
<changes>
<release version="1.1b4-dev" date="February 11 2004">
<action dev="VG" type="update">
+ Xindice managed driver class renamed to DatabaseImpl and supports
+ same configuration parameters as embedded driver.
+ Xindice managed driver supports multiple database instances.
+ </action>
+ <action dev="VG" type="update">
Xindice server and XML-RPC driver support multiple database instances.
</action>
<action dev="VG" type="fix">
@@ -76,9 +90,9 @@
(20040205).
</action>
<action dev="VG" type="update">
- Embedded driver supports two configuration variables (see javadoc
- for details), and multiple database instances (see system.xml for an
- example).
+ Embedded driver has new configuration parameters (see javadoc
+ for details), and supports multiple database instances (see
+ system.xml for an example).
</action>
<action dev="VG" type="update">
Add max-descriptors configuration attribute to all Filer implementations
1.26 +4 -4 xml-xindice/java/src/org/apache/xindice/client/xmldb/DatabaseImpl.java
Index: DatabaseImpl.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/DatabaseImpl.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- DatabaseImpl.java 8 Feb 2004 02:43:01 -0000 1.25
+++ DatabaseImpl.java 12 Feb 2004 03:12:18 -0000 1.26
@@ -20,7 +20,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.xindice.client.xmldb.managed.ManagedDatabaseImpl;
+
import org.xmldb.api.base.Database;
import org.xmldb.api.base.ErrorCodes;
import org.xmldb.api.base.XMLDBException;
@@ -191,7 +191,7 @@
} else if (uri.startsWith(EMBED_URI)) {
driver = new org.apache.xindice.client.xmldb.embed.DatabaseImpl(this);
} else if (uri.startsWith(MANAGED_URI)) {
- driver = new ManagedDatabaseImpl();
+ driver = new org.apache.xindice.client.xmldb.managed.DatabaseImpl(this);
}
} catch (Exception e) {
log.error("Exception during creation of the Database", e);
1.25 +55 -22 xml-xindice/java/src/org/apache/xindice/client/xmldb/embed/DatabaseImpl.java
Index: DatabaseImpl.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/embed/DatabaseImpl.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- DatabaseImpl.java 8 Feb 2004 02:43:01 -0000 1.24
+++ DatabaseImpl.java 12 Feb 2004 03:12:18 -0000 1.25
@@ -41,31 +41,36 @@
/**
* Implements XML:DB's <code>Database</code> interface providing embedded access to
* a Xindice database. Usually, this class is not used
- * directly, use {@link org.apache.xindice.client.xmldb.DatabaseImpl} instead.
+ * directly, but {@link org.apache.xindice.client.xmldb.DatabaseImpl} is used instead.
*
* Embedded database driver supports multiple database instances simultaneously. To use
- * multiple instances, use several instances of this driver with different values for
- * the Xindice DB Name property.
+ * multiple instances, configure several <code>root-collection</code> elements in the
+ * Xindice configuration file and point this driver to this configuration.
+ *
+ * Currently, databases are loaded by the driver lazily, on first access to the
+ * database.
*
* Embedded database driver uses following configuration parameters:
* <ul>
- * <li>Xindice DB Home</li>
- * <li>Xindice Configuration</li>
+ * <li><strong>db-home</strong>: Specifies path to the Xindice DB Home directory</li>
+ * <li><strong>configuration</strong>: Specifies path to the Xindice Configuration file</li>
+ * <li><strong>managed</strong>: If set to true, driver will not load databases by himself,
+ * but will assume that third party code had initialized the database
+ * (See {@link org.apache.xindice.client.xmldb.managed.DatabaseImpl})</li>
* </ul>
*
- * These parameters can be specified either:
+ * If one of these parameters is not specified, system properties will be used.
+ *
+ * Driver parameters can be specified either:
* <ul>
* <li>by instantiating {@link org.apache.xindice.client.xmldb.DatabaseImpl}
- * and setting its properties (see {@link #setProperty}). You don't need to use
- * this class directly in this case.</li>
+ * and setting its properties (see {@link #setProperty}). You won't use this class
+ * directly in this case.</li>
+ * <li>by setting parameters via {@link #setProperty} method <strong>before</strong>
+ * obtaining collection with {@link #getCollection(String, String, String)} method.</li>
* <li>by setting Java system properties (see {@link System#setProperty(String, String)})</li>
* <li>by using constructor {@link DatabaseImpl#DatabaseImpl(CommonConfigurable)} and
* passing instance of CommonConfigurable with all properties already set.</li>
- * <li>by using {@link #setProperty} <strong>before</strong> calling
- * {@link #getCollection(String, String, String)}.</li>
- *
- * These properties are used in the getCollection method, and changes in those properties will
- * not affect this instance of the driver after collection is obtained.
*
* @author <a href="mailto:kstaken@xmldatabases.org">Kimbro Staken</a>
* @author <a href="mailto:james.bates@amplexor.com">James Bates</a>
@@ -80,22 +85,32 @@
/**
* Driver property name for the xindice database home.
*/
- private static final String PROP_XINDICE_DB_HOME = "db-home";
+ public static final String PROP_XINDICE_DB_HOME = "db-home";
/**
* System property name for the xindice database home.
*/
- private static final String SYSPROP_XINDICE_DB_HOME = Xindice.PROP_XINDICE_DB_HOME;
+ public static final String SYSPROP_XINDICE_DB_HOME = Xindice.PROP_XINDICE_DB_HOME;
/**
* Driver property name for the xindice configuration file.
*/
- private static final String PROP_XINDICE_CONFIGURATION = "configuration";
+ public static final String PROP_XINDICE_CONFIGURATION = "configuration";
/**
- * Driver property name for the xindice configuration file.
+ * System property name for the xindice configuration file.
*/
- private static final String SYSPROP_XINDICE_CONFIGURATION = Xindice.PROP_XINDICE_CONFIGURATION;
+ public static final String SYSPROP_XINDICE_CONFIGURATION = Xindice.PROP_XINDICE_CONFIGURATION;
+
+ /**
+ * Driver property name for the managed configuration parameter.
+ */
+ public static final String PROP_XINDICE_MANAGED = "db-managed";
+
+ /**
+ * System property name for the managed configuration parameter.
+ */
+ public static final String SYSPROP_XINDICE_MANAGED = "xindice.db.managed";
/**
* Prefix used to denote XML:DB URI's that should use this driver
@@ -123,7 +138,7 @@
/**
* Create a new DatabaseImpl object with a copy of the properties
- * from the DatabaseImpl parameter.
+ * from the <code>config</code> parameter.
*
* This allows to pass properties such as PROP_XINDICE_CONFIGURATION
* to this instance. Usually this is done by instantiating not this
@@ -145,7 +160,7 @@
*/
private Database getDatabase(String dbName, String uri) throws XMLDBException {
Database database = Database.getDatabase(dbName);
- if (database == null) {
+ if (database == null && !isManaged()) {
Configuration dbConfig = getConfiguration(dbName);
if (log.isDebugEnabled()) {
log.debug("Mounting database: '" + dbName + "'");
@@ -165,6 +180,20 @@
return database;
}
+ protected boolean isManaged() {
+ String managed = null;
+ try {
+ // Try configuration first
+ managed = getProperty(PROP_XINDICE_MANAGED);
+ } catch (XMLDBException ignored) {
+ }
+ if (managed == null) {
+ // Fallback to system property
+ managed = System.getProperty(SYSPROP_XINDICE_MANAGED);
+ }
+ return Boolean.valueOf(managed).booleanValue();
+ }
+
/**
* Get configuration for the named database
*/
@@ -361,6 +390,10 @@
}
Database database = getDatabase(dbName, uri);
+ if (database == null) {
+ throw new XMLDBException(ErrorCodes.NO_SUCH_DATABASE,
+ "Database '" + dbName + "' not found. URL: " + uri);
+ }
try {
return new CollectionImpl(database, colName);
} catch (XMLDBException e) {
1.1 xml-xindice/java/src/org/apache/xindice/client/xmldb/managed/DatabaseImpl.java
Index: DatabaseImpl.java
===================================================================
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* CVS $Id: DatabaseImpl.java,v 1.1 2004/02/12 03:12:18 vgritsenko Exp $
*/
package org.apache.xindice.client.xmldb.managed;
import org.apache.xindice.client.xmldb.CommonConfigurable;
/**
* The xindice-managed is a xindice client driver that requires third party code
* to create the database within the constraints of the client classloader. Typically
* it is used in embedded environments where database creation is managed by the third
* party code.
*
* This driver will throw an exception if the database instance you are trying to access
* hasn't been registered.
*
* @author <a href="mailto:kevin@rocketred.com.au">Kevin O'Neill</a>
* @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
* @version CVS $Revision: 1.1 $, $Date: 2004/02/12 03:12:18 $
*/
public class DatabaseImpl extends org.apache.xindice.client.xmldb.embed.DatabaseImpl {
/**
* Prefix used to denote XML:DB URI's that should use this driver
*/
public static final String DRIVER_NAME = "xindice-managed";
/**
* Creates new <code>DatabaseImpl</code> instance.
*/
public DatabaseImpl() {
super();
}
/**
* Create a new DatabaseImpl object with a copy of the properties
* from the <code>config</code> parameter.
*
* This allows to pass properties such as PROP_XINDICE_CONFIGURATION
* to this instance. Usually this is done by instantiating not this
* class, but {@link org.apache.xindice.client.xmldb.DatabaseImpl},
* set all the necessary parameters, and then get a collection.
*
* @param config from which the initial parameters for this
* DatabaseImpl object are copied.
*/
public DatabaseImpl(CommonConfigurable config) {
super(config);
}
/**
* @return true
*/
protected boolean isManaged() {
return true;
}
public boolean acceptsURI(String uri) {
return ((uri != null) && uri.startsWith(getName() + "://"));
}
/* (non-Javadoc)
* @see org.xmldb.api.base.Database#getName()
*/
public String getName() {
return DRIVER_NAME;
}
/* (non-Javadoc)
* @see org.xmldb.api.base.Database#getNames()
*/
public String[] getNames() {
return new String[]{ DRIVER_NAME };
}
}