kstaken 02/02/25 23:10:09
Modified: java/src/org/apache/xindice/core Database.java
java/src/org/apache/xindice/server Kernel.java
java/src/org/apache/xindice/server/services HTTPServer.java
java/src/org/apache/xindice/server/standard
StdLogManager.java
Log:
Fixes to improve embedability of the server. Changes path setting and kernel
exit states. Default behaviour for paths is more consistently relative to
xindice.home, removes dependence on process current working directory,
Default kernel behaviour is unaltered.
Revision Changes Path
1.2 +10 -2
xml-xindice/java/src/org/apache/xindice/core/Database.java
Index: Database.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/core/Database.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Database.java 6 Dec 2001 21:00:11 -0000 1.1
+++ Database.java 26 Feb 2002 07:10:09 -0000 1.2
@@ -56,7 +56,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- * $Id: Database.java,v 1.1 2001/12/06 21:00:11 bradford Exp $
+ * $Id: Database.java,v 1.2 2002/02/26 07:10:09 kstaken Exp $
*/
import org.apache.xindice.core.query.*;
@@ -84,6 +84,8 @@
private static final String COLKEY = "database.xml";
private static final String NAME = "name";
+ public static final String PROP_XINDICE_HOME = "xindice.home";
+
private static final Map databases = new HashMap(); // String to Database
private DocumentCache docCache = new DocumentCache();
@@ -117,7 +119,13 @@
name = config.getAttribute(NAME);
setCanonicalName('/' + getName());
- setCollectionRoot(new File(config.getAttribute(DBROOT)));
+
+ String dbroot = config.getAttribute(DBROOT);
+ if ( ! dbroot.startsWith("/") ) {
+ dbroot = System.getProperty( PROP_XINDICE_HOME ) +
+ "/" + dbroot;
+ }
+ setCollectionRoot(new File(dbroot));
// Create the security manager so that it exists for loading the system
// collections.
1.2 +33 -8
xml-xindice/java/src/org/apache/xindice/server/Kernel.java
Index: Kernel.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/server/Kernel.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Kernel.java 6 Dec 2001 19:33:55 -0000 1.1
+++ Kernel.java 26 Feb 2002 07:10:09 -0000 1.2
@@ -56,7 +56,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- * $Id: Kernel.java,v 1.1 2001/12/06 19:33:55 bradford Exp $
+ * $Id: Kernel.java,v 1.2 2002/02/26 07:10:09 kstaken Exp $
*/
import org.apache.xindice.util.*;
@@ -110,11 +110,16 @@
private UserManager users;
public Kernel() {
- this("system.xml");
+ this("system.xml", true);
}
public Kernel(final String name) {
- //System.runFinalizersOnExit(true);
+ this(name, true);
+ }
+
+ public Kernel(final String name, boolean exit) {
+
+ //System.runFinalizersOnExit(true);
// Read in the configuration
Document tmp = null;
@@ -128,7 +133,12 @@
catch ( Exception e ) {
System.err.println("\u0007FATAL ERROR: Reading configuration file
'"+name+"'");
org.apache.xindice.Debug.printStackTrace(e);
- System.exit(1);
+ if ( exit ) {
+ System.exit(1);
+ }
+ else {
+ throw new RuntimeException("\u0007FATAL ERROR: Reading
configuration file '"+name+"'");
+ }
}
final Document doc = tmp;
config = new Configuration(doc.getDocumentElement(), false); //
Read/Write
@@ -145,9 +155,14 @@
scripts = (ScriptManager)loadAPI(serverConfig.getChild(SCRIPTS));
components =
(ComponentManager)loadAPI(serverConfig.getChild(COMPONENTS));
- if ( !startServices() ) {
+ if ( !startServices() ) {
System.err.println("\u0007FATAL ERROR: Service manager could not be
started");
- System.exit(1);
+ if ( exit ) {
+ System.exit(1);
+ }
+ else {
+ throw new RuntimeException("\u0007FATAL ERROR: Service manager
could not be started");
+ }
}
// Start The Scheduling Daemon
@@ -259,7 +274,15 @@
}
public void shutDown(int exitCode) {
-
+ shutDown(exitCode, true);
+ }
+
+ /*
+ * Shutdown the kernel. If exit is false the VM won't exit but the
current kernel
+ * instance becomes invalid and should no longer be used.
+ */
+ public void shutDown(int exitCode, boolean exit) {
+
System.out.println();
removeTask(finalizer);
@@ -288,7 +311,9 @@
System.runFinalization();
// Shut Down The Kernel
- System.exit(exitCode);
+ if ( exit ) {
+ System.exit(exitCode);
+ }
}
private Object loadAPI(Configuration config) {
1.2 +7 -3
xml-xindice/java/src/org/apache/xindice/server/services/HTTPServer.java
Index: HTTPServer.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/server/services/HTTPServer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HTTPServer.java 6 Dec 2001 19:33:56 -0000 1.1
+++ HTTPServer.java 26 Feb 2002 07:10:09 -0000 1.2
@@ -56,7 +56,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- * $Id: HTTPServer.java,v 1.1 2001/12/06 19:33:56 bradford Exp $
+ * $Id: HTTPServer.java,v 1.2 2002/02/26 07:10:09 kstaken Exp $
*/
import org.apache.xindice.server.*;
@@ -118,9 +118,13 @@
public void setConfig(Configuration config) throws XindiceException {
super.setConfig(config);
-
+
docroot = config.getAttribute(DOCROOT, "./docs/");
-
+ if (! docroot.startsWith("/")) {
+ docroot = System.getProperty( Xindice.PROP_XINDICE_HOME ) +
+ "/" + docroot;
+ }
+
Configuration vserverConfig = config.getChild(VSERVERS);
if ( vserverConfig != null ) {
vserverConfig.processChildren(VSERVER,
1.2 +6 -1
xml-xindice/java/src/org/apache/xindice/server/standard/StdLogManager.java
Index: StdLogManager.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/server/standard/StdLogManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StdLogManager.java 6 Dec 2001 19:33:56 -0000 1.1
+++ StdLogManager.java 26 Feb 2002 07:10:09 -0000 1.2
@@ -56,7 +56,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- * $Id: StdLogManager.java,v 1.1 2001/12/06 19:33:56 bradford Exp $
+ * $Id: StdLogManager.java,v 1.2 2002/02/26 07:10:09 kstaken Exp $
*/
import org.apache.xindice.server.*;
@@ -100,6 +100,11 @@
public void setConfig(Configuration config) {
this.config = config;
logname = config.getAttribute(FILENAME);
+ if ( ! logname.startsWith("/") ) {
+ logname = System.getProperty( Xindice.PROP_XINDICE_HOME ) +
+ "/" + config.getAttribute(FILENAME);
+ }
+
archive = config.getBooleanAttribute(ROTATE);
today = DateUtilities.getDateLong(new Date());
if ( logname.length() > 0 ) {