[Mulgara-svn] r1662 - in trunk/src/jar/server: . java/org/mulgara/server
pag at mulgara.org
pag at mulgara.org
Mon Apr 6 17:54:20 UTC 2009
Author: pag
Date: 2009-04-06 10:54:19 -0700 (Mon, 06 Apr 2009)
New Revision: 1662
Modified:
trunk/src/jar/server/build.xml
trunk/src/jar/server/java/org/mulgara/server/ServletMulgaraServer.java
Log:
Updated database creation and access to enable other servlets to access the created database with limitted description of this servlet.
Modified: trunk/src/jar/server/build.xml
===================================================================
--- trunk/src/jar/server/build.xml 2009-04-06 17:51:00 UTC (rev 1661)
+++ trunk/src/jar/server/build.xml 2009-04-06 17:54:19 UTC (rev 1662)
@@ -60,8 +60,7 @@
<target name="server-configure"
depends="-server-prepare"
- description="Prepares any configuration files/generated code for the
- server">
+ description="Prepares any configuration files/generated code for the server">
<!-- Copy the Embedded Mulgara server to obj directory -->
@@ -73,8 +72,7 @@
<copy todir="${server.obj.dir}/java/"
preservelastmodified="yes">
<fileset dir="${server.src.dir}/java/"
- includes="**/*.java"
- excludes="**/ServletMulgaraServer.java"/>
+ includes="**/*.java"/>
</copy>
<antcall target="-server-token-build-label"/>
@@ -100,7 +98,7 @@
</target>
<target name="server-compile"
- depends="server-configure, store-jar, store-xa-jar, resolver-spi-jar, util-xa-jar"
+ depends="server-configure, store-jar, store-xa-jar, resolver-spi-jar, util-xa-jar, util-jar"
description="Compiles all server related files included generated
source code">
Modified: trunk/src/jar/server/java/org/mulgara/server/ServletMulgaraServer.java
===================================================================
--- trunk/src/jar/server/java/org/mulgara/server/ServletMulgaraServer.java 2009-04-06 17:51:00 UTC (rev 1661)
+++ trunk/src/jar/server/java/org/mulgara/server/ServletMulgaraServer.java 2009-04-06 17:54:19 UTC (rev 1662)
@@ -48,10 +48,10 @@
import org.apache.log4j.PropertyConfigurator;
// locall written packages
-import org.mulgara.resolver.Database;
import org.mulgara.server.SessionFactory;
import org.mulgara.server.SessionFactoryException;
import org.mulgara.server.SessionFactoryFactory;
+import org.mulgara.util.Closable;
/**
* Servlet startup wrapper for a Mulgara server. <p>
@@ -104,23 +104,26 @@
/** the database of this server */
- private static Database database = null;
+ private static SessionFactory database = null;
+ public ServletMulgaraServer() {
+ }
+
/**
* Sets the database of this server.
- * @param database the database of this server
+ * @param database the database of this server, refered to as a SessionFactory.
*/
- public static void setDatabase(Database database) {
+ public static void setDatabase(SessionFactory database) {
ServletMulgaraServer.database = database;
}
/**
- * Sets the database of this server.
- * @return The Database value
+ * Gets the sessionFactory/database of this server.
+ * @return The database value as a SessionFactory
*/
- public static Database getDatabase() {
+ public static SessionFactory getDatabase() {
return ServletMulgaraServer.database;
}
@@ -156,7 +159,11 @@
// if it we don't have one already, create a new database
if (ServletMulgaraServer.getDatabase() == null) {
- ServletMulgaraServer.setDatabase(createDatabase());
+ try {
+ ServletMulgaraServer.setDatabase(createDatabase());
+ } catch (Throwable t) {
+ log.info("No local database available. Using RMI.");
+ }
}
}
@@ -170,7 +177,11 @@
// log that we're stopping the database
if (log.isInfoEnabled()) log.info("Stopping Mulgara server");
- getDatabase().close();
+ try {
+ ((Closable)getDatabase()).close();
+ } catch (Exception e) {
+ log.error("Unable to close database cleanly", e);
+ }
setDatabase(null);
}
@@ -283,7 +294,7 @@
* @return The created database.
* @throws ServletException if the database could not be created.
*/
- private synchronized Database createDatabase() throws ServletException {
+ private synchronized SessionFactory createDatabase() throws ServletException {
try {
// configure the system properties
if (log.isDebugEnabled()) log.debug("Configuring system properties");
@@ -312,7 +323,7 @@
SessionFactoryFactory factory = new SessionFactoryFactory();
SessionFactory sessionFactory = factory.newSessionFactory(serverURI, statePath);
- return (Database)sessionFactory;
+ return sessionFactory;
} catch (SessionFactoryException sfe) {
// log the error
More information about the Mulgara-svn
mailing list