[Mulgara-svn] r1005 - in branches/mgr-121-lockrecovery: . jxdata/iTQL jxdata/iTQL/advance_queries jxdata/iTQL/data_types/dateTime jxdata/iTQL/standard_queries lib src/jar/driver src/jar/itql/java/org/mulgara/itql src/jar/krule/java/org/mulgara/krule src/jar/query src/jar/query/java/org/mulgara/connection src/jar/query/java/org/mulgara/query/filter/value src/jar/query/java/org/mulgara/query/rdf src/jar/query/java/org/mulgara/server src/jar/resolver/java/org/mulgara/resolver src/jar/resolver-null/java/org/mulgara/resolver/nullres src/jar/resolver-relational/java/org/mulgara/resolver/relational src/jar/resolver-spi/java/org/mulgara/resolver/spi src/jar/resolver-store/java/org/mulgara/resolver/store src/jar/server-beep/java/org/mulgara/server/beep src/jar/server-rmi/java/org/mulgara/server/rmi src/jar/sparql-interpreter/java/org/mulgara/sparql src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa src/jar/store-stringpool-memory src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa src/jar/tuples-hybrid/java/org/mulgara/store/xa src/jar/util/java/org/mulgara/util tools/src/org/mulgara/tools

ronald at mulgara.org ronald at mulgara.org
Thu Jun 19 03:35:31 UTC 2008


Author: ronald
Date: 2008-06-18 20:35:29 -0700 (Wed, 18 Jun 2008)
New Revision: 1005

Added:
   branches/mgr-121-lockrecovery/jxdata/iTQL/advance_queries/queryResult6.txt
   branches/mgr-121-lockrecovery/jxdata/iTQL/advance_queries/queryResult7.txt
   branches/mgr-121-lockrecovery/jxdata/iTQL/advance_queries/result2.txt
   branches/mgr-121-lockrecovery/jxdata/iTQL/data-02-ext.ttl
   branches/mgr-121-lockrecovery/lib/joda-time-1.5.2.jar
   branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/connection/ConnectionFactoryUnitTest.java
   branches/mgr-121-lockrecovery/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintVariableRewrite.java
   branches/mgr-121-lockrecovery/src/jar/resolver-spi/java/org/mulgara/resolver/spi/DuplicateVariableTransformer.java
   branches/mgr-121-lockrecovery/src/jar/util/java/org/mulgara/util/LexicalDateTime.java
   branches/mgr-121-lockrecovery/src/jar/util/java/org/mulgara/util/LexicalDateTimeUnitTest.java
   branches/mgr-121-lockrecovery/src/jar/util/java/org/mulgara/util/Timezone.java
Removed:
   branches/mgr-121-lockrecovery/lib/DateUtils1.jar
Modified:
   branches/mgr-121-lockrecovery/.classpath
   branches/mgr-121-lockrecovery/build.properties
   branches/mgr-121-lockrecovery/build.xml
   branches/mgr-121-lockrecovery/common.properties
   branches/mgr-121-lockrecovery/common.xml
   branches/mgr-121-lockrecovery/jxdata/iTQL/advance_queries/test.jxu
   branches/mgr-121-lockrecovery/jxdata/iTQL/data_types/dateTime/queryResult17.txt
   branches/mgr-121-lockrecovery/jxdata/iTQL/data_types/dateTime/queryResult18.txt
   branches/mgr-121-lockrecovery/jxdata/iTQL/standard_queries/queryResult18.txt
   branches/mgr-121-lockrecovery/jxdata/iTQL/standard_queries/queryResult19.txt
   branches/mgr-121-lockrecovery/jxdata/iTQL/standard_queries/test.jxu
   branches/mgr-121-lockrecovery/lib/jrdf-0.3.4.3.jar
   branches/mgr-121-lockrecovery/lib/mulgara-sparql-0.0.1.jar
   branches/mgr-121-lockrecovery/src/jar/driver/build.xml
   branches/mgr-121-lockrecovery/src/jar/itql/java/org/mulgara/itql/ItqlInterpreterBeanUnitTest.java
   branches/mgr-121-lockrecovery/src/jar/itql/java/org/mulgara/itql/TqlAutoInterpreter.java
   branches/mgr-121-lockrecovery/src/jar/krule/java/org/mulgara/krule/Rule.java
   branches/mgr-121-lockrecovery/src/jar/query/build.xml
   branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/connection/Connection.java
   branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/connection/ConnectionFactory.java
   branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/connection/DummyConnection.java
   branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/connection/SessionConnection.java
   branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/query/filter/value/Var.java
   branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/query/rdf/LiteralImpl.java
   branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/query/rdf/XSD.java
   branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/server/Session.java
   branches/mgr-121-lockrecovery/src/jar/resolver-null/java/org/mulgara/resolver/nullres/NullResolution.java
   branches/mgr-121-lockrecovery/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalResolver.java
   branches/mgr-121-lockrecovery/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ResolverFactoryInitializer.java
   branches/mgr-121-lockrecovery/src/jar/resolver-store/java/org/mulgara/resolver/store/StatementStoreResolver.java
   branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/AppendAggregateTuples.java
   branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/ConstraintOperations.java
   branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/Database.java
   branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java
   branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/DatabaseResolverFactoryInitializer.java
   branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java
   branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/DefaultConstraintHandlers.java
   branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransactionFactory.java
   branches/mgr-121-lockrecovery/src/jar/server-beep/java/org/mulgara/server/beep/BEEPSession.java
   branches/mgr-121-lockrecovery/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSession.java
   branches/mgr-121-lockrecovery/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSessionWrapperSession.java
   branches/mgr-121-lockrecovery/src/jar/server-rmi/java/org/mulgara/server/rmi/SessionWrapperRemoteSession.java
   branches/mgr-121-lockrecovery/src/jar/sparql-interpreter/java/org/mulgara/sparql/SparqlInterpreter.java
   branches/mgr-121-lockrecovery/src/jar/store-stringpool-memory/build.xml
   branches/mgr-121-lockrecovery/src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory/MemoryStringPoolImplTest.java
   branches/mgr-121-lockrecovery/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImplTest.java
   branches/mgr-121-lockrecovery/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateImpl.java
   branches/mgr-121-lockrecovery/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateTimeImpl.java
   branches/mgr-121-lockrecovery/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateTimeUnitTest.java
   branches/mgr-121-lockrecovery/src/jar/tuples-hybrid/java/org/mulgara/store/xa/BlockCacheLine.java
   branches/mgr-121-lockrecovery/tools/src/org/mulgara/tools/Sparql.java
Log:
Merge revisions 954 to 1002 from trunk, and bump up the heap-size for the
tests so the jxunit tests don't run out of memory.


Modified: branches/mgr-121-lockrecovery/.classpath
===================================================================
--- branches/mgr-121-lockrecovery/.classpath	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/.classpath	2008-06-19 03:35:29 UTC (rev 1005)
@@ -126,7 +126,6 @@
 	<classpathentry kind="lib" path="lib/ant-junit-1.7.0.jar"/>
 	<classpathentry kind="lib" path="lib/ant-apache-bsf-1.7.0.jar"/>
 	<classpathentry kind="lib" path="lib/ant-1.7.0.jar"/>
-	<classpathentry kind="lib" path="lib/DateUtils1.jar"/>
 	<classpathentry kind="lib" path="lib/commons-httpclient-3.0.1.jar"/>
 	<classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/>
 	<classpathentry kind="lib" path="lib/castor-1.2-codegen.jar"/>
@@ -136,6 +135,7 @@
 	<classpathentry kind="lib" path="lib/velocity-1.5.jar"/>
 	<classpathentry kind="lib" path="lib/emory-util-2.1-remote.jar"/>
 	<classpathentry kind="lib" path="lib/mulgara-sparql-0.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/joda-time-1.5.2.jar"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="output" path="obj/jar"/>
 </classpath>

Modified: branches/mgr-121-lockrecovery/build.properties
===================================================================
--- branches/mgr-121-lockrecovery/build.properties	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/build.properties	2008-06-19 03:35:29 UTC (rev 1005)
@@ -110,7 +110,6 @@
 commons-httpclient.jar   =commons-httpclient-3.0.1.jar
 commons-logging.jar      =commons-logging-1.0.3.jar
 commons-codec.jar        =commons-codec-1.3.jar
-date-utils.jar           =DateUtils1.jar
 d2r.jar                  =d2rmap-V02.jar
 emory-util.jar           =emory-util-2.1-remote.jar
 httpclient.jar           =${commons-httpclient.jar}
@@ -126,6 +125,7 @@
 jetty.plus.jar           =org.mortbay.jetty.plus-4.2.19.jar
 jid3.jar                 =jid3-0.34.jar
 jmdns.jar                =jmdns-0.2.jar
+joda-time.jar            =joda-time-1.5.2.jar
 jrdf.base.jar            =jrdf-base-1.1.0.jar
 jrdf-doc.jar             =jrdf-doc-0.3.3.jar
 jrdf.jar                 =jrdf-0.3.4.3.jar

Modified: branches/mgr-121-lockrecovery/build.xml
===================================================================
--- branches/mgr-121-lockrecovery/build.xml	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/build.xml	2008-06-19 03:35:29 UTC (rev 1005)
@@ -1,1994 +1,1995 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE project>
-
-  <!-- =================================================================== -->
-  <!--                       Project definition                            -->
-  <!-- =================================================================== -->
-  <project name="Mulgara" default="help" basedir=".">
-
-  <!-- =================================================================== -->
-  <!--                      Property Definitions                           -->
-  <!-- =================================================================== -->
-  <property file="common.properties"/>
-  <property file="build.properties"/>
-
-  <property file="${jar.src.dir}/ant-task/ant-task-build.properties"/>
-  <property file="${jar.src.dir}/client-jrdf/client-jrdf-build.properties"/>
-  <property file="${jar.src.dir}/config/config-build.properties"/>
-  <property file="${jar.src.dir}/demo/demo-build.properties"/>
-  <property file="${jar.src.dir}/demo-mp3/demo-mp3-build.properties"/>
-  <property file="${jar.src.dir}/content-mbox/content-mbox-build.properties"/>
-  <property file="${jar.src.dir}/content-mp3/content-mp3-build.properties"/>
-  <property file="${jar.src.dir}/content-n3/content-n3-build.properties"/>
-  <property file="${jar.src.dir}/content-rdfxml/content-rdfxml-build.properties"/>
-  <property file="${jar.src.dir}/content-rio/content-rio-build.properties"/>
-  <property file="${jar.src.dir}/descriptor/descriptor-build.properties"/>
-  <property file="${jar.src.dir}/driver/driver-build.properties"/>
-  <property file="${jar.src.dir}/dtd/dtd-build.properties"/>
-  <property file="${jar.src.dir}/itql/itql-build.properties"/>
-  <property file="${jar.src.dir}/jrdf/jrdf-build.properties"/>
-  <property file="${jar.src.dir}/query/query-build.properties"/>
-  <!--property file="${jar.src.dir}/rdql/rdql-build.properties"/-->
-  <property file="${jar.src.dir}/resolver/resolver-build.properties"/>
-  <property file="${jar.src.dir}/resolver-null/resolver-null-build.properties"/>
-  <property file="${jar.src.dir}/resolver-file/resolver-file-build.properties"/>
-  <property file="${jar.src.dir}/resolver-filesystem/resolver-filesystem-build.properties"/>
-  <property file="${jar.src.dir}/resolver-gis/resolver-gis-build.properties"/>
-  <property file="${jar.src.dir}/resolver-http/resolver-http-build.properties"/>
-  <property file="${jar.src.dir}/resolver-jar/resolver-jar-build.properties"/>
-  <property file="${jar.src.dir}/resolver-lucene/resolver-lucene-build.properties"/>
-  <property file="${jar.src.dir}/resolver-memory/resolver-memory-build.properties"/>
-  <property file="${jar.src.dir}/resolver-spi/resolver-spi-build.properties"/>
-  <property file="${jar.src.dir}/resolver-store/resolver-store-build.properties"/>
-  <property file="${jar.src.dir}/resolver-url/resolver-url-build.properties"/>
-  <property file="${jar.src.dir}/resolver-view/resolver-view-build.properties"/>
-  <property file="${jar.src.dir}/resolver-xsd/resolver-xsd-build.properties"/>
-  <property file="${jar.src.dir}/resolver-test/resolver-test-build.properties"/>
-  <property file="${jar.src.dir}/resolver-nodetype/resolver-nodetype-build.properties"/>
-  <property file="${jar.src.dir}/resolver-prefix/resolver-prefix-build.properties"/>
-  <property file="${jar.src.dir}/resolver-relational/resolver-relational-build.properties"/>
-  <property file="${jar.src.dir}/resolver-distributed/resolver-distributed-build.properties"/>
-  <property file="${jar.src.dir}/server/server-build.properties"/>
-  <property file="${jar.src.dir}/server-beep/server-beep-build.properties"/>
-  <property file="${jar.src.dir}/server-http/server-http-build.properties"/>
-  <property file="${jar.src.dir}/server-local/server-local-build.properties"/>
-  <property file="${jar.src.dir}/server-rmi/server-rmi-build.properties"/>
-  <property file="${jar.src.dir}/sofa/sofa-build.properties"/>
-  <property file="${jar.src.dir}/krule/krule-build.properties"/>
-  <property file="${jar.src.dir}/rules/rules-build.properties"/>
-  <property file="${jar.src.dir}/sparql-protocol/sparql-protocol-build.properties"/>
-  <property file="${jar.src.dir}/sparql-interpreter/sparql-interpreter-build.properties"/>
-  <property file="${jar.src.dir}/store/store-build.properties"/>
-  <property file="${jar.src.dir}/store-xa/store-xa-build.properties"/>
-  <property file="${jar.src.dir}/store-nodepool/store-nodepool-build.properties"/>
-  <property file="${jar.src.dir}/store-nodepool-memory/store-nodepool-memory-build.properties"/>
-  <property file="${jar.src.dir}/store-nodepool-xa/store-nodepool-xa-build.properties"/>
-  <property file="${jar.src.dir}/store-stringpool/store-stringpool-build.properties"/>
-  <property file="${jar.src.dir}/store-stringpool-memory/store-stringpool-memory-build.properties"/>
-  <property file="${jar.src.dir}/store-stringpool-xa/store-stringpool-xa-build.properties"/>
-  <property file="${jar.src.dir}/tag/tag-build.properties"/>
-  <property file="${jar.src.dir}/tuples-hybrid/tuples-hybrid-build.properties"/>
-  <property file="${jar.src.dir}/tuples/tuples-build.properties"/>
-  <property file="${jar.src.dir}/util-xa/util-xa-build.properties"/>
-  <property file="${jar.src.dir}/util/util-build.properties"/>
-
-  <property name="webui.viewer.src.dir"
-      value="${webui.src.dir}/java/org/mulgara/webui/viewer"/>
-  <property name="webui.viewer.obj.dir.classes"
-      value="${obj.dir}/war/webui/classes/org/mulgara/webui/viewer"/>
-
-  <!-- =================================================================== -->
-  <!--                              Imports                                -->
-  <!-- =================================================================== -->
-  <import file="common.xml"/>
-  <import file="webdocs.xml"/>
-
-  <import file="${jar.src.dir}/ant-task/build.xml"/>
-  <import file="${jar.src.dir}/client-jrdf/build.xml"/>
-  <import file="${jar.src.dir}/demo/build.xml"/>
-  <import file="${jar.src.dir}/demo-mp3/build.xml"/>
-  <import file="${jar.src.dir}/config/build.xml"/>
-  <import file="${jar.src.dir}/content-mbox/build.xml"/>
-  <import file="${jar.src.dir}/content-mp3/build.xml"/>
-  <import file="${jar.src.dir}/content-n3/build.xml"/>
-  <import file="${jar.src.dir}/content-rdfxml/build.xml"/>
-  <import file="${jar.src.dir}/content-rio/build.xml"/>
-  <import file="${jar.src.dir}/descriptor/build.xml"/>
-  <import file="${jar.src.dir}/driver/build.xml"/>
-  <import file="${jar.src.dir}/dtd/build.xml"/>
-  <import file="${jar.src.dir}/itql/build.xml"/>
-  <import file="${jar.src.dir}/jrdf/build.xml"/>
-  <import file="${jar.src.dir}/query/build.xml"/>
-  <!--import file="${jar.src.dir}/rdql/build.xml"/-->
-  <import file="${jar.src.dir}/resolver/build.xml"/>
-  <import file="${jar.src.dir}/resolver-null/build.xml"/>
-  <import file="${jar.src.dir}/resolver-file/build.xml"/>
-  <import file="${jar.src.dir}/resolver-filesystem/build.xml"/>
-  <import file="${jar.src.dir}/resolver-gis/build.xml"/>
-  <import file="${jar.src.dir}/resolver-http/build.xml"/>
-  <import file="${jar.src.dir}/resolver-jar/build.xml"/>
-  <import file="${jar.src.dir}/resolver-lucene/build.xml"/>
-  <import file="${jar.src.dir}/resolver-memory/build.xml"/>
-  <import file="${jar.src.dir}/resolver-nodetype/build.xml"/>
-  <import file="${jar.src.dir}/resolver-prefix/build.xml"/>
-  <import file="${jar.src.dir}/resolver-relational/build.xml"/>
-  <import file="${jar.src.dir}/resolver-distributed/build.xml"/>
-  <import file="${jar.src.dir}/resolver-spi/build.xml"/>
-  <import file="${jar.src.dir}/resolver-store/build.xml"/>
-  <import file="${jar.src.dir}/resolver-url/build.xml"/>
-  <import file="${jar.src.dir}/resolver-view/build.xml"/>
-  <import file="${jar.src.dir}/resolver-xsd/build.xml"/>
-  <import file="${jar.src.dir}/resolver-test/build.xml"/>
-  <import file="${jar.src.dir}/server/build.xml"/>
-  <import file="${jar.src.dir}/server-beep/build.xml"/>
-  <import file="${jar.src.dir}/server-http/build.xml"/>
-  <import file="${jar.src.dir}/server-local/build.xml"/>
-  <import file="${jar.src.dir}/server-rmi/build.xml"/>
-  <import file="${jar.src.dir}/sofa/build.xml"/>
-  <import file="${jar.src.dir}/krule/build.xml"/>
-  <import file="${jar.src.dir}/rules/build.xml"/>
-  <import file="${jar.src.dir}/sparql-protocol/build.xml"/>
-  <import file="${jar.src.dir}/sparql-interpreter/build.xml"/>
-  <import file="${jar.src.dir}/store/build.xml"/>
-  <import file="${jar.src.dir}/store-xa/build.xml"/>
-  <import file="${jar.src.dir}/store-nodepool/build.xml"/>
-  <import file="${jar.src.dir}/store-nodepool-memory/build.xml"/>
-  <import file="${jar.src.dir}/store-nodepool-xa/build.xml"/>
-  <import file="${jar.src.dir}/store-stringpool/build.xml"/>
-  <import file="${jar.src.dir}/store-stringpool-memory/build.xml"/>
-  <import file="${jar.src.dir}/store-stringpool-xa/build.xml"/>
-  <import file="${jar.src.dir}/tag/build.xml"/>
-  <import file="${jar.src.dir}/tuples-hybrid/build.xml"/>
-  <import file="${jar.src.dir}/tuples/build.xml"/>
-  <import file="${jar.src.dir}/util-xa/build.xml"/>
-  <import file="${jar.src.dir}/util/build.xml"/>
-
-  <!-- =================================================================== -->
-  <!--                          Path Definitions                           -->
-  <!-- =================================================================== -->
-  <path id="project-classpath">
-
-    <path refid="common-classpath"/>
-  </path>
-
-  <path id="webui.classpath">
-
-    <pathelement path="${java.class.path}"/>
-    <pathelement path="${obj.dir}/war/webui/classes"/>
-
-    <fileset dir="${lib.dir}" includes="**/**"/>
-    <fileset dir="${dist.dir}" includes="${driver.jar}"/>
-  </path>
-
-  <!-- =================================================================== -->
-  <!--                          Task Definitions                           -->
-  <!-- =================================================================== -->
-
-  <!-- Define the RDFLoad task -->
-  <target name="define.rdfload" unless="define.rdfload" depends="ant-task-jar"
-   description="Defines the rdfload taskdef">
-
-    <taskdef name="rdfload" classname="org.mulgara.ant.task.rdf.RDFLoad">
-
-     <classpath>
-
-       <pathelement path="${dist.dir}/${driver.jar}"/>
-       <pathelement path="${dist.dir}/${ant-task.jar}"/>
-       <pathelement path="${lib.dir}/apache-soap-2.2.jar"/>
-       <pathelement path="${lib.dir}/log4j-1.2.15.jar"/>
-     </classpath>
-    </taskdef>
-
-    <property name="define.rdfload" value="true"/>
-  </target>
-
-  <!-- Define the ITQLCommand task -->
-  <target name="define.itqlcommand" unless="define.itqlcommand" depends="ant-task-jar"
-   description="Defines the itqlcommand taskdef">
-
-    <taskdef name="itqlcommand" classname="org.mulgara.ant.task.itql.ITQLCommand">
-
-     <classpath>
-
-       <pathelement path="${dist.dir}/${driver.jar}"/>
-       <pathelement path="${dist.dir}/${ant-task.jar}"/>
-       <pathelement path="${lib.dir}/apache-soap-2.2.jar"/>
-       <pathelement path="${lib.dir}/log4j-1.2.15.jar"/>
-     </classpath>
-    </taskdef>
-
-    <property name="define.itqlcommand" value="true"/>
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Delete all intermediate and end product files, leaving only files   -->
-  <!-- from CVS.                                                           -->
-  <!-- =================================================================== -->
-  <target name="clean"
-      description="Deletes all intermediate and product files, leaving only sources">
-
-    <tstamp/>
-
-    <delete dir="${obj.dir}"/>
-    <delete dir="${test.dir}"/>
-    <delete dir="${bin.dir}"/>
-    <delete dir="${dist.dir}"/>
-    <delete dir="${tmp.dir}"/>
-    <delete dir="${javadoc.dir}"/>
-    <delete dir="${jxtest.dir}"/>
-    <delete dir="${src.docs.dir}"/>
-    <delete dir="${basedir}/testDatabase"/>
-    <delete dir="${basedir}/sqltest"/>
-    <delete>
-      <fileset dir="${basedir}" includes="*.log*"/>
-    </delete>
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Automated testing target for Anthill, updates source before         -->
-  <!-- running tests                                                       -->
-  <!-- =================================================================== -->
-  <target name="anthill-test"
-          depends="clean, test"
-          description="Runs all tests for Anthill">
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Automated testing target for Anthill, updates source before         -->
-  <!-- running tests                                                       -->
-  <!-- =================================================================== -->
-  <target name="anthill-quick-test"
-          depends="clean, jxunit-test, publish"
-          description="Runs all tests for Anthill">
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Performs a cvs update on the server-side source                     -->
-  <!-- =================================================================== -->
-  <target name="cvs-update" description="perform a CVS update on all source">
-    <cvs cvsRoot="${cvs.root}" package="${cvs.src.package}" command="update"/>
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Run JUnit regression (non-load) tests on dbms.jar                   -->
-  <!-- =================================================================== -->
-  <target name="dbms-test" depends="-prepare-build, uri,
-    driver-jar, itql-jar, query-jar, util-jar, log4j-conf.xml"
-    description="runs regression tests on the triple store">
-
-    <!-- Set timestamp for CruiseControl's benefit -->
-    <tstamp/>
-
-    <delete dir="${junit.results.tmpdir}"/>
-
-    <mkdir dir="${junit.results.tmpdir}"/>
-
-    <delete file="${junit.results}"/>
-
-    <junit fork="yes" haltonfailure="no" printsummary="on"
-      jvm="${java.home}/bin/java" dir="${basedir}">
-
-      <!-- The cvs.root system property allows tests to find CVS'ed test data -->
-      <jvmarg value="${arch.bits}"/>
-      <jvmarg value="-Djava.io.tmpdir=${tmp.dir}"/>
-      <jvmarg value="-Djava.naming.factory.initial=com.sun.jndi.rmi.registry.RegistryContextFactory"/>
-      <jvmarg value="-Djava.naming.provider.url=rmi://localhost"/>
-      <jvmarg value="-Djava.rmi.server.codebase=${bin.uri}/${rmi.jar}"/>
-      <jvmarg value="-Dcvs.root=${basedir}"/>
-      <jvmarg value="-Dlog4j.configuration=${baseuri}/log4j-conf.xml"/>
-
-      <classpath refid="project-classpath"/>
-      <classpath path="${activation.jar}"/>
-      <classpath path="${bin.dir}/${query.jar}"/>
-      <classpath path="${bin.dir}/${driver.jar}"/>
-      <classpath path="${bin.dir}/${itql.jar}"/>
-      <classpath path="${bin.dir}/${rules.jar}"/>
-      <classpath path="${bin.dir}/${server.jar}"/>
-      <classpath path="${bin.dir}/${util.jar}"/>
-
-      <formatter type="xml"/>
-
-      <batchtest todir="${junit.results.tmpdir}">
-
-        <fileset dir="${src.dir}/jar/query/java" includes="**/*Test.java"
-          excludes="**/*LoadTest.java"/>
-        <fileset dir="${src.dir}/jar/driver/java" includes="**/*Test.java"
-          excludes="**/*LoadTest.java"/>
-        <fileset dir="${src.dir}/jar/itql/java" includes="**/*Test.java"
-          excludes="**/*LoadTest.java"/>
-        <fileset dir="${src.dir}/jar/server/java" includes="**/*Test.java"
-          excludes="**/*LoadTest.java"/>
-        <fileset dir="${src.dir}/jar/util/java" includes="**/*Test.java"
-          excludes="**/*LoadTest.java"/>
-      </batchtest>
-    </junit>
-
-    <!-- junitreport does not seem to support props in the tofile attribute -->
-    <!--<junitreport tofile="${junit.results}">-->
-
-    <junitreport tofile="test/All-Tests.xml">
-      <fileset dir="${junit.results.tmpdir}" includes="TEST-*.xml"/>
-    </junitreport>
-  </target>
-
-  <target name="base-dist"
-          depends="ant-task-dist,
-                   client-jrdf-dist, content-mbox-dist,
-                   content-mp3-dist, content-rdfxml-dist, content-rio-dist,
-                   descriptor-dist, driver-dist, dtd-dist, itql-dist, jrdf-dist,
-                   store-dist, store-xa-dist, store-nodepool-dist,
-                   store-nodepool-memory-dist,
-                   store-nodepool-xa-dist, query-dist,
-                   resolver-dist, resolver-null-dist, resolver-file-dist, resolver-filesystem-dist,
-                   resolver-http-dist, resolver-nodetype-dist, resolver-prefix-dist,
-                   resolver-lucene-dist, resolver-memory-dist, resolver-relational-dist,
-                   resolver-spi-dist, resolver-store-dist, resolver-distributed-dist,
-                   resolver-url-dist, resolver-view-dist, resolver-xsd-dist,
-                   resolver-jar-dist, resolver-test-dist,
-                   server-dist, server-beep-dist, server-http-dist, server-local-dist,
-                   server-rmi-dist, sofa-dist, sparql-int-dist, krule-dist, rules-dist,
-                   store-stringpool-dist, store-stringpool-memory-dist,
-                   store-stringpool-xa-dist, tag-dist,
-                   tuples-dist, tuples-hybrid-dist,
-                   util-dist, util-xa-dist"
-          description="Creates the distribution base jars">
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Creates the distribution files                                      -->
-  <!-- =================================================================== -->
-  <!-- Removed server-local, jrdf -->
-  <target name="dist"
-          depends="itql-dist, driver-dist, descriptor-dist, mulgara-war,
-                   embedded-dist, lite-dist"
-          description="Creates the distribution files">
-
-    <copy file="${bin.dir}/${mulgara.war}" tofile="${dist.dir}/${mulgara.war}"/>
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Creates the distribution of documentation files                     -->
-  <!-- =================================================================== -->
-  <target name="dist-website" depends="javadoc, javadoc-dist, webpage-includes"
-    description="Creates the distribution of documentation files">
-
-    <mkdir dir="${dist.docs.dir}"/>
-    <mkdir dir="${dist.api.dir}"/>
-
-    <!-- copy the documentation -->
-    <copy todir="${dist.docs.dir}">
-      <fileset dir="${src.docs.dir}"/>
-    </copy>
-
-    <!-- copy the API -->
-    <copy todir="${dist.api.dir}">
-      <fileset dir="${javadoc.dir}"/>
-    </copy>
-
-
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Creates and copies the core Mulgara files to a single directory      -->
-  <!-- =================================================================== -->
-  <target name="core" depends="dist"
-    description="Creates and then copies the core Mulgara files to a single directory.">
-
-    <!-- webservices.war -->
-    <copy file="${obj.dir}/war/webservices.war" todir="${core.dir}"/>
-
-    <!-- jars for webui war -->
-    <copy file="${obj.dir}/war/webui/jars/${webui-logic.jar}" todir="${core.dir}"/>
-    <copy file="${obj.dir}/war/webui/jars/${webui-barracuda.jar}" todir="${core.dir}"/>
-
-    <!-- driver jar for clients -->
-    <copy file="${dist.dir}/${driver.jar}" todir="${core.dir}"/>
-
-    <!-- ant task jar -->
-    <copy file="${ant-task.dist.dir}/${ant-task.jar}" todir="${core.dir}"/>
-
-    <copy todir="${core.dir}">
-      <fileset dir="${bin.dir}">
-        <include name="*.jar"/>
-      </fileset>
-    </copy>
-
-    <!-- generate the client side java doc -->
-    <antcall target="javadoc"/>
-    <copy todir="${core-javadoc.dir}">
-      <fileset dir="${javadoc.dir}">
-        <include name="*/**"/>
-      </fileset>
-    </copy>
-
-    <!-- jxunit tests -->
-    <mkdir dir="${core.dir}/jxdata/iTQL/"/>
-    <copy todir="${core.dir}/jxdata/iTQL">
-      <fileset dir="${jxdata.dir}/iTQL"/>
-    </copy>
-
-    <!-- resolver example -->
-    <mkdir dir="${core.dir}/example/resolver"/>
-    <copy todir="${core.dir}/example/resolver">
-      <fileset dir="${resolver-http.src.dir}">
-        <include name="**/*.*"/>
-        <exclude name="**/*UnitTest.java"/>
-      </fileset>
-    </copy>
-
-    <!-- content handler example -->
-    <mkdir dir="${core.dir}/example/handler"/>
-    <copy todir="${core.dir}/example/handler">
-      <fileset dir="${content-mp3.src.dir}">
-        <include name="**/*.*"/>
-        <exclude name="**/*UnitTest.java"/>
-      </fileset>
-    </copy>
-
-    <mkdir dir="${core.dir}/example/conf/handler"/>
-    <copy todir="${core.dir}/example/conf/handler">
-      <fileset dir="${content-mp3.conf.dir}" includes="**/parserfactory.conf"/>
-    </copy>
-
-    <move todir="${core.dir}/example/resolver/java">
-      <fileset dir="${core.dir}/example/handler" includes="**/compile-resolver.list"/>
-    </move>
-
-    <move todir="${core.dir}/example/handler/java">
-      <fileset dir="${core.dir}/example/handler" includes="**/compile-handler.list"/>
-    </move>
-
-    <move todir="${core.dir}/example">
-      <fileset dir="${core.dir}/example/handler" includes="**/build-tutorial.*"/>
-    </move>
-
-    <!-- Library jars -->
-    <mkdir dir="${core.dir}/example/lib"/>
-    <copy todir="${core.dir}/example/lib">
-      <fileset dir="${lib.dir}" includes="${jid3.jar}"/>
-    </copy>
-
-    <delete>
-      <fileset dir="${core.dir}/example/handler" includes="*build*.*"/>
-    </delete>
-    <delete>
-      <fileset dir="${core.dir}/example/resolver" includes="*build*.*"/>
-    </delete>
-
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Generates a manifest file for the Mulgara executable project JAR        -->
-  <!-- =================================================================== -->
-  <target name="lite-create-manifest" depends="-prepare-build">
-    <mkdir dir="${obj.dir}/META-INF"/>
-
-    <!-- generate the core manifest -->
-    <manifest file="${obj.dir}/META-INF/MANIFEST_Mulgara_BASE.MF">
-      <attribute name="Main-Class" value="org.mulgara.triplestore.Main"/>
-    </manifest>
-
-    <!-- generate the bootstrap manifest -->
-    <manifest file="${obj.dir}/META-INF/MANIFEST_Mulgara_Lite_BOOTSTRAP.MF">
-
-      <attribute name="Main-Class" value="org.mulgara.util.Bootstrap"/>
-      <attribute name="Embedded-Jar" value="
-          lib/${query.jar}, lib/${driver.jar}, lib/${itql.jar}, lib/${sparql-int.jar},
-          lib/${rmi.jar},
-          lib/${server.jar}, lib/${server-beep.jar}, lib/${server-rmi.jar},
-          lib/${util.jar}, lib/${config.jar}, lib/${descriptor.jar}, lib/${server-local.jar},
-          lib/${resolver.jar}, lib/${resolver-spi.jar}, lib/${resolver-filesystem.jar},
-          lib${store.jar}, lib/${store-xa.jar}, lib/${rules.jar},
-          lib/${store-nodepool.jar}, lib/${store-nodepool-xa.jar},
-          lib/${store-nodepool-memory.jar}, lib/${store-stringpool.jar}
-          lib/${store-stringpool-xa.jar},
-          lib/${store-stringpool-memory.jar}, lib/${util-xa.jar}, lib/${resolver-null.jar}, lib/${resolver-file.jar},
-          lib/${resolver-http.jar}, lib/${resolver-lucene.jar}, lib/${resolver-memory.jar},
-          lib/${resolver-store.jar}, lib/${resolver-url.jar}, lib/${resolver-view.jar},
-          lib/${tuples.jar}, lib/${tuples-hybrid.jar}, lib/${content-mp3.jar},
-          lib/${content-n3.jar}, lib/${content-mbox.jar}, lib/${content-rdfxml.jar},
-          lib/${content-rio.jar}, lib/${resolver-nodetype.jar}, lib/${resolver-prefix.jar},
-          lib/${resolver-relational.jar}, lib/${resolver-xsd.jar}, lib/${resolver-test.jar},
-          lib/${resolver-distributed.jar},
-          lib/${resolver-jar.jar}, lib/${dtd.jar}, lib/${jrdf.base.jar}
-          lib/activation-1.0.2.jar, lib/icu4j.jar, lib/jena-2.1.jar, lib/antlr.jar,
-          lib/${date-utils.jar}, lib/${commons-logging.jar}, lib/beepcore-0.9.08.jar, lib/log4j-1.2.15.jar, lib/${lucene.jar}, lib/mail-1.3.jar,
-          lib/${jetty.jar}, lib/${jetty.plus.jar}, lib/${jasper.compiler.jar}, lib/${servlet.jar}, lib/jargs-0.2.jar,
-          lib/${castor-xml.jar}, lib/${castor-codegen.jar}, lib/${castor-xml-schema.jar}, lib/trove-1.0.2.jar, lib/${jrdf.jar}, lib/${saaj.jar},
-          lib/${jakarta-oro.jar}, lib/jta-spec1_0_1.jar, lib/${jotm.jar}, lib/${jotm.jrmp.jar}, lib/${carol.jar}, lib/${howl.jar},
-          lib/${jca.jar}, lib/${httpclient.jar}, lib/${commons-codec.jar}, lib/${mulgara-sparql.jar}"/>
-      <attribute name="Embedded-Main-Class" value="org.mulgara.server.EmbeddedMulgaraServer"/>
-    </manifest>
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Creates the lite distribution file for the Embedded Mulgara server   -->
-  <!-- =================================================================== -->
-  <target name="lite-dist"
-          depends="driver-jar, itql-jar, sparql-int-jar, rules-jar, query-jar, rmi-jar,
-                   server-jar, server-local-jar, server-beep-jar,
-                   server-rmi-jar, util-jar, config-jar, dtd-jar, jrdf-jar, ant-task-jar,
-                   store-dist, store-xa-dist, store-nodepool-dist,
-                   store-nodepool-xa-dist,
-                   store-nodepool-memory-dist,
-                   store-stringpool-dist,
-                   store-stringpool-xa-dist,
-                   store-stringpool-memory-dist, tuples-dist, tuples-hybrid-dist, resolver-null-dist,
-                   resolver-file-dist, resolver-filesystem-dist, resolver-distributed-dist,
-                   resolver-http-dist, resolver-lucene-dist, resolver-relational-dist,
-                   resolver-memory-dist, resolver-nodetype-dist, resolver-prefix-dist,
-                   resolver-store-dist, resolver-url-dist, resolver-jar-dist,
-                   resolver-view-dist, resolver-xsd-dist,
-                   content-mbox-dist, content-mp3-dist, content-n3-dist,
-                   content-rdfxml-dist, content-rio-dist,
-                   lite-create-manifest, javadoc-dist,
-                   lite-dist-uptodate, webpage-includes"
-          unless="dist.lite.uptodate"
-          description="Creates the executable JAR for the Embedded Mulgara Lite
-                       server">
-
-    <!-- HACK!!!!! -->
-    <!-- This will get the ARP parser working -->
-    <mkdir dir="${obj.dir}/xerces"/>
-
-    <unjar src="${lib.dir}/xercesImpl.jar" dest="${obj.dir}/xerces"/>
-    <unjar src="${lib.dir}/xmlParserAPIs.jar" dest="${obj.dir}/xerces"/>
-    <unjar src="${lib.dir}/jsr173_07_api.jar" dest="${obj.dir}/xerces"/>
-    <unjar src="${lib.dir}/jsr173_07_ri.jar" dest="${obj.dir}/xerces"/>
-    <!-- HACK!!!!! -->
-
-    <!-- build the executable jar file -->
-    <jar jarfile="${dist.dir}/${mulgara-lite.jar}"
-        manifest="${obj.dir}/META-INF/MANIFEST_Mulgara_Lite_BOOTSTRAP.MF">
-
-      <zipfileset dir="${conf.dir}" prefix="conf"
-          includes="log4j-mulgara.xml, webdefault.xml, mulgara-rmi.policy,
-                    mulgara.policy"/>
-      <zipfileset dir="${lib.dir}" prefix="lib" includes="
-        ${log4j.jar}, ${icu4j.jar}, ${activation.jar}, ${beep.jar},
-        ${jargs.jar}, ${jrdf.jar}, ${jetty.jar}, ${jetty.plus.jar},
-        ${servlet.jar}, ${jasper.runtime.jar}, ${jasper.compiler.jar},
-        ${lucene.jar}, ${mail.jar}, ${castor-xml.jar}, ${castor-xml-schema.jar}, ${castor-codegen.jar}, ${trove.jar},
-        ${date-utils.jar}, ${commons-logging.jar}, ${commons-httpclient.jar},
-        ${commons-codec.jar}, ${emory-util.jar}, ${mulgara-sparql.jar}
-        ${jotm.jar}, ${jotm.jrmp.jar}, ${carol.jar}, ${howl.jar}, ${jta.jar},
-        ${jsr.173.api.jar}, ${jsr.173.ri.jar}, ${jca.jar}, ${saaj.jar},
-        ${axis.jar}, ${commons-discovery.jar}, ${jaxrpc.jar}, ${wsdl4j.jar},
-        ${jena.jar}, ${antlr.jar}, ${jakarta-oro.jar}, {jid3.jar}"/>
-      <zipfileset dir="${lib.dir}" prefix="lib" includes="${saaj.jar},
-                       ${axis.jar}, ${commons-discovery.jar},
-                       ${jaxrpc.jar}, ${wsdl4j.jar}"/>
-      <zipfileset dir="${bin.dir}" prefix="lib" includes="
-          ${query.jar}, ${driver.jar}, ${itql.jar}, ${sparql-int.jar},
-          ${rules.jar}, ${rmi.jar},
-          ${server.jar}, ${server-beep.jar}, ${server-rmi.jar},
-          ${util.jar}, ${config.jar}, ${descriptor.jar}, ${server-local.jar},
-          ${resolver.jar}, ${resolver-spi.jar}, ${resolver-filesystem.jar},
-          ${store.jar}, ${store-xa.jar},
-          ${store-nodepool.jar}, ${store-nodepool-xa.jar}, ${store-stringpool.jar},
-          ${store-stringpool-xa.jar}, ${store-nodepool-memory.jar}, ${resolver-null.jar},
-          ${store-stringpool-memory.jar}, ${util-xa.jar}, ${resolver-file.jar},
-          ${resolver-http.jar}, ${resolver-lucene.jar}, ${resolver-memory.jar},
-          ${resolver-store.jar}, ${resolver-url.jar}, ${resolver-view.jar},
-          ${tuples.jar}, ${tuples-hybrid.jar}, ${content-mp3.jar},
-          ${content-n3.jar}, ${content-mbox.jar}, ${content-rdfxml.jar},
-          ${content-rio.jar}, ${resolver-nodetype.jar}, ${resolver-prefix.jar},
-          ${resolver-xsd.jar}, ${resolver-test.jar}, ${resolver-relational.jar},
-          ${resolver-distributed.jar},
-          ${resolver-jar.jar}, ${dtd.jar}, ${jrdf.base.jar}"/>
-
-      <!-- Schemas -->
-      <zipfileset dir="${basedir}/data" prefix="data"
-          includes="mulgara.rdfs"/>
-
-      <zipfileset dir="${src.docs.dir}" prefix="docs"
-          includes="**/*.html, **/*.htm, **/*.gif, **/*.png, **/*.jpg, **/*.css, **/images/*, **/images/icons/*"/>
-      <zipfileset file="${obj.dir}/mulgara-x-config.xml" prefix="conf" />
-
-      <fileset dir="${obj.dir}/jar/util/classes" includes="**/Bootstrap.class"/>
-      <fileset dir="${src.dir}/jar/dtd" includes="META-INF/**, DTD/**"/>
-
-      <!-- HACK!!!!! -->
-      <!-- This will get the ARP parser working -->
-      <!-- Ignore the xerces DocumentBuilderFactory -->
-      <fileset dir="${obj.dir}/xerces" excludes="META_INF/**"/>
-
-      <!-- HACK!!!!! -->
-
-    </jar>
-
-  </target>
-
-  <!-- do a check for any changes made to the mulgara build -->
-  <!-- potentially not the most efficient checking performed -->
-  <target name="lite-dist-uptodate">
-
-    <uptodate property="dist.lite.uptodate"
-       targetfile="${dist.dir}/${mulgara-lite.jar}">
-
-     <srcfiles dir="${bin.dir}" includes="**/*"/>
-     <srcfiles dir="${conf.dir}" includes="**/*"/>
-     <srcfiles dir="${lib.dir}" includes="**/*"/>
-     <srcfiles dir="${data.dir}" includes="**/*"/>
-     <srcfiles dir="${template.src.docs.dir}" includes="**/*"/>
-    </uptodate>
-  </target>
-
-
-  <!-- =================================================================== -->
-  <!-- Generate the doclet to support custom @-tags in Mulgara javadoc      -->
-  <!-- =================================================================== -->
-  <target name="doclet.jar"
-          depends="javadoc-version, doclet-compile, doclet141-compile">
-
-    <mkdir dir="${bin.dir}"/>
-
-    <jar jarfile="${bin.dir}/doclet.jar">
-      <fileset dir="${obj.dir}/jar/doclet/classes"/>
-    </jar>
-  </target>
-
-  <target name="javadoc-version">
-
-    <condition property="javadoc1.4.1">
-      <contains string="${java.version}" substring="1.4.1"/>
-    </condition>
-  </target>
-
-  <target name="doclet-compile" unless="javadoc1.4.1">
-
-    <mkdir dir="${obj.dir}/jar/doclet/classes"/>
-
-    <javac destdir="${obj.dir}/jar/doclet/classes"
-           classpath="${java.class.path}"
-           debug="on" deprecation="on">
-      <src path="${src.dir}/jar/doclet/java"/>
-    </javac>
-  </target>
-
-  <target name="doclet141-compile" if="javadoc1.4.1">
-
-    <mkdir dir="${obj.dir}/jar/doclet/classes"/>
-
-    <javac destdir="${obj.dir}/jar/doclet/classes"
-           classpath="${java.class.path}"
-           debug="on" deprecation="on">
-      <src path="${src.dir}/jar/doclet141/java"/>
-    </javac>
-  </target>
-
-
-  <!-- =================================================================== -->
-  <!-- Translate XHTML+MathML into printable XHTML                         -->
-  <!-- =================================================================== -->
-  <target name="docs" depends="javadoc-dist,webpage-includes" description="Generate documentation">
-
-    <style basedir="${src.docs.dir}"
-           destdir="${src.docs.dir}"
-           extension="-toc.xml"
-           style="toc.xsl"
-           includes="model.xml"
-           excludes="*-toc.xml"/>
-    <!--
-    <style basedir="${src.docs.dir}"
-           destdir="${src.docs.dir}"
-           style="mathml.xsl"
-           includes="*.xml"/>
-    -->
-  </target>
-
-  <!-- ==================================================================== -->
-  <!-- Formats all source files                                             -->
-  <!-- ==================================================================== -->
-  <target name="format" depends="jalopy">
-
-    <!--
-      Invokes Jalopy as follows:
-
-      - All formatted files will have unix fileformat (\n)
-      - Load your code convention from the given url
-      - Override the convention to use the file history feature
-      - Override the convention to use alder32 checksums of files for history testing
-      - Override the convention to use loglevel "info"
-      - Override the convention to use 2 threads
-      - The import optimization feature will work (if enabled in the active
-        convention), because a classpath reference is specified
-
-        Don't forget to setup an include pattern as Jalopy truly expects
-        valid Java source files as input!
-      -->
-    <jalopy fileformat="unix"
-            convention="${src.dir}/mulgara.xml"
-            history="file"
-            historymethod="adler32"
-            loglevel="info"
-            threads="2"
-            classpathref="project-classpath">
-
-      <fileset dir="${src.dir}">
-        <include name="**/*.java" />
-      </fileset>
-    </jalopy>
-  </target>
-
-  <!-- ================================================================== -->
-  <!-- Prints help information                                            -->
-  <!-- ================================================================== -->
-  <target name="help" description="Print this help message">
-    <echo message="Welcome to the build script for the ${description}"/>
-    <echo message="These targets can be invoked as follows:"/>
-    <echo message="  ./build.sh &lt;target&gt;"/>
-    <echo message=""/>
-    <java fork="false" classname="org.apache.tools.ant.Main"
-          newenvironment="false">
-      <jvmarg value="${arch.bits}"/>
-      <arg line="-buildfile build.xml -projecthelp"/>
-    </java>
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Generates all javadoc for the project                               -->
-  <!-- =================================================================== -->
-  <target name="javadoc"
-    depends="javadoc-uptodate, javadoc-overview.html,
-             ant-task-jar, client-jrdf-jar, config-jar,
-             content-mbox-jar, content-mp3-jar,
-             content-n3-jar, content-rdfxml-jar, content-rio-jar,
-             itql-jar, sparql-int-jar,
-             doclet.jar, jrdf-jar, store-jar,
-             store-xa-jar,
-             store-nodepool-jar, store-nodepool-memory-jar,
-             store-nodepool-xa-jar, query-jar,
-             resolver-jar, resolver-null-jar, resolver-file-jar, resolver-filesystem-jar,
-             resolver-http-jar, resolver-lucene-jar, resolver-memory-jar,
-             resolver-spi-jar, resolver-store-jar,
-             resolver-url-jar, resolver-view-jar, resolver-xsd-jar,
-             resolver-test-jar,
-             server-jar, server-beep-jar, server-rmi-jar,
-             sofa-jar, krule-jar, rules-jar, sparql-protocol-jar,
-             store-stringpool-jar,
-             store-stringpool-memory-jar, store-stringpool-xa-jar,
-             tuples-jar, tuples-hybrid-jar, util-jar, util-xa-jar, webui-war"
-    unless="javadoc-uptodate"
-    description="Creates the project javadoc">
-    <delete dir="${javadoc.dir}"/>
-    <mkdir dir="${javadoc.dir}"/>
-    <javadoc destdir="${javadoc.dir}"
-        packagenames="org.mulgara.ant.*,
-                      org.mulgara.barracuda.*,
-                      org.mulgara.beep.*,
-                      org.mulgara.client.*,
-                      org.mulgara.config,
-                      org.mulgara.content.*,
-                      org.mulgara.connection.*,
-                      org.mulgara.driver.*,
-                      org.mulgara.extractor.tag,
-                      org.mulgara.itql,
-                      org.mulgara.jrdf,
-                      org.mulgara.local.*,
-                      org.mulgara.query.*,
-                      org.mulgara.rdf,
-                      org.mulgara.resolver.*,
-                      org.mulgara.rmi.*,
-                      org.mulgara.server.*,
-                      org.mulgara.sofa.*,
-                      org.mulgara.krule.*,
-                      org.mulgara.rules.*,
-                      org.mulgara.sparql.*,
-                      org.mulgara.store.*,
-                      org.mulgara.store.graph.*,
-                      org.mulgara.store.graph.xa.*,
-                      org.mulgara.store.jxunit.*,
-                      org.mulgara.store.loader.*,
-                      org.mulgara.store.nodepool.*,
-                      org.mulgara.store.nodepool.memory.*,
-                      org.mulgara.store.nodepool.xa.*,
-                      org.mulgara.store.stringpool.*,
-                      org.mulgara.store.stringpool.memory.*,
-                      org.mulgara.store.stringpool.xa.*,
-                      org.mulgara.store.tuples.*,
-                      org.mulgara.store.xa.*,
-                      org.mulgara.webui.*,
-                      org.mulgara.util,
-                      org.mulgara.xml.*"
-        private="true"
-        overview="${obj.dir}/docs/overview.html"
-        windowtitle="${description} ${mulgara-version} API"
-        doctitle="${description} ${mulgara-version} API"
-        version="true"
-        use="true"
-        bottom="Copyright &amp;copy; ${year} Tucana Technologies, Inc. (http://www.tucanatech.com/)."
-        author="true"
-        additionalParam="-breakiterator -source 1.5">
-      <tag name="company" description="Company:"/>
-      <tag name="copyright" description="Copyright:"/>
-      <tag name="created" description="Creation date:"/>
-      <tag name="licence" description="Licence:"/>
-      <taglet name="org.mulgara.doclet.MaintenanceAuthorTaglet"
-        path="${bin.dir}/doclet.jar"/>
-      <taglet name="org.mulgara.doclet.ModifiedTaglet"
-        path="${bin.dir}/doclet.jar"/>
-      <taglet name="org.mulgara.doclet.VersionTaglet"
-        path="${bin.dir}/doclet.jar"/>
-      <classpath refid="project-classpath"/>
-      <classpath path="${lib.dir}/antlr.jar"/>
-      <classpath path="${lib.dir}/barracuda-1.2.6.jar"/>
-      <classpath path="${lib.dir}/beepcore-0.9.08.jar"/>
-      <classpath path="${lib.dir}/javax.servlet-2.3.jar"/>
-      <classpath path="${lib.dir}/${jid3.jar}"/>
-      <classpath path="${lib.dir}/jsr173_07_api.jar"/>
-      <classpath path="${lib.dir}/${lucene.jar}"/>
-      <classpath path="${lib.dir}/${sofa.jar}"/>
-      <classpath path="${lib.dir}/xmlc-all-runtime-2.2.jar"/>
-      <classpath path="${lib.dir}/xom-1.0d21.jar"/>
-      <sourcepath path="${ant-task.src.dir}/java"/>
-      <sourcepath path="${client-jrdf.src.dir}/java"/>
-      <sourcepath path="${content-mp3.src.dir}/java"/>
-      <sourcepath path="${content-n3.src.dir}/java"/>
-      <sourcepath path="${content-rdfxml.src.dir}/java"/>
-      <sourcepath path="${content-rio.src.dir}/java"/>
-      <sourcepath path="${driver.src.dir}/java"/>
-      <sourcepath path="${dtd.src.dir}/java"/>
-      <sourcepath path="${itql.src.dir}/java"/>
-      <sourcepath path="${jrdf.src.dir}/java"/>
-      <sourcepath path="${krule.src.dir}/java"/>
-      <sourcepath path="${rules.src.dir}/java"/>
-      <sourcepath path="${query.src.dir}/java"/>
-      <!--sourcepath path="${rdql.src.dir}/java"/-->
-      <sourcepath path="${resolver.src.dir}/java"/>
-      <sourcepath path="${resolver-null.src.dir}/java"/>
-      <sourcepath path="${resolver-file.src.dir}/java"/>
-      <sourcepath path="${resolver-filesystem.src.dir}/java"/>
-      <sourcepath path="${resolver-jar.src.dir}/java"/>
-      <sourcepath path="${resolver-http.src.dir}/java"/>
-      <sourcepath path="${resolver-lucene.src.dir}/java"/>
-      <sourcepath path="${resolver-url.src.dir}/java"/>
-      <sourcepath path="${resolver-memory.src.dir}/java"/>
-      <sourcepath path="${resolver-spi.src.dir}/java"/>
-      <sourcepath path="${resolver-store.src.dir}/java"/>
-      <sourcepath path="${resolver-view.src.dir}/java"/>
-      <sourcepath path="${resolver-xsd.src.dir}/java"/>
-      <sourcepath path="${resolver-test.src.dir}/java"/>
-      <sourcepath path="${server.src.dir}/java"/>
-      <sourcepath path="${server-beep.src.dir}/java"/>
-      <sourcepath path="${server-rmi.src.dir}/java"/>
-      <sourcepath path="${sofa.src.dir}/java"/>
-      <sourcepath path="${sparql-protocol.src.dir}/java"/>
-      <sourcepath path="${sparql-int.src.dir}/java"/>
-      <sourcepath path="${store.src.dir}/java"/>
-      <sourcepath path="${store-xa.src.dir}/java"/>
-      <sourcepath path="${store-nodepool.src.dir}/java"/>
-      <sourcepath path="${store-nodepool-memory.src.dir}/java"/>
-      <sourcepath path="${store-nodepool-xa.src.dir}/java"/>
-      <sourcepath path="${store-stringpool.src.dir}/java"/>
-      <sourcepath path="${store-stringpool-memory.src.dir}/java"/>
-      <sourcepath path="${store-stringpool-xa.src.dir}/java"/>
-      <sourcepath path="${tuples.src.dir}/java"/>
-      <sourcepath path="${tuples-hybrid.src.dir}/java"/>
-      <sourcepath path="${util.src.dir}/java"/>
-      <sourcepath path="${util-xa.src.dir}/java"/>
-      <sourcepath path="${webui.src.dir}/java"/>
-      <sourcepath path="${obj.dir}/jar/config/java"/>
-      <sourcepath path="${obj.dir}/jar/itql/java"/>
-      <sourcepath path="${obj.dir}/jar/query/java"/>
-      <!--sourcepath path="${obj.dir}/jar/rdql/java"/-->
-      <sourcepath path="${obj.dir}/jar/util/java"/>
-      <sourcepath path="${obj.dir}/war/webui/java"/>
-      <link href="${j2ee.javadoc}"/>
-      <link href="${java.javadoc}"/>
-      <link href="${jrdf.javadoc}"/>
-    </javadoc>
-  </target>
-
-  <target name="javadoc-dist"
-          if="distjavadoc">
-
-    <antcall target="create-javadoc"/>
-  </target>
-
-  <!-- If and depends are not compatible so we have to approach javadoc in
-       two steps -->
-  <target name="create-javadoc"
-          depends="javadoc-uptodate, javadoc-overview.html, doclet.jar,
-                   ant-task-javadoc,
-                   client-jrdf-javadoc,
-                   content-mbox-javadoc,
-                   content-mp3-javadoc, content-n3-javadoc,
-                   content-rdfxml-javadoc, content-rio-javadoc,
-                   descriptor-javadoc, driver-javadoc, dtd-javadoc,
-                   itql-javadoc, sparql-int-javadoc,
-                   store-javadoc, store-xa-javadoc,
-                   store-nodepool-javadoc,
-                   store-nodepool-memory-javadoc, jrdf-javadoc,
-                   store-nodepool-xa-javadoc, query-javadoc,
-                   resolver-filesystem-javadoc, resolver-null-javadoc,
-                   resolver-file-javadoc, resolver-http-javadoc,
-                   resolver-lucene-javadoc, resolver-memory-javadoc,
-                   resolver-spi-javadoc, resolver-distributed-javadoc,
-                   resolver-store-javadoc, resolver-url-javadoc, resolver-view-javadoc,
-                   resolver-nodetype-javadoc, resolver-prefix-javadoc, resolver-xsd-javadoc,
-                   resolver-test-javadoc, resolver-javadoc, resolver-relational-javadoc,
-                   server-beep-javadoc, server-http-javadoc,
-                   server-local-javadoc, server-rmi-javadoc, server-javadoc,
-                   sofa-javadoc, rules-javadoc, krule-javadoc,
-                   store-stringpool-javadoc,
-                   store-stringpool-memory-javadoc, store-stringpool-xa-javadoc,
-                   tag-javadoc, tuples-hybrid-javadoc, tuples-javadoc,
-                   util-xa-javadoc, util-javadoc"
-      unless="javadoc.uptodate"
-      description="creates project javadoc documentation">
-  </target>
-
-  <target name="javadoc-overview.html">
-
-    <style in    ="build.xml"
-           style ="docs/overview.xsl"
-           out   ="${obj.dir}/docs/overview.html"/>
-  </target>
-
-  <target name="javadoc-uptodate">
-
-    <uptodate property="javadoc.uptodate"
-        targetfile="${javadoc.dir}/package-list">
-
-      <srcfiles dir="${src.dir}" includes="**/*.java, **/package.html"/>
-      <srcfiles dir="docs" includes="overview.xsl"/>
-    </uptodate>
-  </target>
-
-  <target name="jrdf-example" description="Runs the JRDF memory example">
-
-     <java classname="org.jrdf.graph.mem.JRDFExample" fork="no" failonerror="yes"
-        jvm="${java.home}/bin/java" dir="${basedir}">
-
-        <jvmarg value="${arch.bits}"/>
-
-        <classpath>
-            <pathelement path="${lib.dir}/${jrdf.jar}"/>
-        </classpath>
-      </java>
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Create config file for Log4J for each developer                     -->
-  <!-- =================================================================== -->
-  <target name="log4j-conf.xml">
-
-    <copy file="${conf.dir}/log4j-template.xml"
-      tofile="${basedir}/log4j-conf.xml"/>
-  </target>
-
-  <target name="model.html">
-
-    <style basedir="${template.src.docs.dir}"
-           destdir="${template.src.docs.dir}"
-           style="mathml.xsl"
-           includes="model.xml"/>
-  </target>
-
-
-  <!-- =================================================================== -->
-  <!-- Create JAR for use as the RMI codebase                              -->
-  <!-- =================================================================== -->
-  <target name="rmi-jar"
-          depends="query-jar, driver-jar, server-jar, util-jar,
-                   rmi-jar-uptodate"
-          unless="rmi.jar.uptodate">
-
-    <jar jarfile="${bin.dir}/${rmi.jar}">
-
-      <fileset dir="${obj.dir}/jar/query/classes"/>
-      <fileset dir="${obj.dir}/jar/driver/classes"/>
-      <fileset dir="${obj.dir}/jar/server/classes"/>
-      <fileset dir="${obj.dir}/jar/util/classes"/>
-    </jar>
-  </target>
-
-  <target name="rmi-jar-uptodate">
-
-    <uptodate property="rmi.jar.uptodate"
-              targetfile="${bin.dir}/${rmi.jar}">
-
-      <srcfiles dir="${obj.dir}/jar/query/classes" includes="**/*"/>
-      <srcfiles dir="${obj.dir}/jar/driver/classes" includes="**/*"/>
-      <srcfiles dir="${obj.dir}/jar/server/classes" includes="**/*"/>
-      <srcfiles dir="${obj.dir}/jar/util/classes" includes="**/*"/>
-    </uptodate>
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Starts the iTQL command line tool                                   -->
-  <!-- =================================================================== -->
-  <target name="run-itql" depends="itql-dist, uri">
-
-    <java classname="org.mulgara.itql.ItqlSession"
-          failonerror="yes">
-
-      <jvmarg value="${arch.bits}"/>
-
-      <sysproperty key="java.io.tmpdir" value="${tmp.dir}"/>
-      <sysproperty key="log4j.configuration"
-                   value="${baseuri}/conf/log4j-tql.xml"/>
-
-      <classpath>
-
-        <pathelement path="${bin.dir}/${query.jar}"/>
-        <pathelement path="${bin.dir}/${driver.jar}"/>
-        <pathelement path="${bin.dir}/${itql.jar}"/>
-        <pathelement path="${bin.dir}/${rules.jar}"/>
-        <pathelement path="${bin.dir}/${server.jar}"/>
-        <pathelement path="${bin.dir}/${server-http.jar}"/>
-        <pathelement path="${bin.dir}/${server-local.jar}"/>
-        <pathelement path="${bin.dir}/${server-rmi.jar}"/>
-        <pathelement path="${bin.dir}/${server-beep.jar}"/>
-        <pathelement path="${bin.dir}/${util.jar}"/>
-
-        <fileset dir="${lib.dir}"
-                 includes="activation*.jar, beepcore-*.jar, jargs-*.jar,
-                           icu4j.jar, jena*.jar, antlr*.jar,
-                           ${commons-logging.jar}, log4j*.jar, lucene*.jar,
-                           xerces*.jar, xmlParserAPIs.jar, ${jrdf.jar},
-                           ${saaj.jar}"/>
-      </classpath>
-    </java>
-
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Starts multiple embedded Mulgara servers                             -->
-  <!-- =================================================================== -->
-  <target name="start-instance"
-     description="Starts an embedded Mulgara server">
-
-    <echo>
-      Starting embedded Mulgara ${server.instance} server on ${os.name} with
-      output to ${dist.dir}/mulgara-output-${server.instance}
-    </echo>
-
-    <!-- create a temporary directory for this server instance -->
-    <mkdir dir="${tmp.dir}/${server.instance}"/>
-
-    <!-- prepare a log4j file for server instance -->
-    <copy file="${conf.dir}/log4j-instance.xml"
-      tofile="${dist.dir}/log4j-instance-${server.instance}.xml"/>
-
-    <replace file="${dist.dir}/log4j-instance-${server.instance}.xml"
-       token="@server.instance@" value="${server.instance}"/>
-
-    <exec os="Linux" executable="${scripts.dir}/bg.linux" failonerror="yes">
-
-      <arg value="-o"/>
-      <arg value="${dist.dir}/mulgara-output-${server.instance}"/>
-      <arg value="${java.home}/bin/java"/>
-      <arg line="-Djava.io.tmpdir=&quot;${tmp.dir}/${server.instance}&quot;"/>
-      <arg line="-Dshutdownhook.port=689${server.instance}"/>
-      <arg value="-jar"/>
-      <arg value="${dist.dir}/${mulgara.version.to.run}"/>
-      <arg value="-a"/>
-      <arg value="${test.dir}"/>
-      <arg value="-s"/>
-      <arg value="server${server.instance}"/>
-      <arg value="-p"/>
-      <arg value="808${server.instance}"/>
-      <arg value="-l"/>
-      <arg value="file:${dist.dir}/log4j-instance-${server.instance}.xml"/>
-    </exec>
-
-    <exec os="SunOS" executable="${scripts.dir}/bg.sh" failonerror="yes">
-
-      <arg value="-o"/>
-      <arg value="${dist.dir}/mulgara-output-${server.instance}"/>
-      <arg value="${java.home}/bin/java"/>
-      <arg value="${arch.bits}"/>
-      <arg line="-Djava.io.tmpdir=&quot;${tmp.dir}/${server.instance}&quot;"/>
-      <arg line="-Dshutdownhook.port=689${server.instance}"/>
-      <arg value="-jar"/>
-      <arg value="${dist.dir}/${mulgara.version.to.run}"/>
-      <arg value="-a"/>
-      <arg value="${test.dir}"/>
-      <arg value="-s"/>
-      <arg value="server${server.instance}"/>
-      <arg value="-p"/>
-      <arg value="808${server.instance}"/>
-      <arg value="-l"/>
-      <arg value="file:${dist.dir}/log4j-instance-${server.instance}.xml"/>
-    </exec>
-
-    <exec os="Mac OS X" executable="${scripts.dir}/bg.sh" failonerror="yes">
-
-      <arg value="-o"/>
-      <arg value="${dist.dir}/mulgara-output-${server.instance}"/>
-      <arg value="${java.home}/bin/java"/>
-      <arg line="-Djava.io.tmpdir=&quot;${tmp.dir}/${server.instance}&quot;"/>
-      <arg line="-Dshutdownhook.port=689${server.instance}"/>
-      <arg value="-jar"/>
-      <arg value="${dist.dir}/${mulgara.version.to.run}"/>
-      <arg value="-a"/>
-      <arg value="${test.dir}"/>
-      <arg value="-s"/>
-      <arg value="server${server.instance}"/>
-      <arg value="-p"/>
-      <arg value="808${server.instance}"/>
-      <arg value="-l"/>
-      <arg value="file:${dist.dir}/log4j-instance-${server.instance}.xml"/>
-    </exec>
-
-    <exec os="Windows NT,Windows 2000,Windows XP, Windows 2003" executable="${scripts.dir}\bg.exe"
-        failonerror="yes">
-
-      <arg value="-o"/>
-      <arg value="${dist.dir}/mulgara-output-${server.instance}"/>
-      <arg value="${java.home}/bin/java"/>
-      <arg line="-Djava.io.tmpdir=&quot;${tmp.dir}/${server.instance}&quot;"/>
-      <arg line="-Dshutdownhook.port=689${server.instance}"/>
-      <arg value="-jar"/>
-      <arg value="${dist.dir}/${mulgara.version.to.run}"/>
-      <arg value="-a"/>
-      <arg value="${test.dir}"/>
-      <arg value="-s"/>
-      <arg value="server${server.instance}"/>
-      <arg value="-p"/>
-      <arg value="808${server.instance}"/>
-      <arg value="-l"/>
-      <arg value="&quot;file:/${dist.dir}/log4j-instance-${server.instance}.xml&quot;"/>
-    </exec>
-
-    <!-- wait for the server to start -->
-    <antcall target="await">
-      <param name="shutdownhook.port" value="689${server.instance}"/>
-    </antcall>
-  </target>
-
-
-  <!-- Run full dist of Mulgara by default unless other (lite) is set -->
-  <target name="set-version-to-run" unless="mulgara.version.to.run.jar">
-
-    <property name="mulgara.version.to.run" value="${mulgara.jar}"/>
-  </target>
-
-
-  <!-- =================================================================== -->
-  <!-- Starts an embedded Mulgara server with profiling (from OptimizeIt)      -->
-  <!-- =================================================================== -->
-  <target name="start-profiled" depends="dist"
-      description="Starts an embedded Mulgara server with profiling (from OptimizeIt)">
-
-    <echo>
-      Starting embedded Mulgara server with profiling (from OptimizeIt) with output to
-      ${dist.dir}/mulgara-output
-    </echo>
-
-    <exec executable="${mulgara-profiled}" failonerror="yes">
-
-      <env key="Mulgara_DIR" path="${dist.dir}"/>
-
-      <arg value="start"/>
-    </exec>
-
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Starts two embedded Mulgara servers                                     -->
-  <!-- =================================================================== -->
-  <target name="start-twoservers"
-      depends="dist, lite-dist, set-version-to-run"
-      description="Starts two embedded Mulgara servers">
-
-    <echo>
-      Starting two embedded Mulgara servers with output to
-      ${dist.dir}/mulgara-output
-    </echo>
-
-    <antcall target="start-instance">
-      <param name="server.instance" value="1"/>
-    </antcall>
-
-    <antcall target="start-instance">
-      <param name="server.instance" value="2"/>
-    </antcall>
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Add the required JARs into the Web Services war file                -->
-  <!-- =================================================================== -->
-  <target name="webservices-war"
-          depends="descriptor-jar, descriptor-add-to-war-dir,
-                   webservices-war-uptodate"
-          unless="webservices.war.uptodate"
-          description="Adds the required jars into the webservices.war file">
-
-    <mkdir dir="${obj.dir}/war/web-services"/>
-
-    <copy todir="${obj.dir}/war/web-services/WEB-INF">
-      <fileset dir="${webservices.src.dir}/WEB-INF" includes="*"/>
-    </copy>
-
-    <replace file="${obj.dir}/war/web-services/WEB-INF/web.xml"
-       token="@@hostname@@" value="${host.name}"/>
-
-    <war warfile="${obj.dir}/war/webservices.war"
-         basedir="${obj.dir}/war/web-services"
-         webxml="${obj.dir}/war/web-services/WEB-INF/web.xml"
-         excludes="WEB-INF/web.xml">
-
-        <!-- AXIS WSDD FILE -->
-        <webinf dir="${webservices.src.dir}/WEB-INF/" includes="server-config.wsdd"/>
-
-        <!-- descriptors -->
-
-        <!-- pre compiled jsps -->
-        <classes dir="${descriptor.war.obj.dir}/classes"
-          includes="**/*.class"/>
-
-        <fileset dir="${obj.dir}/war/"
-          includes="descriptor/descriptors/**/*.xsl"/>
-        <fileset dir="${src.dir}/war/"
-          includes="descriptor/**/*.html, descriptor/**/*.css, descriptor/**/*.jsp"/>
-        <fileset dir="${src.dir}/war/"
-          includes="descriptor/images/**"/>
-        <fileset dir="${src.dir}/war/"
-          includes="descriptor/tutorial/**"/>
-        <fileset dir="${src.dir}/war/"
-          includes="descriptor/examples/**"/>
-        <fileset dir="${src.dir}/war/"
-          includes="descriptor/examples/vcard/**"/>
-
-        <!-- 3rd party -->
-        <lib dir="${lib.dir}" includes="bsf.jar"/>
-        <lib dir="${lib.dir}" includes="js.jar"/>
-
-      </war>
-   </target>
-
-  <!-- =================================================================== -->
-  <!-- Check if the webservices.war file is uptodate                       -->
-  <!-- =================================================================== -->
-   <target name="webservices-war-uptodate">
-
-    <uptodate property="webservices.war.uptodate"
-        targetfile="${obj.dir}/war/webservices.war">
-      <srcfiles dir="${obj.dir}/war/web-services" includes="**/*"/>
-    </uptodate>
-   </target>
-
-  <!-- =================================================================== -->
-  <!-- Stops an embedded Mulgara instance                                   -->
-  <!-- =================================================================== -->
-  <target name="stop-instance" depends="set-version-to-run" description="Stops an embedded Mulgara server">
-
-    <echo message="Stopping embedded Mulgara server instance ${server.instance}"/>
-
-    <java jar="${dist.dir}/${mulgara.version.to.run}" fork="true" failonerror="true">
-
-      <sysproperty key="java.io.tmpdir" value="${tmp.dir}"/>
-      <sysproperty key="shutdownhook.port" value="689${server.instance}"/>
-
-      <jvmarg value="${arch.bits}"/>
-
-      <arg value="-x"/>
-    </java>
-
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Stops two embedded Mulgara servers                                      -->
-  <!-- =================================================================== -->
-  <target name="stop-twoservers" description="Stops the two embedded Mulgara servers">
-
-    <!-- shutdown servers in reverse order. First has the RMI registry -->
-    <echo message="Stopping Mulgara instance servers"/>
-
-    <antcall target="stop-instance">
-      <param name="server.instance" value="2"/>
-    </antcall>
-
-    <antcall target="stop-instance">
-      <param name="server.instance" value="1"/>
-    </antcall>
-
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Unpack, filter and preen test data                                  -->
-  <!-- =================================================================== -->
-  <target name="test-data">
-
-    <filter token="basedir" value="${basedir}"/>
-
-    <copy todir="${test.dir}" filtering="yes">
-      <fileset dir="data" includes="*.itql"/>
-    </copy>
-
-    <mkdir dir="${test.dir}/RDF-Test-Cases"/>
-
-    <unzip src="data/RDF-Test-Cases-2001-09-12.zip" dest="${test.dir}/RDF-Test-Cases"/>
-
-    <mkdir dir="${test.dir}/RDQL"/>
-
-    <unzip src="data/rdql-tests-jena-2.0.zip" dest="${test.dir}/RDQL"/>
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Stress test - performs itql query stress tests                      -->
-  <!-- =================================================================== -->
-
-  <target name="stress-test"
-          depends="itql-jar, uri"
-          description="run stress tests the ItqlInterpreterBean">
-
-    <java classname="org.mulgara.itql.ItqlInterpreterStressTest" fork="yes" failonerror="no"
-      jvm="${java.home}/bin/java" dir="${basedir}">
-
-      <jvmarg value="${arch.bits}"/>
-
-      <sysproperty key="java.io.tmpdir" value="${tmp.dir}"/>
-      <sysproperty key="org.mulgara.xml.ResourceDocumentBuilderFactory"
-        value="org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"/>
-      <sysproperty key="java.naming.factory.initial"
-        value="com.sun.jndi.rmi.registry.RegistryContextFactory"/>
-      <sysproperty key="java.naming.provider.url" value="rmi://localhost"/>
-      <sysproperty key="java.rmi.server.codebase"
-        value="${bin.uri}/${rmi.jar}"/>
-      <sysproperty key="cvs.root" value="${basedir}"/>
-      <sysproperty key="log4j.configuration"
-        value="${baseuri}/log4j-conf.xml"/>
-
-      <!-- JUnitPP settings -->
-      <arg line="-r 1000 -w 10000 -wm 2000 -s 100 -t 5000 -ra 5000 -f itql.commands"/>
-
-      <classpath>
-
-        <path refid="query-classpath"/>
-
-        <fileset dir="${bin.dir}" includes="${dtd.jar}, ${itql.jar}, ${rules.jar}, ${query.jar},
-                 ${driver.jar}, ${rmi.jar}, ${server-rmi.jar}"/>
-        <fileset dir="${lib.dir}" includes="xerces*.jar, xmlParserAPIs.jar, jxunit*.jar, junit.jar, junitpp.jar"/>
-      </classpath>
-
-    </java>
-   </target>
-
-  <!-- =================================================================== -->
-  <!-- Runs regression tests on a Mulgara server                               -->
-  <!-- =================================================================== -->
-  <!--target name="regression-test"
-    depends="-prepare-build, log4j-conf.xml, dist"
-    description="Runs regression tests on a Mulgara server">
-
-    <echo message="mulgara-test has not been implemented, run itql-test or dbms-test instead."/-->
-
-    <!-- Set timestamp for CruiseControl's benefit -->
-    <!--tstamp/>
-
-    <delete dir="${mulgara.results.tmpdir}"/>
-    <mkdir dir="${mulgara.results.tmpdir}"/>
-    <delete file="${mulgara.results}"/-->
-
-    <!-- start a server -->
-    <!--ant target="start"/-->
-
-    <!-- run the tests -->
-
-    <!-- stop the server -->
-    <!--ant target="stop"/>
-
-  </target-->
-
-
-  <!-- =================================================================== -->
-  <!-- Builds Mulgara Semantic Store (Mulgara) WAR                           -->
-  <!-- =================================================================== -->
-  <target name="mulgara-war"
-      description="Builds the Mulgara Semantic Store (Mulgara) WAR"
-      depends="driver-jar, itql-jar, sparql-int-jar, query-jar, rmi-jar, server-jar,
-      server-beep-jar, server-rmi-jar, util-jar, config-jar, descriptor-jar, dtd-compile,
-      set.host.name, mulgara.war-uptodate"
-      unless="mulgara.war-uptodate">
-
-    <copy file="${mulgara.war.src.dir}/WEB-INF/web.xml"
-      tofile="${obj.dir}/war/mulgara/WEB-INF/web.xml"/>
-
-    <replace file="${obj.dir}/war/mulgara/WEB-INF/web.xml"
-       token="@@hostname@@" value="${host.name}"/>
-
-    <delete file="${bin.dir}/${mulgara.war}"/>
-
-    <war warfile="${bin.dir}/${mulgara.war}"
-        webxml="${obj.dir}/war/mulgara/WEB-INF/web.xml">
-
-      <zipfileset dir="${conf.dir}" prefix="WEB-INF/conf"
-          includes="mulgara-config-war.xml, mulgara-rmi.policy, mulgara.policy,
-          log4j-mulgara-war.properties, expires.txt"/>
-
-      <fileset dir="${src.dir}/war/mulgara"
-          includes="WEB-INF/**" excludes="WEB-INF/web.xml"/>
-
-      <lib dir="${lib.dir}" includes="log4j-core-*.jar, icu4j.jar, jena-*.jar, antlr*.jar, beepcore-*.jar,
-          lucene*.jar, apache-soap-*.jar, ${jrdf.jar}, ${date-utils.jar}, ${commons-logging.jar}"/>
-      <lib dir="${bin.dir}" includes="${query.jar},
-        ${driver.jar}, ${itql.jar}, ${sparql-int.jar}, ${rules.jar}, ${rmi.jar},
-          ${server.jar}, ${server-beep.jar}, ${server-rmi.jar},
-          ${util.jar}, ${config.jar}"/>
-      <lib dir="${dist.dir}" includes="expires.txt"/>
-    </war>
-  </target>
-
-  <target name="mulgara.war-uptodate">
-
-    <uptodate property="mulgara.war-uptodate"
-       targetfile="${bin.dir}/${mulgara.war}">
-
-      <srcfiles dir="${bin.dir}" includes="${query.jar},
-          ${driver.jar}, ${itql.jar}, ${rules.jar}, ${rmi.jar},
-          ${sparql-int.jar},
-          ${server.jar}, ${server-beep.jar}, ${server-rmi.jar},
-          ${util.jar}, ${config.jar}, ${descriptor.jar}"/>
-      <srcfiles dir="${dist.dir}" includes="expires.txt"/>
-      <srcfiles dir="${conf.dir}" includes="**/*"/>
-      <srcfiles dir="${src.dir}/war/mulgara" includes="WEB-INF/**"
-                                         excludes="WEB-INF/web.xml"/>
-      <srcfiles dir="${mulgara.war.src.dir}/WEB-INF" includes="web.xml"/>
-    </uptodate>
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Compiles the Mulgara webui interface pages with XMLC                    -->
-  <!-- =================================================================== -->
-  <target name="webui-xmlc" depends="xmlc"
-      description="Compiles the Mulgara webui interface pages with XMLC">
-
-    <!-- Build the webui interface classes -->
-    <mkdir dir="${obj.dir}/war/webui/java"/>
-
-    <!-- build the webui interface classes -->
-    <xmlc sourceout="${obj.dir}/war/webui/java"
-          includes="**/*.html"
-          markup="HTML"
-          verbose="false"
-          force="no"
-          srcdir="${webui.src.dir}/template-html"/>
-  </target>
-
-
-  <!-- =================================================================== -->
-  <!-- Compiles the Mulgara webui interface classes                            -->
-  <!-- =================================================================== -->
-  <target name="webui-build" depends="webui-xmlc, eventbuilder, driver-dist"
-      description="Compiles the Mulgara webui interface classes">
-
-    <!-- Build the webui interface classes -->
-    <mkdir dir="${obj.dir}/war/webui/classes"/>
-    <mkdir dir="${obj.dir}/war/webui/xlib"/>
-
-    <!-- Event class generation - also compiles the XMLC generated classes -->
-    <eventbuilder sourceout="${obj.dir}/war/webui/java"
-        descriptor="${webui.viewer.src.dir}/events/events.xml">
-    </eventbuilder>
-
-    <javac srcdir="${obj.dir}/war/webui/java"
-     destdir="${obj.dir}/war/webui/classes"
-     debug="${debug}" deprecation="on">
-      <classpath refid="webui.classpath"/>
-    </javac>
-
-    <javac srcdir="${webui.src.dir}/java"
-        destdir="${obj.dir}/war/webui/classes"
-        debug="${debug}" deprecation="on">
-      <classpath refid="webui.classpath"/>
-    </javac>
-
-    <!-- Example queries and directives -->
-    <copy todir="${obj.dir}/war/webui/classes" >
-
-      <fileset dir="${webui.src.dir}/java" >
-
-        <include name="**/*.txt"/>
-        <include name="**/*.directives"/>
-      </fileset>
-    </copy>
-
-    <!-- images -->
-    <copy todir="${obj.dir}/war/webui/xlib" >
-
-      <fileset dir="${webui.src.dir}/template-html/org/mulgara/webui/viewer" >
-
-        <exclude name="**/*.html"/>
-        <exclude name="**/*.xmlc"/>
-      </fileset>
-    </copy>
-
-    <!-- Replace tokens in example queries - leave out the <> brackets-->
-    <!-- The name of the model to work on -->
-    <replace file="${obj.dir}/war/webui/classes/org/mulgara/webui/viewer/ExampleQueries.txt"
-       token="@@model-uri@@" value="rmi://host.name/server1#sampledata"/>
-    <replace file="${obj.dir}/war/webui/classes/org/mulgara/webui/viewer/ExampleQueries.txt"
-       token="@@data-dir@@" value="jar:file:mulgara.jar.path!/data"/>
-
-  </target>
-
-
-  <!-- =================================================================== -->
-  <!-- Builds the Mulgara webui interface WAR                                  -->
-  <!-- =================================================================== -->
-  <target name="webui-war" depends="webui-build, -webui-war-uptodate"
-      description="Builds the Mulgara webui interface WAR" unless="webui.war-uptodate">
-
-    <mkdir dir="${obj.dir}/war/webui/jars"/>
-
-    <!-- Actual page classes -->
-    <jar jarfile="${obj.dir}/war/webui/jars/${webui-screens.jar}">
-      <fileset dir="${obj.dir}/war/webui/classes" includes="org/mulgara/webui/**/*HTML.class"/>
-    </jar>
-
-    <!-- Images and stylesheet - swap this jar to change badging -->
-    <jar jarfile="${obj.dir}/war/webui/jars/${webui-resources.jar}"
-      basedir="${obj.dir}/war/webui/" includes="xlib/**"/>
-
-    <!-- Barracuda related classes -->
-    <jar jarfile="${obj.dir}/war/webui/jars/${webui-barracuda.jar}"
-      basedir="${obj.dir}/war/webui/classes"
-      includes="org/mulgara/barracuda/**"/>
-
-    <!-- Logic -->
-    <jar jarfile="${obj.dir}/war/webui/jars/${webui-logic.jar}"
-      basedir="${obj.dir}/war/webui/classes"
-      includes="org/mulgara/webui/**"
-      excludes="**/*HTML.class"/>
-
-    <war warfile="${bin.dir}/${webui.war}"
-      webxml="${webui.src.dir}/WEB-INF/web.xml">
-
-      <fileset dir="${webui.src.dir}/content"/>
-      <fileset dir="${webui.src.dir}"
-        includes="WEB-INF/**" excludes="WEB-INF/web.xml"/>
-
-      <lib dir="${lib.dir}" includes="xmlc-all*.jar, *barracuda*.jar, plankton*.jar"/>
-      <lib dir="${obj.dir}/war/webui/jars" includes="*.jar"/>
-    </war>
-  </target>
-
-  <target name="-webui-war-uptodate">
-
-     <uptodate property="webui.war-uptodate" targetfile="${bin.dir}/${webui.war}">
-
-       <srcfiles dir="${dist.dir}" includes="${driver.jar}"/>
-       <srcfiles dir="${obj.dir}/war/webui/jars" includes="*.jar"/>
-       <srcfiles dir="${obj.dir}/war/webui/classes"/>
-     </uptodate>
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- J2EE resource adapter                                               -->
-  <!-- =================================================================== -->
-  <target name="mulgara-rar" depends="driver-jar, query-jar">
-
-    <jar jarfile="${bin.dir}/mulgara.rar">
-
-      <fileset dir="${src.dir}/rar/mulgara" includes="META-INF/ra.xml"/>
-      <fileset dir="${src.dir}/rar/mulgara/content"/>
-      <fileset dir="${bin.dir}" includes="${driver.jar}, ${query.jar}"/>
-      <fileset dir="${lib.dir}" includes="beepcore-*.jar"/>
-    </jar>
-  </target>
-
-  <!-- Hand-run test example for rdfload -->
-  <target name="load-rdf-example" depends="host.name, define.rdfload, start"
-   description="Hand-run example of using the rdfload task">
-
-    <sleep seconds="15"/>
-
-    <!-- delete old logs -->
-    <delete file="${basedir}/rdfload.log"/>
-
-    <rdfload
-       logfile="${basedir}/rdfload.log"
-       modeluri="rmi://${host.name}/server1#load-rdf-example"
-       domainuri="rmi://${host.name}/server1"
-       username="user"
-       password="letmein"
-       dropmodel="yes"
-       maxerrors="10"
-       ignoreerrors="false"
-       transactionsize="10"
-       logconfig="${conf.dir}/log4j-rdfload.xml">
-
-       <rdfpath>
-
-         <fileset dir="${jxdata.dir}/ant-tasks">
-
-           <include name="rdf-good/*.rdf"/>
-           <!-- Put in a baddy -->
-           <include name="rdf-bad/2.rdf"/>
-        </fileset>
-      </rdfpath>
-    </rdfload>
-
-   <!-- shutdown the Mulgara server -->
-   <antcall target="stop"/>
-
-  </target>
-
-
-  <!-- Hand-run test example for itql command -->
-  <target name="itqlcommand-example" depends="host.name, define.itqlcommand, start"
-   description="Hand-run example of using the itqlcommand task">
-
-    <sleep seconds="15"/>
-
-    <itqlcommand ignoreerrors="true">
-
-       <itqlquery query="set autocommit off;"/>
-       <itqlquery query="create &lt;rmi://${host.name}/server1#itqlcommand-example&gt; ;"/>
-       <itqlquery query="insert &lt;http://test&gt; &lt;http://message&gt; 'Hello World' into  &lt;rmi://${host.name}/server1#itqlcommand-test&gt; ;"/>
-       <itqlquery query="select $$s $$p $$o from &lt;rmi://${host.name}/server1#itqlcommand-test&gt; where $$s $$p $$o ;"/>
-       <itqlquery query="drop &lt;rmi://${host.name}/server1#itqlcommand-test&gt; ;"/>
-       <!-- Bad query -->
-       <itqlquery query="drop &lt;rmi://${host.name}/server1#itqlcommand-test&gt; ;"/>
-       <itqlquery query="set autocommit on;"/>
-    </itqlcommand>
-
-   <!-- shutdown the Mulgara server -->
-   <antcall target="stop"/>
-
-  </target>
-
-  <!-- ======================================================= -->
-  <!-- Publish the test results to Anthill                     -->
-  <!-- ======================================================= -->
-  <target name="publish"
-   description="Publish the test results to the deployDir">
-
-     <antcall target="format-results"/>
-
-     <!-- Set new values if not already put in test dir under html -->
-     <property name="deployDir" value="${test.dir}"/>
-     <property name="version" value="html"/>
-
-     <mkdir dir="${deployDir}/${version}"/>
-
-     <copy todir="${deployDir}/${version}">
-       <fileset dir="${test.dir}"
-         includes="**/*.html,**/*.css"
-         excludes="RDF-Test-Cases/**"/>
-     </copy>
-
-     <mkdir dir="${deployDir}/${version}/logs"/>
-     <copy todir="${deployDir}/${version}/logs">
-       <fileset dir="${jxtest.dir}"
-         includes="**/*.xml,**/*.txt"/>
-     </copy>
-     <copy todir="${deployDir}/${version}/logs">
-       <fileset dir="${jxtest.dir}"
-         includes="**/*output. **/*.log"/>
-     </copy>
-
-  </target>
-
-  <target name="format-results" description="Report results of the JUnit tests">
-    <junitreport tofile="test/All-Tests.xml">
-      <fileset dir="${junit.results.tmpdir}" includes="TEST-*.xml"/>
-      <report todir="${test.dir}"/>
-    </junitreport>
-  </target>
-
-  <target name="publish-summary" depends="format-results"
-          description="Report summary of Junit results">
-
-    <delete file="${test.dir}/junit-summary.txt"/>
-    <delete file="${test.dir}/All-Tests.html"/>
-
-    <xslt  basedir="${test.dir}"
-           destdir="${test.dir}"
-           style="${scripts.dir}/junit-summary.xsl"
-           includes="**/All-Tests.xml">
-       <param name="output.dir" expression="${test.dir}"/>
-    </xslt>
-
-    <concat>
-      <fileset file="${test.dir}/junit-summary.txt"/>
-    </concat>
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Creates the distribution file for the Embedded Mulgara server        -->
-  <!-- =================================================================== -->
-  <target name="embedded-dist"
-          depends="client-jrdf-jar, config-jar,
-             content-mbox-jar, content-mp3-jar, content-n3-jar,
-             content-rdfxml-jar, content-rio-jar,
-             create-manifest, demo-jar, dtd-jar, driver-jar, dtd-jar,
-             itql-jar, sparql-int-jar,
-             javadoc-dist, jrdf-jar, store-jar, store-xa-jar,
-             store-nodepool-jar,
-             store-nodepool-memory-jar, store-nodepool-xa-jar,
-             query-jar, resolver-jar, resolver-null-jar, resolver-file-jar, resolver-filesystem-jar,
-             resolver-http-jar, resolver-memory-jar, resolver-spi-jar,
-             resolver-store-jar, resolver-url-jar, resolver-lucene-jar,
-             resolver-view-jar, resolver-nodetype-jar, resolver-prefix-jar, resolver-jar-jar,
-             resolver-relational-jar, resolver-distributed-jar,
-             resolver-xsd-jar, resolver-test-jar, rmi-jar,
-             server-jar, server-beep-jar, server-rmi-jar,
-             sofa-jar, rules-jar, krule-jar, store-stringpool-jar, store-stringpool-memory-jar,
-             store-stringpool-xa-jar, tuples-jar,
-             tuples-hybrid-jar, util-jar, util-xa-jar,
-             webservices-war, webui-war, -embedded-dist-uptodate, webpage-includes"
-          description="Creates the executable JAR for the Embedded Mulgara server"
-                unless="embedded.dist.uptodate">
-
-    <!-- HACK!!!!! -->
-    <!-- This will get the ARP parser working -->
-    <!-- My theory about why this is necessary is that the Bootloader class
-         messes up the JAR plugin framework that both JAXP and StAX use -->
-    <mkdir dir="${obj.dir}/xerces"/>
-
-    <unjar src="${lib.dir}/xercesImpl.jar" dest="${obj.dir}/xerces"/>
-    <unjar src="${lib.dir}/xmlParserAPIs.jar" dest="${obj.dir}/xerces"/>
-    <unjar src="${lib.dir}/jsr173_07_api.jar" dest="${obj.dir}/xerces"/>
-    <unjar src="${lib.dir}/jsr173_07_ri.jar" dest="${obj.dir}/xerces"/>
-
-    <!-- build the executable jar file -->
-    <jar jarfile="${dist.dir}/${mulgara.jar}"
-        manifest="${obj.dir}/META-INF/MANIFEST_Mulgara_BOOTSTRAP.MF">
-
-      <zipfileset dir="${conf.dir}" prefix="conf"
-          includes="log4j-mulgara.xml, webdefault.xml, mulgara-rmi.policy,
-                    mulgara.policy"/>
-
-      <!-- third party libraries -->
-      <zipfileset src="${lib.dir}/${log4j.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${icu4j.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${activation.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${beep.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${jargs.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${jrdf.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${jetty.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${jetty.plus.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${servlet.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${jasper.runtime.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${jasper.compiler.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${lucene.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${mail.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${mulgara-sparql.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${castor-xml.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${castor-xml-schema.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${castor-codegen.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${trove.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${date-utils.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${commons-logging.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${commons-httpclient.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${commons-codec.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${emory-util.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${jotm.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${jotm.jrmp.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${carol.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${howl.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${jta.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${jsr.173.api.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${jsr.173.ri.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${jca.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${saaj.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${axis.jar}" excludes="META-INF/**, log4j.properties"/>
-      <zipfileset src="${lib.dir}/${commons-discovery.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${jaxrpc.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${wsdl4j.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${jakarta-oro.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${jena.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${antlr.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${serializer.jar}" excludes="META-INF/**"/>
-
-      <!-- core libraries -->
-      <zipfileset src="${bin.dir}/${query.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${driver.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${itql.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${sparql-int.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${rmi.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${server.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${server-beep.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${server-rmi.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${util.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${config.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${descriptor.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${server-local.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-spi.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-filesystem.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${store.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${store-xa.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${store-nodepool.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${store-nodepool-memory.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${store-nodepool-xa.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${store-stringpool.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${store-stringpool-memory.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${store-stringpool-xa.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${util-xa.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-null.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-file.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-http.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-lucene.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-memory.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-store.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-url.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-view.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${tuples.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${tuples-hybrid.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${content-mp3.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${content-n3.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${content-mbox.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${content-rdfxml.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${content-rio.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-nodetype.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-prefix.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-relational.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-distributed.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-xsd.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-test.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-jar.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${jid3.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${dtd.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${jrdf.base.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${rules.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${krule.jar}" excludes="META-INF/**"/>
-
-
-      <!-- include pre-bundled webapps -->
-      <zipfileset dir="${bin.dir}" prefix="webapps"
-          includes="${webui.war}"/>
-      <zipfileset dir="${obj.dir}/war" prefix="webapps"
-          includes="webservices.war"/>
-      <zipfileset dir="${lib.dir}" prefix="lib" includes="barracuda-core*.jar"/>
-      <zipfileset file="${obj.dir}/mulgara-x-config.xml" prefix="conf" />
-
-      <!-- Schemas -->
-      <zipfileset dir="${basedir}/data" prefix="data"
-          includes="**/*.rdfs,**/*.rss,**/*.n3"/>
-
-      <zipfileset dir="${basedir}/docs" prefix="docs"
-          includes="**/*.html, **/*.css, **/images/*, **/images/icons/*, LEGAL.txt"/>
-      <zipfileset dir="${src.docs.dir}" prefix="docs"
-          includes="**/*.html, **/*.htm, **/*.gif, **/*.png, **/*.jpg, **/*.css, **/images/*, **/images/icons/*"/>
-
-      <fileset dir="${obj.dir}/jar/util/classes" includes="**/Bootstrap.class"/>
-      <fileset dir="${src.dir}/jar/dtd" includes="META-INF/**, DTD/**"/>      <!-- fileset dir="${obj.dir}/jar/dtd/classes"/ -->
-
-      <!-- HACK!!!!! -->
-      <!-- This will get the ARP parser working -->
-      <!-- Ignore the xerces DocumentBuilderFactory -->
-      <fileset dir="${obj.dir}/xerces" excludes="META_INF/**,META-INF/services/javax.xml.parsers.DocumentBuilderFactory"/>
-
-      <fileset dir="${obj.dir}/xerces" excludes="META_INF/**"/>
-      <!-- HACK!!!!! -->
-
-    </jar>
-  </target>
-
-  <!-- do a check for any changes made to the mulgara build -->
-  <!-- potentially not the most efficient checking performed -->
-  <target name="-embedded-dist-uptodate">
-
-    <uptodate property="embedded.dist.uptodate"
-       targetfile="${dist.dir}/${mulgara.jar}">
-
-      <srcfiles dir="${bin.dir}" includes="**/*"/>
-      <srcfiles dir="${conf.dir}" includes="**/*"/>
-      <srcfiles dir="${lib.dir}" includes="**/*"/>
-      <srcfiles dir="${data.dir}" includes="**/*"/>
-      <srcfiles dir="${obj.dir}/war" includes="webservices.war"/>
-      <srcfiles dir="${basedir}/docs" includes="**/*"/>
-    </uptodate>
-  </target>
-
-  <target name="create-manifest" depends="-prepare-build">
-
-    <mkdir dir="${obj.dir}/META-INF"/>
-
-    <!-- generate the core manifest -->
-    <manifest file="${obj.dir}/META-INF/MANIFEST_Mulgara_BASE.MF">
-      <attribute name="Main-Class" value="org.mulgara.triplestore.Main"/>
-    </manifest>
-
-    <!-- generate the bootstrap manifest -->
-    <manifest file="${obj.dir}/META-INF/MANIFEST_Mulgara_BOOTSTRAP.MF">
-
-      <attribute name="Main-Class" value="org.mulgara.util.Bootstrap"/>
-      <attribute name="Embedded-Main-Class" value="org.mulgara.server.EmbeddedMulgaraServer"/>
-    </manifest>
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Meta testing target, updates source before running tests            -->
-  <!-- =================================================================== -->
-
-  <target name="test"
-          depends="dist, client-test, session-test, resolver-api-test, store-xa-test,
-                   utils-test, jxtest, store-stringpool-xa-loadtest, publish-summary"
-          description="Runs all tests (updates source first)">
-
-    <loadfile property="test.status.success" srcfile="${test.dir}/junit-summary.txt">
-      <filterchain>
-        <linecontainsregexp>
-          <regexp pattern="Success rate *100\.?0?0?%"/>
-        </linecontainsregexp>
-      </filterchain>
-    </loadfile>
-    <fail unless="test.status.success"/>
-  </target>
-
-  <target name="client-test"
-          depends="client-jrdf-test,
-                   demo-mp3-test, driver-test, itql-test, query-test,
-                   descriptor-test"
-          description="Runs client side tests">
-  </target>
-
-  <target name="session-test"
-          depends="jrdf-test, server-test,
-             server-beep-test, server-http-test, server-local-test,
-             server-rmi-test"
-          description="Runs session based tests">
-  </target>
-
-  <target name="resolver-api-test"
-    depends="content-mbox-test, content-mp3-test, content-n3-test,
-             content-rdfxml-test, content-rio-test,
-             resolver-test, resolver-null-test, resolver-file-test,
-             resolver-filesystem-test, resolver-jar-test, resolver-gis-test,
-             resolver-http-test, resolver-lucene-test,
-             resolver-nodetype-test, resolver-prefix-test, resolver-memory-test,
-             resolver-spi-test, resolver-store-test, resolver-relational-test,
-             resolver-url-test, resolver-view-test, resolver-xsd-test,
-             resolver-distributed-test, resolver-test-test,
-             store-stringpool-test"
-    description="Runs resolver API/SPI tests">
-  </target>
-
-  <target name="store-xa-test"
-    depends="store-nodepool-memory-test, store-nodepool-xa-test,
-             store-stringpool-memory-test,
-             store-stringpool-xa-test, tuples-test, tuples-hybrid-test"
-    description="Runs store -xa tests">
-  </target>
-
-  <target name="utils-test"
-    depends="ant-task-test, dtd-test, sofa-test, rules-test, krule-test, tag-test, util-test, util-xa-test"
-    description="Runs miscellaneous utility tests">
-  </target>
-
-  <target name="jxtest"
-    depends="jxunit-test"
-    description="Runs all jxunit based testing">
-  </target>
-
-  <target name="ideSupport" depends="dist,demo-mp3-jar,descriptor-wsdl-client.jar"
-    description="Builds necessary libraries for using the Eclipse IDE.">
-
-     <jar jarfile="${dist.dir}/ideSupport.jar">
-      <zipfileset dir="${obj.dir}/jar/itql/classes" includes="org/mulgara/itql/**"/>
-      <zipfileset dir="${obj.dir}/jar/itql/java" includes="org/mulgara/itql/lexer/lexer.dat"/>
-      <zipfileset dir="${obj.dir}/jar/itql/java" includes="org/mulgara/itql/parser/parser.dat"/>
-      <zipfileset dir="${obj.dir}/jar/config/classes" includes="org/mulgara/config/**"/>
-      <zipfileset dir="${obj.dir}/jar/util/classes" includes="org/mulgara/util/conversion/**"/>
-      <zipfileset dir="${obj.dir}/jar/server-rmi/classes" includes="org/mulgara/server/rmi/**"/>
-	  <zipfileset dir="${obj.dir}/jar/demo-mp3/classes" includes="org/mulgara/demo/mp3/**"/>
-      <zipfileset dir="${obj.dir}/war/webui/classes" includes="org/mulgara/barracuda/**"/>
-      <zipfileset dir="${obj.dir}/war/webui/classes" includes="org/mulgara/webui/**"/>
-      <zipfileset dir="${basedir}" includes="conf/**"/>
-  	  <zipfileset dir="${obj.dir}/jar/descriptor-client/classes" includes="org/mulgara/descriptor/**" excludes="org/mulgara/descriptor/test/**"/>
-      <!-- include pre-bundled webapps -->
-      <zipfileset dir="${bin.dir}" prefix="webapps" includes="${webui.war}"/>
-      <zipfileset dir="${obj.dir}/war" prefix="webapps" includes="webservices.war"/>
-      <zipfileset dir="${lib.dir}" prefix="lib" includes="barracuda*.jar"/>
-      <zipfileset file="${obj.dir}/mulgara-x-config.xml" prefix="conf" />
-
-      <!-- Schemas -->
-      <zipfileset dir="${basedir}/data" prefix="data" includes="**/*.rdfs,**/*.rss,**/*.n3"/>
-
-      <zipfileset dir="${basedir}/docs" prefix="docs" includes="**/*.html, **/*.css, **/images/*, **/images/icons/*, LEGAL.txt"/>
-      <zipfileset dir="${src.docs.dir}" prefix="docs" includes="**/*.html, **/*.htm, **/*.gif, **/*.png, **/*.jpg, **/*.css, **/images/*, **/images/icons/*"/>
-
-      <fileset dir="${src.dir}/jar/dtd" includes="META-INF/**, DTD/**"/>     
-
-    </jar>
-  </target>
-
-  
-</project>
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE project>
+
+  <!-- =================================================================== -->
+  <!--                       Project definition                            -->
+  <!-- =================================================================== -->
+  <project name="Mulgara" default="help" basedir=".">
+
+  <!-- =================================================================== -->
+  <!--                      Property Definitions                           -->
+  <!-- =================================================================== -->
+  <property file="common.properties"/>
+  <property file="build.properties"/>
+
+  <property file="${jar.src.dir}/ant-task/ant-task-build.properties"/>
+  <property file="${jar.src.dir}/client-jrdf/client-jrdf-build.properties"/>
+  <property file="${jar.src.dir}/config/config-build.properties"/>
+  <property file="${jar.src.dir}/demo/demo-build.properties"/>
+  <property file="${jar.src.dir}/demo-mp3/demo-mp3-build.properties"/>
+  <property file="${jar.src.dir}/content-mbox/content-mbox-build.properties"/>
+  <property file="${jar.src.dir}/content-mp3/content-mp3-build.properties"/>
+  <property file="${jar.src.dir}/content-n3/content-n3-build.properties"/>
+  <property file="${jar.src.dir}/content-rdfxml/content-rdfxml-build.properties"/>
+  <property file="${jar.src.dir}/content-rio/content-rio-build.properties"/>
+  <property file="${jar.src.dir}/descriptor/descriptor-build.properties"/>
+  <property file="${jar.src.dir}/driver/driver-build.properties"/>
+  <property file="${jar.src.dir}/dtd/dtd-build.properties"/>
+  <property file="${jar.src.dir}/itql/itql-build.properties"/>
+  <property file="${jar.src.dir}/jrdf/jrdf-build.properties"/>
+  <property file="${jar.src.dir}/query/query-build.properties"/>
+  <!--property file="${jar.src.dir}/rdql/rdql-build.properties"/-->
+  <property file="${jar.src.dir}/resolver/resolver-build.properties"/>
+  <property file="${jar.src.dir}/resolver-null/resolver-null-build.properties"/>
+  <property file="${jar.src.dir}/resolver-file/resolver-file-build.properties"/>
+  <property file="${jar.src.dir}/resolver-filesystem/resolver-filesystem-build.properties"/>
+  <property file="${jar.src.dir}/resolver-gis/resolver-gis-build.properties"/>
+  <property file="${jar.src.dir}/resolver-http/resolver-http-build.properties"/>
+  <property file="${jar.src.dir}/resolver-jar/resolver-jar-build.properties"/>
+  <property file="${jar.src.dir}/resolver-lucene/resolver-lucene-build.properties"/>
+  <property file="${jar.src.dir}/resolver-memory/resolver-memory-build.properties"/>
+  <property file="${jar.src.dir}/resolver-spi/resolver-spi-build.properties"/>
+  <property file="${jar.src.dir}/resolver-store/resolver-store-build.properties"/>
+  <property file="${jar.src.dir}/resolver-url/resolver-url-build.properties"/>
+  <property file="${jar.src.dir}/resolver-view/resolver-view-build.properties"/>
+  <property file="${jar.src.dir}/resolver-xsd/resolver-xsd-build.properties"/>
+  <property file="${jar.src.dir}/resolver-test/resolver-test-build.properties"/>
+  <property file="${jar.src.dir}/resolver-nodetype/resolver-nodetype-build.properties"/>
+  <property file="${jar.src.dir}/resolver-prefix/resolver-prefix-build.properties"/>
+  <property file="${jar.src.dir}/resolver-relational/resolver-relational-build.properties"/>
+  <property file="${jar.src.dir}/resolver-distributed/resolver-distributed-build.properties"/>
+  <property file="${jar.src.dir}/server/server-build.properties"/>
+  <property file="${jar.src.dir}/server-beep/server-beep-build.properties"/>
+  <property file="${jar.src.dir}/server-http/server-http-build.properties"/>
+  <property file="${jar.src.dir}/server-local/server-local-build.properties"/>
+  <property file="${jar.src.dir}/server-rmi/server-rmi-build.properties"/>
+  <property file="${jar.src.dir}/sofa/sofa-build.properties"/>
+  <property file="${jar.src.dir}/krule/krule-build.properties"/>
+  <property file="${jar.src.dir}/rules/rules-build.properties"/>
+  <property file="${jar.src.dir}/sparql-protocol/sparql-protocol-build.properties"/>
+  <property file="${jar.src.dir}/sparql-interpreter/sparql-interpreter-build.properties"/>
+  <property file="${jar.src.dir}/store/store-build.properties"/>
+  <property file="${jar.src.dir}/store-xa/store-xa-build.properties"/>
+  <property file="${jar.src.dir}/store-nodepool/store-nodepool-build.properties"/>
+  <property file="${jar.src.dir}/store-nodepool-memory/store-nodepool-memory-build.properties"/>
+  <property file="${jar.src.dir}/store-nodepool-xa/store-nodepool-xa-build.properties"/>
+  <property file="${jar.src.dir}/store-stringpool/store-stringpool-build.properties"/>
+  <property file="${jar.src.dir}/store-stringpool-memory/store-stringpool-memory-build.properties"/>
+  <property file="${jar.src.dir}/store-stringpool-xa/store-stringpool-xa-build.properties"/>
+  <property file="${jar.src.dir}/tag/tag-build.properties"/>
+  <property file="${jar.src.dir}/tuples-hybrid/tuples-hybrid-build.properties"/>
+  <property file="${jar.src.dir}/tuples/tuples-build.properties"/>
+  <property file="${jar.src.dir}/util-xa/util-xa-build.properties"/>
+  <property file="${jar.src.dir}/util/util-build.properties"/>
+
+  <property name="webui.viewer.src.dir"
+      value="${webui.src.dir}/java/org/mulgara/webui/viewer"/>
+  <property name="webui.viewer.obj.dir.classes"
+      value="${obj.dir}/war/webui/classes/org/mulgara/webui/viewer"/>
+
+  <!-- =================================================================== -->
+  <!--                              Imports                                -->
+  <!-- =================================================================== -->
+  <import file="common.xml"/>
+  <import file="webdocs.xml"/>
+
+  <import file="${jar.src.dir}/ant-task/build.xml"/>
+  <import file="${jar.src.dir}/client-jrdf/build.xml"/>
+  <import file="${jar.src.dir}/demo/build.xml"/>
+  <import file="${jar.src.dir}/demo-mp3/build.xml"/>
+  <import file="${jar.src.dir}/config/build.xml"/>
+  <import file="${jar.src.dir}/content-mbox/build.xml"/>
+  <import file="${jar.src.dir}/content-mp3/build.xml"/>
+  <import file="${jar.src.dir}/content-n3/build.xml"/>
+  <import file="${jar.src.dir}/content-rdfxml/build.xml"/>
+  <import file="${jar.src.dir}/content-rio/build.xml"/>
+  <import file="${jar.src.dir}/descriptor/build.xml"/>
+  <import file="${jar.src.dir}/driver/build.xml"/>
+  <import file="${jar.src.dir}/dtd/build.xml"/>
+  <import file="${jar.src.dir}/itql/build.xml"/>
+  <import file="${jar.src.dir}/jrdf/build.xml"/>
+  <import file="${jar.src.dir}/query/build.xml"/>
+  <!--import file="${jar.src.dir}/rdql/build.xml"/-->
+  <import file="${jar.src.dir}/resolver/build.xml"/>
+  <import file="${jar.src.dir}/resolver-null/build.xml"/>
+  <import file="${jar.src.dir}/resolver-file/build.xml"/>
+  <import file="${jar.src.dir}/resolver-filesystem/build.xml"/>
+  <import file="${jar.src.dir}/resolver-gis/build.xml"/>
+  <import file="${jar.src.dir}/resolver-http/build.xml"/>
+  <import file="${jar.src.dir}/resolver-jar/build.xml"/>
+  <import file="${jar.src.dir}/resolver-lucene/build.xml"/>
+  <import file="${jar.src.dir}/resolver-memory/build.xml"/>
+  <import file="${jar.src.dir}/resolver-nodetype/build.xml"/>
+  <import file="${jar.src.dir}/resolver-prefix/build.xml"/>
+  <import file="${jar.src.dir}/resolver-relational/build.xml"/>
+  <import file="${jar.src.dir}/resolver-distributed/build.xml"/>
+  <import file="${jar.src.dir}/resolver-spi/build.xml"/>
+  <import file="${jar.src.dir}/resolver-store/build.xml"/>
+  <import file="${jar.src.dir}/resolver-url/build.xml"/>
+  <import file="${jar.src.dir}/resolver-view/build.xml"/>
+  <import file="${jar.src.dir}/resolver-xsd/build.xml"/>
+  <import file="${jar.src.dir}/resolver-test/build.xml"/>
+  <import file="${jar.src.dir}/server/build.xml"/>
+  <import file="${jar.src.dir}/server-beep/build.xml"/>
+  <import file="${jar.src.dir}/server-http/build.xml"/>
+  <import file="${jar.src.dir}/server-local/build.xml"/>
+  <import file="${jar.src.dir}/server-rmi/build.xml"/>
+  <import file="${jar.src.dir}/sofa/build.xml"/>
+  <import file="${jar.src.dir}/krule/build.xml"/>
+  <import file="${jar.src.dir}/rules/build.xml"/>
+  <import file="${jar.src.dir}/sparql-protocol/build.xml"/>
+  <import file="${jar.src.dir}/sparql-interpreter/build.xml"/>
+  <import file="${jar.src.dir}/store/build.xml"/>
+  <import file="${jar.src.dir}/store-xa/build.xml"/>
+  <import file="${jar.src.dir}/store-nodepool/build.xml"/>
+  <import file="${jar.src.dir}/store-nodepool-memory/build.xml"/>
+  <import file="${jar.src.dir}/store-nodepool-xa/build.xml"/>
+  <import file="${jar.src.dir}/store-stringpool/build.xml"/>
+  <import file="${jar.src.dir}/store-stringpool-memory/build.xml"/>
+  <import file="${jar.src.dir}/store-stringpool-xa/build.xml"/>
+  <import file="${jar.src.dir}/tag/build.xml"/>
+  <import file="${jar.src.dir}/tuples-hybrid/build.xml"/>
+  <import file="${jar.src.dir}/tuples/build.xml"/>
+  <import file="${jar.src.dir}/util-xa/build.xml"/>
+  <import file="${jar.src.dir}/util/build.xml"/>
+
+  <!-- =================================================================== -->
+  <!--                          Path Definitions                           -->
+  <!-- =================================================================== -->
+  <path id="project-classpath">
+
+    <path refid="common-classpath"/>
+  </path>
+
+  <path id="webui.classpath">
+
+    <pathelement path="${java.class.path}"/>
+    <pathelement path="${obj.dir}/war/webui/classes"/>
+
+    <fileset dir="${lib.dir}" includes="**/**"/>
+    <fileset dir="${dist.dir}" includes="${driver.jar}"/>
+  </path>
+
+  <!-- =================================================================== -->
+  <!--                          Task Definitions                           -->
+  <!-- =================================================================== -->
+
+  <!-- Define the RDFLoad task -->
+  <target name="define.rdfload" unless="define.rdfload" depends="ant-task-jar"
+   description="Defines the rdfload taskdef">
+
+    <taskdef name="rdfload" classname="org.mulgara.ant.task.rdf.RDFLoad">
+
+     <classpath>
+
+       <pathelement path="${dist.dir}/${driver.jar}"/>
+       <pathelement path="${dist.dir}/${ant-task.jar}"/>
+       <pathelement path="${lib.dir}/apache-soap-2.2.jar"/>
+       <pathelement path="${lib.dir}/log4j-1.2.15.jar"/>
+     </classpath>
+    </taskdef>
+
+    <property name="define.rdfload" value="true"/>
+  </target>
+
+  <!-- Define the ITQLCommand task -->
+  <target name="define.itqlcommand" unless="define.itqlcommand" depends="ant-task-jar"
+   description="Defines the itqlcommand taskdef">
+
+    <taskdef name="itqlcommand" classname="org.mulgara.ant.task.itql.ITQLCommand">
+
+     <classpath>
+
+       <pathelement path="${dist.dir}/${driver.jar}"/>
+       <pathelement path="${dist.dir}/${ant-task.jar}"/>
+       <pathelement path="${lib.dir}/apache-soap-2.2.jar"/>
+       <pathelement path="${lib.dir}/log4j-1.2.15.jar"/>
+     </classpath>
+    </taskdef>
+
+    <property name="define.itqlcommand" value="true"/>
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Delete all intermediate and end product files, leaving only files   -->
+  <!-- from CVS.                                                           -->
+  <!-- =================================================================== -->
+  <target name="clean"
+      description="Deletes all intermediate and product files, leaving only sources">
+
+    <tstamp/>
+
+    <delete dir="${obj.dir}"/>
+    <delete dir="${test.dir}"/>
+    <delete dir="${bin.dir}"/>
+    <delete dir="${dist.dir}"/>
+    <delete dir="${tmp.dir}"/>
+    <delete dir="${javadoc.dir}"/>
+    <delete dir="${jxtest.dir}"/>
+    <delete dir="${src.docs.dir}"/>
+    <delete dir="${basedir}/testDatabase"/>
+    <delete dir="${basedir}/sqltest"/>
+    <delete>
+      <fileset dir="${basedir}" includes="*.log*"/>
+    </delete>
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Automated testing target for Anthill, updates source before         -->
+  <!-- running tests                                                       -->
+  <!-- =================================================================== -->
+  <target name="anthill-test"
+          depends="clean, test"
+          description="Runs all tests for Anthill">
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Automated testing target for Anthill, updates source before         -->
+  <!-- running tests                                                       -->
+  <!-- =================================================================== -->
+  <target name="anthill-quick-test"
+          depends="clean, jxunit-test, publish"
+          description="Runs all tests for Anthill">
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Performs a cvs update on the server-side source                     -->
+  <!-- =================================================================== -->
+  <target name="cvs-update" description="perform a CVS update on all source">
+    <cvs cvsRoot="${cvs.root}" package="${cvs.src.package}" command="update"/>
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Run JUnit regression (non-load) tests on dbms.jar                   -->
+  <!-- =================================================================== -->
+  <target name="dbms-test" depends="-prepare-build, uri,
+    driver-jar, itql-jar, query-jar, util-jar, log4j-conf.xml"
+    description="runs regression tests on the triple store">
+
+    <!-- Set timestamp for CruiseControl's benefit -->
+    <tstamp/>
+
+    <delete dir="${junit.results.tmpdir}"/>
+
+    <mkdir dir="${junit.results.tmpdir}"/>
+
+    <delete file="${junit.results}"/>
+
+    <junit fork="yes" haltonfailure="no" printsummary="on"
+      jvm="${java.home}/bin/java" dir="${basedir}">
+
+      <!-- The cvs.root system property allows tests to find CVS'ed test data -->
+      <jvmarg value="${arch.bits}"/>
+      <jvmarg value="-Djava.io.tmpdir=${tmp.dir}"/>
+      <jvmarg value="-Djava.naming.factory.initial=com.sun.jndi.rmi.registry.RegistryContextFactory"/>
+      <jvmarg value="-Djava.naming.provider.url=rmi://localhost"/>
+      <jvmarg value="-Djava.rmi.server.codebase=${bin.uri}/${rmi.jar}"/>
+      <jvmarg value="-Dcvs.root=${basedir}"/>
+      <jvmarg value="-Dlog4j.configuration=${baseuri}/log4j-conf.xml"/>
+
+      <classpath refid="project-classpath"/>
+      <classpath path="${activation.jar}"/>
+      <classpath path="${bin.dir}/${query.jar}"/>
+      <classpath path="${bin.dir}/${driver.jar}"/>
+      <classpath path="${bin.dir}/${itql.jar}"/>
+      <classpath path="${bin.dir}/${rules.jar}"/>
+      <classpath path="${bin.dir}/${server.jar}"/>
+      <classpath path="${bin.dir}/${util.jar}"/>
+
+      <formatter type="xml"/>
+
+      <batchtest todir="${junit.results.tmpdir}">
+
+        <fileset dir="${src.dir}/jar/query/java" includes="**/*Test.java"
+          excludes="**/*LoadTest.java"/>
+        <fileset dir="${src.dir}/jar/driver/java" includes="**/*Test.java"
+          excludes="**/*LoadTest.java"/>
+        <fileset dir="${src.dir}/jar/itql/java" includes="**/*Test.java"
+          excludes="**/*LoadTest.java"/>
+        <fileset dir="${src.dir}/jar/server/java" includes="**/*Test.java"
+          excludes="**/*LoadTest.java"/>
+        <fileset dir="${src.dir}/jar/util/java" includes="**/*Test.java"
+          excludes="**/*LoadTest.java"/>
+      </batchtest>
+    </junit>
+
+    <!-- junitreport does not seem to support props in the tofile attribute -->
+    <!--<junitreport tofile="${junit.results}">-->
+
+    <junitreport tofile="test/All-Tests.xml">
+      <fileset dir="${junit.results.tmpdir}" includes="TEST-*.xml"/>
+    </junitreport>
+  </target>
+
+  <target name="base-dist"
+          depends="ant-task-dist,
+                   client-jrdf-dist, content-mbox-dist,
+                   content-mp3-dist, content-rdfxml-dist, content-rio-dist,
+                   descriptor-dist, driver-dist, dtd-dist, itql-dist, jrdf-dist,
+                   store-dist, store-xa-dist, store-nodepool-dist,
+                   store-nodepool-memory-dist,
+                   store-nodepool-xa-dist, query-dist,
+                   resolver-dist, resolver-null-dist, resolver-file-dist, resolver-filesystem-dist,
+                   resolver-http-dist, resolver-nodetype-dist, resolver-prefix-dist,
+                   resolver-lucene-dist, resolver-memory-dist, resolver-relational-dist,
+                   resolver-spi-dist, resolver-store-dist, resolver-distributed-dist,
+                   resolver-url-dist, resolver-view-dist, resolver-xsd-dist,
+                   resolver-jar-dist, resolver-test-dist,
+                   server-dist, server-beep-dist, server-http-dist, server-local-dist,
+                   server-rmi-dist, sofa-dist, sparql-int-dist, krule-dist, rules-dist,
+                   store-stringpool-dist, store-stringpool-memory-dist,
+                   store-stringpool-xa-dist, tag-dist,
+                   tuples-dist, tuples-hybrid-dist,
+                   util-dist, util-xa-dist"
+          description="Creates the distribution base jars">
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Creates the distribution files                                      -->
+  <!-- =================================================================== -->
+  <!-- Removed server-local, jrdf -->
+  <target name="dist"
+          depends="itql-dist, driver-dist, descriptor-dist, mulgara-war,
+                   embedded-dist, lite-dist"
+          description="Creates the distribution files">
+
+    <copy file="${bin.dir}/${mulgara.war}" tofile="${dist.dir}/${mulgara.war}"/>
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Creates the distribution of documentation files                     -->
+  <!-- =================================================================== -->
+  <target name="dist-website" depends="javadoc, javadoc-dist, webpage-includes"
+    description="Creates the distribution of documentation files">
+
+    <mkdir dir="${dist.docs.dir}"/>
+    <mkdir dir="${dist.api.dir}"/>
+
+    <!-- copy the documentation -->
+    <copy todir="${dist.docs.dir}">
+      <fileset dir="${src.docs.dir}"/>
+    </copy>
+
+    <!-- copy the API -->
+    <copy todir="${dist.api.dir}">
+      <fileset dir="${javadoc.dir}"/>
+    </copy>
+
+
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Creates and copies the core Mulgara files to a single directory      -->
+  <!-- =================================================================== -->
+  <target name="core" depends="dist"
+    description="Creates and then copies the core Mulgara files to a single directory.">
+
+    <!-- webservices.war -->
+    <copy file="${obj.dir}/war/webservices.war" todir="${core.dir}"/>
+
+    <!-- jars for webui war -->
+    <copy file="${obj.dir}/war/webui/jars/${webui-logic.jar}" todir="${core.dir}"/>
+    <copy file="${obj.dir}/war/webui/jars/${webui-barracuda.jar}" todir="${core.dir}"/>
+
+    <!-- driver jar for clients -->
+    <copy file="${dist.dir}/${driver.jar}" todir="${core.dir}"/>
+
+    <!-- ant task jar -->
+    <copy file="${ant-task.dist.dir}/${ant-task.jar}" todir="${core.dir}"/>
+
+    <copy todir="${core.dir}">
+      <fileset dir="${bin.dir}">
+        <include name="*.jar"/>
+      </fileset>
+    </copy>
+
+    <!-- generate the client side java doc -->
+    <antcall target="javadoc"/>
+    <copy todir="${core-javadoc.dir}">
+      <fileset dir="${javadoc.dir}">
+        <include name="*/**"/>
+      </fileset>
+    </copy>
+
+    <!-- jxunit tests -->
+    <mkdir dir="${core.dir}/jxdata/iTQL/"/>
+    <copy todir="${core.dir}/jxdata/iTQL">
+      <fileset dir="${jxdata.dir}/iTQL"/>
+    </copy>
+
+    <!-- resolver example -->
+    <mkdir dir="${core.dir}/example/resolver"/>
+    <copy todir="${core.dir}/example/resolver">
+      <fileset dir="${resolver-http.src.dir}">
+        <include name="**/*.*"/>
+        <exclude name="**/*UnitTest.java"/>
+      </fileset>
+    </copy>
+
+    <!-- content handler example -->
+    <mkdir dir="${core.dir}/example/handler"/>
+    <copy todir="${core.dir}/example/handler">
+      <fileset dir="${content-mp3.src.dir}">
+        <include name="**/*.*"/>
+        <exclude name="**/*UnitTest.java"/>
+      </fileset>
+    </copy>
+
+    <mkdir dir="${core.dir}/example/conf/handler"/>
+    <copy todir="${core.dir}/example/conf/handler">
+      <fileset dir="${content-mp3.conf.dir}" includes="**/parserfactory.conf"/>
+    </copy>
+
+    <move todir="${core.dir}/example/resolver/java">
+      <fileset dir="${core.dir}/example/handler" includes="**/compile-resolver.list"/>
+    </move>
+
+    <move todir="${core.dir}/example/handler/java">
+      <fileset dir="${core.dir}/example/handler" includes="**/compile-handler.list"/>
+    </move>
+
+    <move todir="${core.dir}/example">
+      <fileset dir="${core.dir}/example/handler" includes="**/build-tutorial.*"/>
+    </move>
+
+    <!-- Library jars -->
+    <mkdir dir="${core.dir}/example/lib"/>
+    <copy todir="${core.dir}/example/lib">
+      <fileset dir="${lib.dir}" includes="${jid3.jar}"/>
+    </copy>
+
+    <delete>
+      <fileset dir="${core.dir}/example/handler" includes="*build*.*"/>
+    </delete>
+    <delete>
+      <fileset dir="${core.dir}/example/resolver" includes="*build*.*"/>
+    </delete>
+
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Generates a manifest file for the Mulgara executable project JAR        -->
+  <!-- =================================================================== -->
+  <target name="lite-create-manifest" depends="-prepare-build">
+    <mkdir dir="${obj.dir}/META-INF"/>
+
+    <!-- generate the core manifest -->
+    <manifest file="${obj.dir}/META-INF/MANIFEST_Mulgara_BASE.MF">
+      <attribute name="Main-Class" value="org.mulgara.triplestore.Main"/>
+    </manifest>
+
+    <!-- generate the bootstrap manifest -->
+    <manifest file="${obj.dir}/META-INF/MANIFEST_Mulgara_Lite_BOOTSTRAP.MF">
+
+      <attribute name="Main-Class" value="org.mulgara.util.Bootstrap"/>
+      <attribute name="Embedded-Jar" value="
+          lib/${query.jar}, lib/${driver.jar}, lib/${itql.jar}, lib/${sparql-int.jar},
+          lib/${rmi.jar},
+          lib/${server.jar}, lib/${server-beep.jar}, lib/${server-rmi.jar},
+          lib/${util.jar}, lib/${config.jar}, lib/${descriptor.jar}, lib/${server-local.jar},
+          lib/${resolver.jar}, lib/${resolver-spi.jar}, lib/${resolver-filesystem.jar},
+          lib${store.jar}, lib/${store-xa.jar}, lib/${rules.jar},
+          lib/${store-nodepool.jar}, lib/${store-nodepool-xa.jar},
+          lib/${store-nodepool-memory.jar}, lib/${store-stringpool.jar}
+          lib/${store-stringpool-xa.jar},
+          lib/${store-stringpool-memory.jar}, lib/${util-xa.jar}, lib/${resolver-null.jar}, lib/${resolver-file.jar},
+          lib/${resolver-http.jar}, lib/${resolver-lucene.jar}, lib/${resolver-memory.jar},
+          lib/${resolver-store.jar}, lib/${resolver-url.jar}, lib/${resolver-view.jar},
+          lib/${tuples.jar}, lib/${tuples-hybrid.jar}, lib/${content-mp3.jar},
+          lib/${content-n3.jar}, lib/${content-mbox.jar}, lib/${content-rdfxml.jar},
+          lib/${content-rio.jar}, lib/${resolver-nodetype.jar}, lib/${resolver-prefix.jar},
+          lib/${resolver-relational.jar}, lib/${resolver-xsd.jar}, lib/${resolver-test.jar},
+          lib/${resolver-distributed.jar},
+          lib/${resolver-jar.jar}, lib/${dtd.jar}, lib/${jrdf.base.jar}
+          lib/activation-1.0.2.jar, lib/icu4j.jar, lib/jena-2.1.jar, lib/antlr.jar,
+          lib/${joda-time.jar}, lib/${commons-logging.jar}, lib/beepcore-0.9.08.jar, lib/log4j-1.2.15.jar, lib/${lucene.jar}, lib/mail-1.3.jar,
+          lib/${jetty.jar}, lib/${jetty.plus.jar}, lib/${jasper.compiler.jar}, lib/${servlet.jar}, lib/jargs-0.2.jar,
+          lib/${castor-xml.jar}, lib/${castor-codegen.jar}, lib/${castor-xml-schema.jar}, lib/trove-1.0.2.jar, lib/${jrdf.jar}, lib/${saaj.jar},
+          lib/${jakarta-oro.jar}, lib/jta-spec1_0_1.jar, lib/${jotm.jar}, lib/${jotm.jrmp.jar}, lib/${carol.jar}, lib/${howl.jar},
+          lib/${jca.jar}, lib/${httpclient.jar}, lib/${commons-codec.jar}, lib/${mulgara-sparql.jar}"/>
+      <attribute name="Embedded-Main-Class" value="org.mulgara.server.EmbeddedMulgaraServer"/>
+    </manifest>
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Creates the lite distribution file for the Embedded Mulgara server   -->
+  <!-- =================================================================== -->
+  <target name="lite-dist"
+          depends="driver-jar, itql-jar, sparql-int-jar, rules-jar, query-jar, rmi-jar,
+                   server-jar, server-local-jar, server-beep-jar,
+                   server-rmi-jar, util-jar, config-jar, dtd-jar, jrdf-jar, ant-task-jar,
+                   store-dist, store-xa-dist, store-nodepool-dist,
+                   store-nodepool-xa-dist,
+                   store-nodepool-memory-dist,
+                   store-stringpool-dist,
+                   store-stringpool-xa-dist,
+                   store-stringpool-memory-dist, tuples-dist, tuples-hybrid-dist, resolver-null-dist,
+                   resolver-file-dist, resolver-filesystem-dist, resolver-distributed-dist,
+                   resolver-http-dist, resolver-lucene-dist, resolver-relational-dist,
+                   resolver-memory-dist, resolver-nodetype-dist, resolver-prefix-dist,
+                   resolver-store-dist, resolver-url-dist, resolver-jar-dist,
+                   resolver-view-dist, resolver-xsd-dist,
+                   content-mbox-dist, content-mp3-dist, content-n3-dist,
+                   content-rdfxml-dist, content-rio-dist,
+                   lite-create-manifest, javadoc-dist,
+                   lite-dist-uptodate, webpage-includes"
+          unless="dist.lite.uptodate"
+          description="Creates the executable JAR for the Embedded Mulgara Lite
+                       server">
+
+    <!-- HACK!!!!! -->
+    <!-- This will get the ARP parser working -->
+    <mkdir dir="${obj.dir}/xerces"/>
+
+    <unjar src="${lib.dir}/xercesImpl.jar" dest="${obj.dir}/xerces"/>
+    <unjar src="${lib.dir}/xmlParserAPIs.jar" dest="${obj.dir}/xerces"/>
+    <unjar src="${lib.dir}/jsr173_07_api.jar" dest="${obj.dir}/xerces"/>
+    <unjar src="${lib.dir}/jsr173_07_ri.jar" dest="${obj.dir}/xerces"/>
+    <!-- HACK!!!!! -->
+
+    <!-- build the executable jar file -->
+    <jar jarfile="${dist.dir}/${mulgara-lite.jar}"
+        manifest="${obj.dir}/META-INF/MANIFEST_Mulgara_Lite_BOOTSTRAP.MF">
+
+      <zipfileset dir="${conf.dir}" prefix="conf"
+          includes="log4j-mulgara.xml, webdefault.xml, mulgara-rmi.policy,
+                    mulgara.policy"/>
+      <zipfileset dir="${lib.dir}" prefix="lib" includes="
+        ${log4j.jar}, ${icu4j.jar}, ${activation.jar}, ${beep.jar},
+        ${jargs.jar}, ${jrdf.jar}, ${jetty.jar}, ${jetty.plus.jar},
+        ${servlet.jar}, ${jasper.runtime.jar}, ${jasper.compiler.jar},
+        ${lucene.jar}, ${mail.jar}, ${castor-xml.jar}, ${castor-xml-schema.jar}, ${castor-codegen.jar}, ${trove.jar},
+        ${joda-time.jar}, ${commons-logging.jar}, ${commons-httpclient.jar},
+        ${commons-codec.jar}, ${emory-util.jar}, ${mulgara-sparql.jar}
+        ${jotm.jar}, ${jotm.jrmp.jar}, ${carol.jar}, ${howl.jar}, ${jta.jar},
+        ${jsr.173.api.jar}, ${jsr.173.ri.jar}, ${jca.jar}, ${saaj.jar},
+        ${axis.jar}, ${commons-discovery.jar}, ${jaxrpc.jar}, ${wsdl4j.jar},
+        ${jena.jar}, ${antlr.jar}, ${jakarta-oro.jar}, {jid3.jar}"/>
+      <zipfileset dir="${lib.dir}" prefix="lib" includes="${saaj.jar},
+                       ${axis.jar}, ${commons-discovery.jar},
+                       ${jaxrpc.jar}, ${wsdl4j.jar}"/>
+      <zipfileset dir="${bin.dir}" prefix="lib" includes="
+          ${query.jar}, ${driver.jar}, ${itql.jar}, ${sparql-int.jar},
+          ${rules.jar}, ${rmi.jar},
+          ${server.jar}, ${server-beep.jar}, ${server-rmi.jar},
+          ${util.jar}, ${config.jar}, ${descriptor.jar}, ${server-local.jar},
+          ${resolver.jar}, ${resolver-spi.jar}, ${resolver-filesystem.jar},
+          ${store.jar}, ${store-xa.jar},
+          ${store-nodepool.jar}, ${store-nodepool-xa.jar}, ${store-stringpool.jar},
+          ${store-stringpool-xa.jar}, ${store-nodepool-memory.jar}, ${resolver-null.jar},
+          ${store-stringpool-memory.jar}, ${util-xa.jar}, ${resolver-file.jar},
+          ${resolver-http.jar}, ${resolver-lucene.jar}, ${resolver-memory.jar},
+          ${resolver-store.jar}, ${resolver-url.jar}, ${resolver-view.jar},
+          ${tuples.jar}, ${tuples-hybrid.jar}, ${content-mp3.jar},
+          ${content-n3.jar}, ${content-mbox.jar}, ${content-rdfxml.jar},
+          ${content-rio.jar}, ${resolver-nodetype.jar}, ${resolver-prefix.jar},
+          ${resolver-xsd.jar}, ${resolver-test.jar}, ${resolver-relational.jar},
+          ${resolver-distributed.jar},
+          ${resolver-jar.jar}, ${dtd.jar}, ${jrdf.base.jar}"/>
+
+      <!-- Schemas -->
+      <zipfileset dir="${basedir}/data" prefix="data"
+          includes="mulgara.rdfs"/>
+
+      <zipfileset dir="${src.docs.dir}" prefix="docs"
+          includes="**/*.html, **/*.htm, **/*.gif, **/*.png, **/*.jpg, **/*.css, **/images/*, **/images/icons/*"/>
+      <zipfileset file="${obj.dir}/mulgara-x-config.xml" prefix="conf" />
+
+      <fileset dir="${obj.dir}/jar/util/classes" includes="**/Bootstrap.class"/>
+      <fileset dir="${src.dir}/jar/dtd" includes="META-INF/**, DTD/**"/>
+
+      <!-- HACK!!!!! -->
+      <!-- This will get the ARP parser working -->
+      <!-- Ignore the xerces DocumentBuilderFactory -->
+      <fileset dir="${obj.dir}/xerces" excludes="META_INF/**"/>
+
+      <!-- HACK!!!!! -->
+
+    </jar>
+
+  </target>
+
+  <!-- do a check for any changes made to the mulgara build -->
+  <!-- potentially not the most efficient checking performed -->
+  <target name="lite-dist-uptodate">
+
+    <uptodate property="dist.lite.uptodate"
+       targetfile="${dist.dir}/${mulgara-lite.jar}">
+
+     <srcfiles dir="${bin.dir}" includes="**/*"/>
+     <srcfiles dir="${conf.dir}" includes="**/*"/>
+     <srcfiles dir="${lib.dir}" includes="**/*"/>
+     <srcfiles dir="${data.dir}" includes="**/*"/>
+     <srcfiles dir="${template.src.docs.dir}" includes="**/*"/>
+    </uptodate>
+  </target>
+
+
+  <!-- =================================================================== -->
+  <!-- Generate the doclet to support custom @-tags in Mulgara javadoc      -->
+  <!-- =================================================================== -->
+  <target name="doclet.jar"
+          depends="javadoc-version, doclet-compile, doclet141-compile">
+
+    <mkdir dir="${bin.dir}"/>
+
+    <jar jarfile="${bin.dir}/doclet.jar">
+      <fileset dir="${obj.dir}/jar/doclet/classes"/>
+    </jar>
+  </target>
+
+  <target name="javadoc-version">
+
+    <condition property="javadoc1.4.1">
+      <contains string="${java.version}" substring="1.4.1"/>
+    </condition>
+  </target>
+
+  <target name="doclet-compile" unless="javadoc1.4.1">
+
+    <mkdir dir="${obj.dir}/jar/doclet/classes"/>
+
+    <javac destdir="${obj.dir}/jar/doclet/classes"
+           classpath="${java.class.path}"
+           debug="on" deprecation="on">
+      <src path="${src.dir}/jar/doclet/java"/>
+    </javac>
+  </target>
+
+  <target name="doclet141-compile" if="javadoc1.4.1">
+
+    <mkdir dir="${obj.dir}/jar/doclet/classes"/>
+
+    <javac destdir="${obj.dir}/jar/doclet/classes"
+           classpath="${java.class.path}"
+           debug="on" deprecation="on">
+      <src path="${src.dir}/jar/doclet141/java"/>
+    </javac>
+  </target>
+
+
+  <!-- =================================================================== -->
+  <!-- Translate XHTML+MathML into printable XHTML                         -->
+  <!-- =================================================================== -->
+  <target name="docs" depends="javadoc-dist,webpage-includes" description="Generate documentation">
+
+    <style basedir="${src.docs.dir}"
+           destdir="${src.docs.dir}"
+           extension="-toc.xml"
+           style="toc.xsl"
+           includes="model.xml"
+           excludes="*-toc.xml"/>
+    <!--
+    <style basedir="${src.docs.dir}"
+           destdir="${src.docs.dir}"
+           style="mathml.xsl"
+           includes="*.xml"/>
+    -->
+  </target>
+
+  <!-- ==================================================================== -->
+  <!-- Formats all source files                                             -->
+  <!-- ==================================================================== -->
+  <target name="format" depends="jalopy">
+
+    <!--
+      Invokes Jalopy as follows:
+
+      - All formatted files will have unix fileformat (\n)
+      - Load your code convention from the given url
+      - Override the convention to use the file history feature
+      - Override the convention to use alder32 checksums of files for history testing
+      - Override the convention to use loglevel "info"
+      - Override the convention to use 2 threads
+      - The import optimization feature will work (if enabled in the active
+        convention), because a classpath reference is specified
+
+        Don't forget to setup an include pattern as Jalopy truly expects
+        valid Java source files as input!
+      -->
+    <jalopy fileformat="unix"
+            convention="${src.dir}/mulgara.xml"
+            history="file"
+            historymethod="adler32"
+            loglevel="info"
+            threads="2"
+            classpathref="project-classpath">
+
+      <fileset dir="${src.dir}">
+        <include name="**/*.java" />
+      </fileset>
+    </jalopy>
+  </target>
+
+  <!-- ================================================================== -->
+  <!-- Prints help information                                            -->
+  <!-- ================================================================== -->
+  <target name="help" description="Print this help message">
+    <echo message="Welcome to the build script for the ${description}"/>
+    <echo message="These targets can be invoked as follows:"/>
+    <echo message="  ./build.sh &lt;target&gt;"/>
+    <echo message=""/>
+    <java fork="false" classname="org.apache.tools.ant.Main"
+          newenvironment="false">
+      <jvmarg value="${arch.bits}"/>
+      <arg line="-buildfile build.xml -projecthelp"/>
+    </java>
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Generates all javadoc for the project                               -->
+  <!-- =================================================================== -->
+  <target name="javadoc"
+    depends="javadoc-uptodate, javadoc-overview.html,
+             ant-task-jar, client-jrdf-jar, config-jar,
+             content-mbox-jar, content-mp3-jar,
+             content-n3-jar, content-rdfxml-jar, content-rio-jar,
+             itql-jar, sparql-int-jar,
+             doclet.jar, jrdf-jar, store-jar,
+             store-xa-jar,
+             store-nodepool-jar, store-nodepool-memory-jar,
+             store-nodepool-xa-jar, query-jar,
+             resolver-jar, resolver-null-jar, resolver-file-jar, resolver-filesystem-jar,
+             resolver-http-jar, resolver-lucene-jar, resolver-memory-jar,
+             resolver-spi-jar, resolver-store-jar,
+             resolver-url-jar, resolver-view-jar, resolver-xsd-jar,
+             resolver-test-jar,
+             server-jar, server-beep-jar, server-rmi-jar,
+             sofa-jar, krule-jar, rules-jar, sparql-protocol-jar,
+             store-stringpool-jar,
+             store-stringpool-memory-jar, store-stringpool-xa-jar,
+             tuples-jar, tuples-hybrid-jar, util-jar, util-xa-jar, webui-war"
+    unless="javadoc-uptodate"
+    description="Creates the project javadoc">
+    <delete dir="${javadoc.dir}"/>
+    <mkdir dir="${javadoc.dir}"/>
+    <javadoc destdir="${javadoc.dir}"
+        packagenames="org.mulgara.ant.*,
+                      org.mulgara.barracuda.*,
+                      org.mulgara.beep.*,
+                      org.mulgara.client.*,
+                      org.mulgara.config,
+                      org.mulgara.content.*,
+                      org.mulgara.connection.*,
+                      org.mulgara.driver.*,
+                      org.mulgara.extractor.tag,
+                      org.mulgara.itql,
+                      org.mulgara.jrdf,
+                      org.mulgara.local.*,
+                      org.mulgara.query.*,
+                      org.mulgara.rdf,
+                      org.mulgara.resolver.*,
+                      org.mulgara.rmi.*,
+                      org.mulgara.server.*,
+                      org.mulgara.sofa.*,
+                      org.mulgara.krule.*,
+                      org.mulgara.rules.*,
+                      org.mulgara.sparql.*,
+                      org.mulgara.store.*,
+                      org.mulgara.store.graph.*,
+                      org.mulgara.store.graph.xa.*,
+                      org.mulgara.store.jxunit.*,
+                      org.mulgara.store.loader.*,
+                      org.mulgara.store.nodepool.*,
+                      org.mulgara.store.nodepool.memory.*,
+                      org.mulgara.store.nodepool.xa.*,
+                      org.mulgara.store.stringpool.*,
+                      org.mulgara.store.stringpool.memory.*,
+                      org.mulgara.store.stringpool.xa.*,
+                      org.mulgara.store.tuples.*,
+                      org.mulgara.store.xa.*,
+                      org.mulgara.webui.*,
+                      org.mulgara.util,
+                      org.mulgara.xml.*"
+        private="true"
+        overview="${obj.dir}/docs/overview.html"
+        windowtitle="${description} ${mulgara-version} API"
+        doctitle="${description} ${mulgara-version} API"
+        version="true"
+        use="true"
+        bottom="Copyright &amp;copy; ${year} Tucana Technologies, Inc. (http://www.tucanatech.com/)."
+        author="true"
+        additionalParam="-breakiterator -source 1.5">
+      <tag name="company" description="Company:"/>
+      <tag name="copyright" description="Copyright:"/>
+      <tag name="created" description="Creation date:"/>
+      <tag name="licence" description="Licence:"/>
+      <taglet name="org.mulgara.doclet.MaintenanceAuthorTaglet"
+        path="${bin.dir}/doclet.jar"/>
+      <taglet name="org.mulgara.doclet.ModifiedTaglet"
+        path="${bin.dir}/doclet.jar"/>
+      <taglet name="org.mulgara.doclet.VersionTaglet"
+        path="${bin.dir}/doclet.jar"/>
+      <classpath refid="project-classpath"/>
+      <classpath path="${lib.dir}/antlr.jar"/>
+      <classpath path="${lib.dir}/barracuda-1.2.6.jar"/>
+      <classpath path="${lib.dir}/beepcore-0.9.08.jar"/>
+      <classpath path="${lib.dir}/javax.servlet-2.3.jar"/>
+      <classpath path="${lib.dir}/${jid3.jar}"/>
+      <classpath path="${lib.dir}/jsr173_07_api.jar"/>
+      <classpath path="${lib.dir}/${lucene.jar}"/>
+      <classpath path="${lib.dir}/${sofa.jar}"/>
+      <classpath path="${lib.dir}/xmlc-all-runtime-2.2.jar"/>
+      <classpath path="${lib.dir}/xom-1.0d21.jar"/>
+      <sourcepath path="${ant-task.src.dir}/java"/>
+      <sourcepath path="${client-jrdf.src.dir}/java"/>
+      <sourcepath path="${content-mp3.src.dir}/java"/>
+      <sourcepath path="${content-n3.src.dir}/java"/>
+      <sourcepath path="${content-rdfxml.src.dir}/java"/>
+      <sourcepath path="${content-rio.src.dir}/java"/>
+      <sourcepath path="${driver.src.dir}/java"/>
+      <sourcepath path="${dtd.src.dir}/java"/>
+      <sourcepath path="${itql.src.dir}/java"/>
+      <sourcepath path="${jrdf.src.dir}/java"/>
+      <sourcepath path="${krule.src.dir}/java"/>
+      <sourcepath path="${rules.src.dir}/java"/>
+      <sourcepath path="${query.src.dir}/java"/>
+      <!--sourcepath path="${rdql.src.dir}/java"/-->
+      <sourcepath path="${resolver.src.dir}/java"/>
+      <sourcepath path="${resolver-null.src.dir}/java"/>
+      <sourcepath path="${resolver-file.src.dir}/java"/>
+      <sourcepath path="${resolver-filesystem.src.dir}/java"/>
+      <sourcepath path="${resolver-jar.src.dir}/java"/>
+      <sourcepath path="${resolver-http.src.dir}/java"/>
+      <sourcepath path="${resolver-lucene.src.dir}/java"/>
+      <sourcepath path="${resolver-url.src.dir}/java"/>
+      <sourcepath path="${resolver-memory.src.dir}/java"/>
+      <sourcepath path="${resolver-spi.src.dir}/java"/>
+      <sourcepath path="${resolver-store.src.dir}/java"/>
+      <sourcepath path="${resolver-view.src.dir}/java"/>
+      <sourcepath path="${resolver-xsd.src.dir}/java"/>
+      <sourcepath path="${resolver-test.src.dir}/java"/>
+      <sourcepath path="${server.src.dir}/java"/>
+      <sourcepath path="${server-beep.src.dir}/java"/>
+      <sourcepath path="${server-rmi.src.dir}/java"/>
+      <sourcepath path="${sofa.src.dir}/java"/>
+      <sourcepath path="${sparql-protocol.src.dir}/java"/>
+      <sourcepath path="${sparql-int.src.dir}/java"/>
+      <sourcepath path="${store.src.dir}/java"/>
+      <sourcepath path="${store-xa.src.dir}/java"/>
+      <sourcepath path="${store-nodepool.src.dir}/java"/>
+      <sourcepath path="${store-nodepool-memory.src.dir}/java"/>
+      <sourcepath path="${store-nodepool-xa.src.dir}/java"/>
+      <sourcepath path="${store-stringpool.src.dir}/java"/>
+      <sourcepath path="${store-stringpool-memory.src.dir}/java"/>
+      <sourcepath path="${store-stringpool-xa.src.dir}/java"/>
+      <sourcepath path="${tuples.src.dir}/java"/>
+      <sourcepath path="${tuples-hybrid.src.dir}/java"/>
+      <sourcepath path="${util.src.dir}/java"/>
+      <sourcepath path="${util-xa.src.dir}/java"/>
+      <sourcepath path="${webui.src.dir}/java"/>
+      <sourcepath path="${obj.dir}/jar/config/java"/>
+      <sourcepath path="${obj.dir}/jar/itql/java"/>
+      <sourcepath path="${obj.dir}/jar/query/java"/>
+      <!--sourcepath path="${obj.dir}/jar/rdql/java"/-->
+      <sourcepath path="${obj.dir}/jar/util/java"/>
+      <sourcepath path="${obj.dir}/war/webui/java"/>
+      <link href="${j2ee.javadoc}"/>
+      <link href="${java.javadoc}"/>
+      <link href="${jrdf.javadoc}"/>
+    </javadoc>
+  </target>
+
+  <target name="javadoc-dist"
+          if="distjavadoc">
+
+    <antcall target="create-javadoc"/>
+  </target>
+
+  <!-- If and depends are not compatible so we have to approach javadoc in
+       two steps -->
+  <target name="create-javadoc"
+          depends="javadoc-uptodate, javadoc-overview.html, doclet.jar,
+                   ant-task-javadoc,
+                   client-jrdf-javadoc,
+                   content-mbox-javadoc,
+                   content-mp3-javadoc, content-n3-javadoc,
+                   content-rdfxml-javadoc, content-rio-javadoc,
+                   descriptor-javadoc, driver-javadoc, dtd-javadoc,
+                   itql-javadoc, sparql-int-javadoc,
+                   store-javadoc, store-xa-javadoc,
+                   store-nodepool-javadoc,
+                   store-nodepool-memory-javadoc, jrdf-javadoc,
+                   store-nodepool-xa-javadoc, query-javadoc,
+                   resolver-filesystem-javadoc, resolver-null-javadoc,
+                   resolver-file-javadoc, resolver-http-javadoc,
+                   resolver-lucene-javadoc, resolver-memory-javadoc,
+                   resolver-spi-javadoc, resolver-distributed-javadoc,
+                   resolver-store-javadoc, resolver-url-javadoc, resolver-view-javadoc,
+                   resolver-nodetype-javadoc, resolver-prefix-javadoc, resolver-xsd-javadoc,
+                   resolver-test-javadoc, resolver-javadoc, resolver-relational-javadoc,
+                   server-beep-javadoc, server-http-javadoc,
+                   server-local-javadoc, server-rmi-javadoc, server-javadoc,
+                   sofa-javadoc, rules-javadoc, krule-javadoc,
+                   store-stringpool-javadoc,
+                   store-stringpool-memory-javadoc, store-stringpool-xa-javadoc,
+                   tag-javadoc, tuples-hybrid-javadoc, tuples-javadoc,
+                   util-xa-javadoc, util-javadoc"
+      unless="javadoc.uptodate"
+      description="creates project javadoc documentation">
+  </target>
+
+  <target name="javadoc-overview.html">
+
+    <style in    ="build.xml"
+           style ="docs/overview.xsl"
+           out   ="${obj.dir}/docs/overview.html"/>
+  </target>
+
+  <target name="javadoc-uptodate">
+
+    <uptodate property="javadoc.uptodate"
+        targetfile="${javadoc.dir}/package-list">
+
+      <srcfiles dir="${src.dir}" includes="**/*.java, **/package.html"/>
+      <srcfiles dir="docs" includes="overview.xsl"/>
+    </uptodate>
+  </target>
+
+  <target name="jrdf-example" description="Runs the JRDF memory example">
+
+     <java classname="org.jrdf.graph.mem.JRDFExample" fork="no" failonerror="yes"
+        jvm="${java.home}/bin/java" dir="${basedir}">
+
+        <jvmarg value="${arch.bits}"/>
+
+        <classpath>
+            <pathelement path="${lib.dir}/${jrdf.jar}"/>
+        </classpath>
+      </java>
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Create config file for Log4J for each developer                     -->
+  <!-- =================================================================== -->
+  <target name="log4j-conf.xml">
+
+    <copy file="${conf.dir}/log4j-template.xml"
+      tofile="${basedir}/log4j-conf.xml"/>
+  </target>
+
+  <target name="model.html">
+
+    <style basedir="${template.src.docs.dir}"
+           destdir="${template.src.docs.dir}"
+           style="mathml.xsl"
+           includes="model.xml"/>
+  </target>
+
+
+  <!-- =================================================================== -->
+  <!-- Create JAR for use as the RMI codebase                              -->
+  <!-- =================================================================== -->
+  <target name="rmi-jar"
+          depends="query-jar, driver-jar, server-jar, util-jar,
+                   rmi-jar-uptodate"
+          unless="rmi.jar.uptodate">
+
+    <jar jarfile="${bin.dir}/${rmi.jar}">
+
+      <fileset dir="${obj.dir}/jar/query/classes"/>
+      <fileset dir="${obj.dir}/jar/driver/classes"/>
+      <fileset dir="${obj.dir}/jar/server/classes"/>
+      <fileset dir="${obj.dir}/jar/util/classes"/>
+    </jar>
+  </target>
+
+  <target name="rmi-jar-uptodate">
+
+    <uptodate property="rmi.jar.uptodate"
+              targetfile="${bin.dir}/${rmi.jar}">
+
+      <srcfiles dir="${obj.dir}/jar/query/classes" includes="**/*"/>
+      <srcfiles dir="${obj.dir}/jar/driver/classes" includes="**/*"/>
+      <srcfiles dir="${obj.dir}/jar/server/classes" includes="**/*"/>
+      <srcfiles dir="${obj.dir}/jar/util/classes" includes="**/*"/>
+    </uptodate>
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Starts the iTQL command line tool                                   -->
+  <!-- =================================================================== -->
+  <target name="run-itql" depends="itql-dist, uri">
+
+    <java classname="org.mulgara.itql.ItqlSession"
+          failonerror="yes">
+
+      <jvmarg value="${arch.bits}"/>
+
+      <sysproperty key="java.io.tmpdir" value="${tmp.dir}"/>
+      <sysproperty key="log4j.configuration"
+                   value="${baseuri}/conf/log4j-tql.xml"/>
+
+      <classpath>
+
+        <pathelement path="${bin.dir}/${query.jar}"/>
+        <pathelement path="${bin.dir}/${driver.jar}"/>
+        <pathelement path="${bin.dir}/${itql.jar}"/>
+        <pathelement path="${bin.dir}/${rules.jar}"/>
+        <pathelement path="${bin.dir}/${server.jar}"/>
+        <pathelement path="${bin.dir}/${server-http.jar}"/>
+        <pathelement path="${bin.dir}/${server-local.jar}"/>
+        <pathelement path="${bin.dir}/${server-rmi.jar}"/>
+        <pathelement path="${bin.dir}/${server-beep.jar}"/>
+        <pathelement path="${bin.dir}/${util.jar}"/>
+
+        <fileset dir="${lib.dir}"
+                 includes="activation*.jar, beepcore-*.jar, jargs-*.jar,
+                           icu4j.jar, jena*.jar, antlr*.jar,
+                           ${commons-logging.jar}, log4j*.jar, lucene*.jar,
+                           xerces*.jar, xmlParserAPIs.jar, ${jrdf.jar},
+                           ${saaj.jar}"/>
+      </classpath>
+    </java>
+
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Starts multiple embedded Mulgara servers                             -->
+  <!-- =================================================================== -->
+  <target name="start-instance"
+     description="Starts an embedded Mulgara server">
+
+    <echo>
+      Starting embedded Mulgara ${server.instance} server on ${os.name} with
+      output to ${dist.dir}/mulgara-output-${server.instance}
+    </echo>
+
+    <!-- create a temporary directory for this server instance -->
+    <mkdir dir="${tmp.dir}/${server.instance}"/>
+
+    <!-- prepare a log4j file for server instance -->
+    <copy file="${conf.dir}/log4j-instance.xml"
+      tofile="${dist.dir}/log4j-instance-${server.instance}.xml"/>
+
+    <replace file="${dist.dir}/log4j-instance-${server.instance}.xml"
+       token="@server.instance@" value="${server.instance}"/>
+
+    <exec os="Linux" executable="${scripts.dir}/bg.linux" failonerror="yes">
+
+      <arg value="-o"/>
+      <arg value="${dist.dir}/mulgara-output-${server.instance}"/>
+      <arg value="${java.home}/bin/java"/>
+      <arg line="-Djava.io.tmpdir=&quot;${tmp.dir}/${server.instance}&quot;"/>
+      <arg line="-Dshutdownhook.port=689${server.instance}"/>
+      <arg value="-jar"/>
+      <arg value="${dist.dir}/${mulgara.version.to.run}"/>
+      <arg value="-a"/>
+      <arg value="${test.dir}"/>
+      <arg value="-s"/>
+      <arg value="server${server.instance}"/>
+      <arg value="-p"/>
+      <arg value="808${server.instance}"/>
+      <arg value="-l"/>
+      <arg value="file:${dist.dir}/log4j-instance-${server.instance}.xml"/>
+    </exec>
+
+    <exec os="SunOS" executable="${scripts.dir}/bg.sh" failonerror="yes">
+
+      <arg value="-o"/>
+      <arg value="${dist.dir}/mulgara-output-${server.instance}"/>
+      <arg value="${java.home}/bin/java"/>
+      <arg value="${arch.bits}"/>
+      <arg line="-Djava.io.tmpdir=&quot;${tmp.dir}/${server.instance}&quot;"/>
+      <arg line="-Dshutdownhook.port=689${server.instance}"/>
+      <arg value="-jar"/>
+      <arg value="${dist.dir}/${mulgara.version.to.run}"/>
+      <arg value="-a"/>
+      <arg value="${test.dir}"/>
+      <arg value="-s"/>
+      <arg value="server${server.instance}"/>
+      <arg value="-p"/>
+      <arg value="808${server.instance}"/>
+      <arg value="-l"/>
+      <arg value="file:${dist.dir}/log4j-instance-${server.instance}.xml"/>
+    </exec>
+
+    <exec os="Mac OS X" executable="${scripts.dir}/bg.sh" failonerror="yes">
+
+      <arg value="-o"/>
+      <arg value="${dist.dir}/mulgara-output-${server.instance}"/>
+      <arg value="${java.home}/bin/java"/>
+      <arg line="-Djava.io.tmpdir=&quot;${tmp.dir}/${server.instance}&quot;"/>
+      <arg line="-Dshutdownhook.port=689${server.instance}"/>
+      <arg value="-jar"/>
+      <arg value="${dist.dir}/${mulgara.version.to.run}"/>
+      <arg value="-a"/>
+      <arg value="${test.dir}"/>
+      <arg value="-s"/>
+      <arg value="server${server.instance}"/>
+      <arg value="-p"/>
+      <arg value="808${server.instance}"/>
+      <arg value="-l"/>
+      <arg value="file:${dist.dir}/log4j-instance-${server.instance}.xml"/>
+    </exec>
+
+    <exec os="Windows NT,Windows 2000,Windows XP, Windows 2003" executable="${scripts.dir}\bg.exe"
+        failonerror="yes">
+
+      <arg value="-o"/>
+      <arg value="${dist.dir}/mulgara-output-${server.instance}"/>
+      <arg value="${java.home}/bin/java"/>
+      <arg line="-Djava.io.tmpdir=&quot;${tmp.dir}/${server.instance}&quot;"/>
+      <arg line="-Dshutdownhook.port=689${server.instance}"/>
+      <arg value="-jar"/>
+      <arg value="${dist.dir}/${mulgara.version.to.run}"/>
+      <arg value="-a"/>
+      <arg value="${test.dir}"/>
+      <arg value="-s"/>
+      <arg value="server${server.instance}"/>
+      <arg value="-p"/>
+      <arg value="808${server.instance}"/>
+      <arg value="-l"/>
+      <arg value="&quot;file:/${dist.dir}/log4j-instance-${server.instance}.xml&quot;"/>
+    </exec>
+
+    <!-- wait for the server to start -->
+    <antcall target="await">
+      <param name="shutdownhook.port" value="689${server.instance}"/>
+    </antcall>
+  </target>
+
+
+  <!-- Run full dist of Mulgara by default unless other (lite) is set -->
+  <target name="set-version-to-run" unless="mulgara.version.to.run.jar">
+
+    <property name="mulgara.version.to.run" value="${mulgara.jar}"/>
+  </target>
+
+
+  <!-- =================================================================== -->
+  <!-- Starts an embedded Mulgara server with profiling (from OptimizeIt)      -->
+  <!-- =================================================================== -->
+  <target name="start-profiled" depends="dist"
+      description="Starts an embedded Mulgara server with profiling (from OptimizeIt)">
+
+    <echo>
+      Starting embedded Mulgara server with profiling (from OptimizeIt) with output to
+      ${dist.dir}/mulgara-output
+    </echo>
+
+    <exec executable="${mulgara-profiled}" failonerror="yes">
+
+      <env key="Mulgara_DIR" path="${dist.dir}"/>
+
+      <arg value="start"/>
+    </exec>
+
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Starts two embedded Mulgara servers                                     -->
+  <!-- =================================================================== -->
+  <target name="start-twoservers"
+      depends="dist, lite-dist, set-version-to-run"
+      description="Starts two embedded Mulgara servers">
+
+    <echo>
+      Starting two embedded Mulgara servers with output to
+      ${dist.dir}/mulgara-output
+    </echo>
+
+    <antcall target="start-instance">
+      <param name="server.instance" value="1"/>
+    </antcall>
+
+    <antcall target="start-instance">
+      <param name="server.instance" value="2"/>
+    </antcall>
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Add the required JARs into the Web Services war file                -->
+  <!-- =================================================================== -->
+  <target name="webservices-war"
+          depends="descriptor-jar, descriptor-add-to-war-dir,
+                   webservices-war-uptodate"
+          unless="webservices.war.uptodate"
+          description="Adds the required jars into the webservices.war file">
+
+    <mkdir dir="${obj.dir}/war/web-services"/>
+
+    <copy todir="${obj.dir}/war/web-services/WEB-INF">
+      <fileset dir="${webservices.src.dir}/WEB-INF" includes="*"/>
+    </copy>
+
+    <replace file="${obj.dir}/war/web-services/WEB-INF/web.xml"
+       token="@@hostname@@" value="${host.name}"/>
+
+    <war warfile="${obj.dir}/war/webservices.war"
+         basedir="${obj.dir}/war/web-services"
+         webxml="${obj.dir}/war/web-services/WEB-INF/web.xml"
+         excludes="WEB-INF/web.xml">
+
+        <!-- AXIS WSDD FILE -->
+        <webinf dir="${webservices.src.dir}/WEB-INF/" includes="server-config.wsdd"/>
+
+        <!-- descriptors -->
+
+        <!-- pre compiled jsps -->
+        <classes dir="${descriptor.war.obj.dir}/classes"
+          includes="**/*.class"/>
+
+        <fileset dir="${obj.dir}/war/"
+          includes="descriptor/descriptors/**/*.xsl"/>
+        <fileset dir="${src.dir}/war/"
+          includes="descriptor/**/*.html, descriptor/**/*.css, descriptor/**/*.jsp"/>
+        <fileset dir="${src.dir}/war/"
+          includes="descriptor/images/**"/>
+        <fileset dir="${src.dir}/war/"
+          includes="descriptor/tutorial/**"/>
+        <fileset dir="${src.dir}/war/"
+          includes="descriptor/examples/**"/>
+        <fileset dir="${src.dir}/war/"
+          includes="descriptor/examples/vcard/**"/>
+
+        <!-- 3rd party -->
+        <lib dir="${lib.dir}" includes="bsf.jar"/>
+        <lib dir="${lib.dir}" includes="js.jar"/>
+
+      </war>
+   </target>
+
+  <!-- =================================================================== -->
+  <!-- Check if the webservices.war file is uptodate                       -->
+  <!-- =================================================================== -->
+   <target name="webservices-war-uptodate">
+
+    <uptodate property="webservices.war.uptodate"
+        targetfile="${obj.dir}/war/webservices.war">
+      <srcfiles dir="${obj.dir}/war/web-services" includes="**/*"/>
+    </uptodate>
+   </target>
+
+  <!-- =================================================================== -->
+  <!-- Stops an embedded Mulgara instance                                   -->
+  <!-- =================================================================== -->
+  <target name="stop-instance" depends="set-version-to-run" description="Stops an embedded Mulgara server">
+
+    <echo message="Stopping embedded Mulgara server instance ${server.instance}"/>
+
+    <java jar="${dist.dir}/${mulgara.version.to.run}" fork="true" failonerror="true">
+
+      <sysproperty key="java.io.tmpdir" value="${tmp.dir}"/>
+      <sysproperty key="shutdownhook.port" value="689${server.instance}"/>
+
+      <jvmarg value="${arch.bits}"/>
+
+      <arg value="-x"/>
+    </java>
+
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Stops two embedded Mulgara servers                                      -->
+  <!-- =================================================================== -->
+  <target name="stop-twoservers" description="Stops the two embedded Mulgara servers">
+
+    <!-- shutdown servers in reverse order. First has the RMI registry -->
+    <echo message="Stopping Mulgara instance servers"/>
+
+    <antcall target="stop-instance">
+      <param name="server.instance" value="2"/>
+    </antcall>
+
+    <antcall target="stop-instance">
+      <param name="server.instance" value="1"/>
+    </antcall>
+
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Unpack, filter and preen test data                                  -->
+  <!-- =================================================================== -->
+  <target name="test-data">
+
+    <filter token="basedir" value="${basedir}"/>
+
+    <copy todir="${test.dir}" filtering="yes">
+      <fileset dir="data" includes="*.itql"/>
+    </copy>
+
+    <mkdir dir="${test.dir}/RDF-Test-Cases"/>
+
+    <unzip src="data/RDF-Test-Cases-2001-09-12.zip" dest="${test.dir}/RDF-Test-Cases"/>
+
+    <mkdir dir="${test.dir}/RDQL"/>
+
+    <unzip src="data/rdql-tests-jena-2.0.zip" dest="${test.dir}/RDQL"/>
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Stress test - performs itql query stress tests                      -->
+  <!-- =================================================================== -->
+
+  <target name="stress-test"
+          depends="itql-jar, uri"
+          description="run stress tests the ItqlInterpreterBean">
+
+    <java classname="org.mulgara.itql.ItqlInterpreterStressTest" fork="yes" failonerror="no"
+      jvm="${java.home}/bin/java" dir="${basedir}">
+
+      <jvmarg value="${arch.bits}"/>
+
+      <sysproperty key="java.io.tmpdir" value="${tmp.dir}"/>
+      <sysproperty key="org.mulgara.xml.ResourceDocumentBuilderFactory"
+        value="org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"/>
+      <sysproperty key="java.naming.factory.initial"
+        value="com.sun.jndi.rmi.registry.RegistryContextFactory"/>
+      <sysproperty key="java.naming.provider.url" value="rmi://localhost"/>
+      <sysproperty key="java.rmi.server.codebase"
+        value="${bin.uri}/${rmi.jar}"/>
+      <sysproperty key="cvs.root" value="${basedir}"/>
+      <sysproperty key="log4j.configuration"
+        value="${baseuri}/log4j-conf.xml"/>
+
+      <!-- JUnitPP settings -->
+      <arg line="-r 1000 -w 10000 -wm 2000 -s 100 -t 5000 -ra 5000 -f itql.commands"/>
+
+      <classpath>
+
+        <path refid="query-classpath"/>
+
+        <fileset dir="${bin.dir}" includes="${dtd.jar}, ${itql.jar}, ${rules.jar}, ${query.jar},
+                 ${driver.jar}, ${rmi.jar}, ${server-rmi.jar}"/>
+        <fileset dir="${lib.dir}" includes="xerces*.jar, xmlParserAPIs.jar, jxunit*.jar, junit.jar, junitpp.jar"/>
+      </classpath>
+
+    </java>
+   </target>
+
+  <!-- =================================================================== -->
+  <!-- Runs regression tests on a Mulgara server                               -->
+  <!-- =================================================================== -->
+  <!--target name="regression-test"
+    depends="-prepare-build, log4j-conf.xml, dist"
+    description="Runs regression tests on a Mulgara server">
+
+    <echo message="mulgara-test has not been implemented, run itql-test or dbms-test instead."/-->
+
+    <!-- Set timestamp for CruiseControl's benefit -->
+    <!--tstamp/>
+
+    <delete dir="${mulgara.results.tmpdir}"/>
+    <mkdir dir="${mulgara.results.tmpdir}"/>
+    <delete file="${mulgara.results}"/-->
+
+    <!-- start a server -->
+    <!--ant target="start"/-->
+
+    <!-- run the tests -->
+
+    <!-- stop the server -->
+    <!--ant target="stop"/>
+
+  </target-->
+
+
+  <!-- =================================================================== -->
+  <!-- Builds Mulgara Semantic Store (Mulgara) WAR                           -->
+  <!-- =================================================================== -->
+  <target name="mulgara-war"
+      description="Builds the Mulgara Semantic Store (Mulgara) WAR"
+      depends="driver-jar, itql-jar, sparql-int-jar, query-jar, rmi-jar, server-jar,
+      server-beep-jar, server-rmi-jar, util-jar, config-jar, descriptor-jar, dtd-compile,
+      set.host.name, mulgara.war-uptodate"
+      unless="mulgara.war-uptodate">
+
+    <copy file="${mulgara.war.src.dir}/WEB-INF/web.xml"
+      tofile="${obj.dir}/war/mulgara/WEB-INF/web.xml"/>
+
+    <replace file="${obj.dir}/war/mulgara/WEB-INF/web.xml"
+       token="@@hostname@@" value="${host.name}"/>
+
+    <delete file="${bin.dir}/${mulgara.war}"/>
+
+    <war warfile="${bin.dir}/${mulgara.war}"
+        webxml="${obj.dir}/war/mulgara/WEB-INF/web.xml">
+
+      <zipfileset dir="${conf.dir}" prefix="WEB-INF/conf"
+          includes="mulgara-config-war.xml, mulgara-rmi.policy, mulgara.policy,
+          log4j-mulgara-war.properties, expires.txt"/>
+
+      <fileset dir="${src.dir}/war/mulgara"
+          includes="WEB-INF/**" excludes="WEB-INF/web.xml"/>
+
+      <lib dir="${lib.dir}" includes="log4j-core-*.jar, icu4j.jar, jena-*.jar, antlr*.jar, beepcore-*.jar,
+        lucene*.jar, apache-soap-*.jar, ${jrdf.jar}, ${joda-time.jar}, ${commons-logging.jar}"/>
+      <lib dir="${bin.dir}" includes="${query.jar},
+        ${driver.jar}, ${itql.jar}, ${sparql-int.jar}, ${rules.jar}, ${rmi.jar},
+          ${server.jar}, ${server-beep.jar}, ${server-rmi.jar},
+          ${util.jar}, ${config.jar}"/>
+      <lib dir="${dist.dir}" includes="expires.txt"/>
+    </war>
+  </target>
+
+  <target name="mulgara.war-uptodate">
+
+    <uptodate property="mulgara.war-uptodate"
+       targetfile="${bin.dir}/${mulgara.war}">
+
+      <srcfiles dir="${bin.dir}" includes="${query.jar},
+          ${driver.jar}, ${itql.jar}, ${rules.jar}, ${rmi.jar},
+          ${sparql-int.jar},
+          ${server.jar}, ${server-beep.jar}, ${server-rmi.jar},
+          ${util.jar}, ${config.jar}, ${descriptor.jar}"/>
+      <srcfiles dir="${dist.dir}" includes="expires.txt"/>
+      <srcfiles dir="${conf.dir}" includes="**/*"/>
+      <srcfiles dir="${src.dir}/war/mulgara" includes="WEB-INF/**"
+                                         excludes="WEB-INF/web.xml"/>
+      <srcfiles dir="${mulgara.war.src.dir}/WEB-INF" includes="web.xml"/>
+    </uptodate>
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Compiles the Mulgara webui interface pages with XMLC                    -->
+  <!-- =================================================================== -->
+  <target name="webui-xmlc" depends="xmlc"
+      description="Compiles the Mulgara webui interface pages with XMLC">
+
+    <!-- Build the webui interface classes -->
+    <mkdir dir="${obj.dir}/war/webui/java"/>
+
+    <!-- build the webui interface classes -->
+    <xmlc sourceout="${obj.dir}/war/webui/java"
+          includes="**/*.html"
+          markup="HTML"
+          verbose="false"
+          force="no"
+          srcdir="${webui.src.dir}/template-html"/>
+  </target>
+
+
+  <!-- =================================================================== -->
+  <!-- Compiles the Mulgara webui interface classes                            -->
+  <!-- =================================================================== -->
+  <target name="webui-build" depends="webui-xmlc, eventbuilder, driver-dist"
+      description="Compiles the Mulgara webui interface classes">
+
+    <!-- Build the webui interface classes -->
+    <mkdir dir="${obj.dir}/war/webui/classes"/>
+    <mkdir dir="${obj.dir}/war/webui/xlib"/>
+
+    <!-- Event class generation - also compiles the XMLC generated classes -->
+    <eventbuilder sourceout="${obj.dir}/war/webui/java"
+        descriptor="${webui.viewer.src.dir}/events/events.xml">
+    </eventbuilder>
+
+    <javac srcdir="${obj.dir}/war/webui/java"
+     destdir="${obj.dir}/war/webui/classes"
+     debug="${debug}" deprecation="on">
+      <classpath refid="webui.classpath"/>
+    </javac>
+
+    <javac srcdir="${webui.src.dir}/java"
+        destdir="${obj.dir}/war/webui/classes"
+        debug="${debug}" deprecation="on">
+      <classpath refid="webui.classpath"/>
+    </javac>
+
+    <!-- Example queries and directives -->
+    <copy todir="${obj.dir}/war/webui/classes" >
+
+      <fileset dir="${webui.src.dir}/java" >
+
+        <include name="**/*.txt"/>
+        <include name="**/*.directives"/>
+      </fileset>
+    </copy>
+
+    <!-- images -->
+    <copy todir="${obj.dir}/war/webui/xlib" >
+
+      <fileset dir="${webui.src.dir}/template-html/org/mulgara/webui/viewer" >
+
+        <exclude name="**/*.html"/>
+        <exclude name="**/*.xmlc"/>
+      </fileset>
+    </copy>
+
+    <!-- Replace tokens in example queries - leave out the <> brackets-->
+    <!-- The name of the model to work on -->
+    <replace file="${obj.dir}/war/webui/classes/org/mulgara/webui/viewer/ExampleQueries.txt"
+       token="@@model-uri@@" value="rmi://host.name/server1#sampledata"/>
+    <replace file="${obj.dir}/war/webui/classes/org/mulgara/webui/viewer/ExampleQueries.txt"
+       token="@@data-dir@@" value="jar:file:mulgara.jar.path!/data"/>
+
+  </target>
+
+
+  <!-- =================================================================== -->
+  <!-- Builds the Mulgara webui interface WAR                                  -->
+  <!-- =================================================================== -->
+  <target name="webui-war" depends="webui-build, -webui-war-uptodate"
+      description="Builds the Mulgara webui interface WAR" unless="webui.war-uptodate">
+
+    <mkdir dir="${obj.dir}/war/webui/jars"/>
+
+    <!-- Actual page classes -->
+    <jar jarfile="${obj.dir}/war/webui/jars/${webui-screens.jar}">
+      <fileset dir="${obj.dir}/war/webui/classes" includes="org/mulgara/webui/**/*HTML.class"/>
+    </jar>
+
+    <!-- Images and stylesheet - swap this jar to change badging -->
+    <jar jarfile="${obj.dir}/war/webui/jars/${webui-resources.jar}"
+      basedir="${obj.dir}/war/webui/" includes="xlib/**"/>
+
+    <!-- Barracuda related classes -->
+    <jar jarfile="${obj.dir}/war/webui/jars/${webui-barracuda.jar}"
+      basedir="${obj.dir}/war/webui/classes"
+      includes="org/mulgara/barracuda/**"/>
+
+    <!-- Logic -->
+    <jar jarfile="${obj.dir}/war/webui/jars/${webui-logic.jar}"
+      basedir="${obj.dir}/war/webui/classes"
+      includes="org/mulgara/webui/**"
+      excludes="**/*HTML.class"/>
+
+    <war warfile="${bin.dir}/${webui.war}"
+      webxml="${webui.src.dir}/WEB-INF/web.xml">
+
+      <fileset dir="${webui.src.dir}/content"/>
+      <fileset dir="${webui.src.dir}"
+        includes="WEB-INF/**" excludes="WEB-INF/web.xml"/>
+
+      <lib dir="${lib.dir}" includes="xmlc-all*.jar, *barracuda*.jar, plankton*.jar"/>
+      <lib dir="${obj.dir}/war/webui/jars" includes="*.jar"/>
+    </war>
+  </target>
+
+  <target name="-webui-war-uptodate">
+
+     <uptodate property="webui.war-uptodate" targetfile="${bin.dir}/${webui.war}">
+
+       <srcfiles dir="${dist.dir}" includes="${driver.jar}"/>
+       <srcfiles dir="${obj.dir}/war/webui/jars" includes="*.jar"/>
+       <srcfiles dir="${obj.dir}/war/webui/classes"/>
+     </uptodate>
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- J2EE resource adapter                                               -->
+  <!-- =================================================================== -->
+  <target name="mulgara-rar" depends="driver-jar, query-jar">
+
+    <jar jarfile="${bin.dir}/mulgara.rar">
+
+      <fileset dir="${src.dir}/rar/mulgara" includes="META-INF/ra.xml"/>
+      <fileset dir="${src.dir}/rar/mulgara/content"/>
+      <fileset dir="${bin.dir}" includes="${driver.jar}, ${query.jar}"/>
+      <fileset dir="${lib.dir}" includes="beepcore-*.jar"/>
+    </jar>
+  </target>
+
+  <!-- Hand-run test example for rdfload -->
+  <target name="load-rdf-example" depends="host.name, define.rdfload, start"
+   description="Hand-run example of using the rdfload task">
+
+    <sleep seconds="15"/>
+
+    <!-- delete old logs -->
+    <delete file="${basedir}/rdfload.log"/>
+
+    <rdfload
+       logfile="${basedir}/rdfload.log"
+       modeluri="rmi://${host.name}/server1#load-rdf-example"
+       domainuri="rmi://${host.name}/server1"
+       username="user"
+       password="letmein"
+       dropmodel="yes"
+       maxerrors="10"
+       ignoreerrors="false"
+       transactionsize="10"
+       logconfig="${conf.dir}/log4j-rdfload.xml">
+
+       <rdfpath>
+
+         <fileset dir="${jxdata.dir}/ant-tasks">
+
+           <include name="rdf-good/*.rdf"/>
+           <!-- Put in a baddy -->
+           <include name="rdf-bad/2.rdf"/>
+        </fileset>
+      </rdfpath>
+    </rdfload>
+
+   <!-- shutdown the Mulgara server -->
+   <antcall target="stop"/>
+
+  </target>
+
+
+  <!-- Hand-run test example for itql command -->
+  <target name="itqlcommand-example" depends="host.name, define.itqlcommand, start"
+   description="Hand-run example of using the itqlcommand task">
+
+    <sleep seconds="15"/>
+
+    <itqlcommand ignoreerrors="true">
+
+       <itqlquery query="set autocommit off;"/>
+       <itqlquery query="create &lt;rmi://${host.name}/server1#itqlcommand-example&gt; ;"/>
+       <itqlquery query="insert &lt;http://test&gt; &lt;http://message&gt; 'Hello World' into  &lt;rmi://${host.name}/server1#itqlcommand-test&gt; ;"/>
+       <itqlquery query="select $$s $$p $$o from &lt;rmi://${host.name}/server1#itqlcommand-test&gt; where $$s $$p $$o ;"/>
+       <itqlquery query="drop &lt;rmi://${host.name}/server1#itqlcommand-test&gt; ;"/>
+       <!-- Bad query -->
+       <itqlquery query="drop &lt;rmi://${host.name}/server1#itqlcommand-test&gt; ;"/>
+       <itqlquery query="set autocommit on;"/>
+    </itqlcommand>
+
+   <!-- shutdown the Mulgara server -->
+   <antcall target="stop"/>
+
+  </target>
+
+  <!-- ======================================================= -->
+  <!-- Publish the test results to Anthill                     -->
+  <!-- ======================================================= -->
+  <target name="publish"
+   description="Publish the test results to the deployDir">
+
+     <antcall target="format-results"/>
+
+     <!-- Set new values if not already put in test dir under html -->
+     <property name="deployDir" value="${test.dir}"/>
+     <property name="version" value="html"/>
+
+     <mkdir dir="${deployDir}/${version}"/>
+
+     <copy todir="${deployDir}/${version}">
+       <fileset dir="${test.dir}"
+         includes="**/*.html,**/*.css"
+         excludes="RDF-Test-Cases/**"/>
+     </copy>
+
+     <mkdir dir="${deployDir}/${version}/logs"/>
+     <copy todir="${deployDir}/${version}/logs">
+       <fileset dir="${jxtest.dir}"
+         includes="**/*.xml,**/*.txt"/>
+     </copy>
+     <copy todir="${deployDir}/${version}/logs">
+       <fileset dir="${jxtest.dir}"
+         includes="**/*output. **/*.log"/>
+     </copy>
+
+  </target>
+
+  <target name="format-results" description="Report results of the JUnit tests">
+    <junitreport tofile="test/All-Tests.xml">
+      <fileset dir="${junit.results.tmpdir}" includes="TEST-*.xml"/>
+      <report todir="${test.dir}"/>
+    </junitreport>
+  </target>
+
+  <target name="publish-summary" depends="format-results"
+          description="Report summary of Junit results">
+
+    <delete file="${test.dir}/junit-summary.txt"/>
+    <delete file="${test.dir}/All-Tests.html"/>
+
+    <xslt  basedir="${test.dir}"
+           destdir="${test.dir}"
+           style="${scripts.dir}/junit-summary.xsl"
+           includes="**/All-Tests.xml">
+       <param name="output.dir" expression="${test.dir}"/>
+    </xslt>
+
+    <concat>
+      <fileset file="${test.dir}/junit-summary.txt"/>
+    </concat>
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Creates the distribution file for the Embedded Mulgara server        -->
+  <!-- =================================================================== -->
+  <target name="embedded-dist"
+          depends="client-jrdf-jar, config-jar,
+             content-mbox-jar, content-mp3-jar, content-n3-jar,
+             content-rdfxml-jar, content-rio-jar,
+             create-manifest, demo-jar, dtd-jar, driver-jar, dtd-jar,
+             itql-jar, sparql-int-jar,
+             javadoc-dist, jrdf-jar, store-jar, store-xa-jar,
+             store-nodepool-jar,
+             store-nodepool-memory-jar, store-nodepool-xa-jar,
+             query-jar, resolver-jar, resolver-null-jar, resolver-file-jar, resolver-filesystem-jar,
+             resolver-http-jar, resolver-memory-jar, resolver-spi-jar,
+             resolver-store-jar, resolver-url-jar, resolver-lucene-jar,
+             resolver-view-jar, resolver-nodetype-jar, resolver-prefix-jar, resolver-jar-jar,
+             resolver-relational-jar, resolver-distributed-jar,
+             resolver-xsd-jar, resolver-test-jar, rmi-jar,
+             server-jar, server-beep-jar, server-rmi-jar,
+             sofa-jar, rules-jar, krule-jar, store-stringpool-jar, store-stringpool-memory-jar,
+             store-stringpool-xa-jar, tuples-jar,
+             tuples-hybrid-jar, util-jar, util-xa-jar,
+             webservices-war, webui-war, -embedded-dist-uptodate, webpage-includes"
+          description="Creates the executable JAR for the Embedded Mulgara server"
+                unless="embedded.dist.uptodate">
+
+    <!-- HACK!!!!! -->
+    <!-- This will get the ARP parser working -->
+    <!-- My theory about why this is necessary is that the Bootloader class
+         messes up the JAR plugin framework that both JAXP and StAX use -->
+    <mkdir dir="${obj.dir}/xerces"/>
+
+    <unjar src="${lib.dir}/xercesImpl.jar" dest="${obj.dir}/xerces"/>
+    <unjar src="${lib.dir}/xmlParserAPIs.jar" dest="${obj.dir}/xerces"/>
+    <unjar src="${lib.dir}/jsr173_07_api.jar" dest="${obj.dir}/xerces"/>
+    <unjar src="${lib.dir}/jsr173_07_ri.jar" dest="${obj.dir}/xerces"/>
+
+    <!-- build the executable jar file -->
+    <jar jarfile="${dist.dir}/${mulgara.jar}"
+        manifest="${obj.dir}/META-INF/MANIFEST_Mulgara_BOOTSTRAP.MF">
+
+      <zipfileset dir="${conf.dir}" prefix="conf"
+          includes="log4j-mulgara.xml, webdefault.xml, mulgara-rmi.policy,
+                    mulgara.policy"/>
+
+      <!-- third party libraries -->
+      <zipfileset src="${lib.dir}/${log4j.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${icu4j.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${activation.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${beep.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${jargs.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${jrdf.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${jetty.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${jetty.plus.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${servlet.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${jasper.runtime.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${jasper.compiler.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${lucene.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${mail.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${mulgara-sparql.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${castor-xml.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${castor-xml-schema.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${castor-codegen.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${trove.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${joda-time.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${commons-logging.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${commons-httpclient.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${commons-codec.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${emory-util.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${jotm.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${jotm.jrmp.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${carol.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${howl.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${jta.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${jsr.173.api.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${jsr.173.ri.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${jca.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${saaj.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${axis.jar}" excludes="META-INF/**, log4j.properties"/>
+      <zipfileset src="${lib.dir}/${commons-discovery.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${jaxrpc.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${wsdl4j.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${jakarta-oro.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${jena.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${antlr.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${serializer.jar}" excludes="META-INF/**"/>
+
+      <!-- core libraries -->
+      <zipfileset src="${bin.dir}/${query.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${driver.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${itql.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${sparql-int.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${rmi.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${server.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${server-beep.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${server-rmi.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${util.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${config.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${descriptor.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${server-local.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${resolver.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${resolver-spi.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${resolver-filesystem.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${store.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${store-xa.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${store-nodepool.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${store-nodepool-memory.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${store-nodepool-xa.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${store-stringpool.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${store-stringpool-memory.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${store-stringpool-xa.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${util-xa.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${resolver-null.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${resolver-file.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${resolver-http.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${resolver-lucene.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${resolver-memory.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${resolver-store.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${resolver-url.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${resolver-view.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${tuples.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${tuples-hybrid.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${content-mp3.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${content-n3.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${content-mbox.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${content-rdfxml.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${content-rio.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${resolver-nodetype.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${resolver-prefix.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${resolver-relational.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${resolver-distributed.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${resolver-xsd.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${resolver-test.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${resolver-jar.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${jid3.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${dtd.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${jrdf.base.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${rules.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${krule.jar}" excludes="META-INF/**"/>
+
+
+      <!-- include pre-bundled webapps -->
+      <zipfileset dir="${bin.dir}" prefix="webapps"
+          includes="${webui.war}"/>
+      <zipfileset dir="${obj.dir}/war" prefix="webapps"
+          includes="webservices.war"/>
+      <zipfileset dir="${lib.dir}" prefix="lib" includes="barracuda-core*.jar"/>
+      <zipfileset file="${obj.dir}/mulgara-x-config.xml" prefix="conf" />
+
+      <!-- Schemas -->
+      <zipfileset dir="${basedir}/data" prefix="data"
+          includes="**/*.rdfs,**/*.rss,**/*.n3"/>
+
+      <zipfileset dir="${basedir}/docs" prefix="docs"
+          includes="**/*.html, **/*.css, **/images/*, **/images/icons/*, LEGAL.txt"/>
+      <zipfileset dir="${src.docs.dir}" prefix="docs"
+          includes="**/*.html, **/*.htm, **/*.gif, **/*.png, **/*.jpg, **/*.css, **/images/*, **/images/icons/*"/>
+
+      <fileset dir="${obj.dir}/jar/util/classes" includes="**/Bootstrap.class"/>
+      <fileset dir="${src.dir}/jar/dtd" includes="META-INF/**, DTD/**"/>      <!-- fileset dir="${obj.dir}/jar/dtd/classes"/ -->
+
+      <!-- HACK!!!!! -->
+      <!-- This will get the ARP parser working -->
+      <!-- Ignore the xerces DocumentBuilderFactory -->
+      <fileset dir="${obj.dir}/xerces" excludes="META_INF/**,META-INF/services/javax.xml.parsers.DocumentBuilderFactory"/>
+
+      <fileset dir="${obj.dir}/xerces" excludes="META_INF/**"/>
+      <!-- HACK!!!!! -->
+
+    </jar>
+  </target>
+
+  <!-- do a check for any changes made to the mulgara build -->
+  <!-- potentially not the most efficient checking performed -->
+  <target name="-embedded-dist-uptodate">
+
+    <uptodate property="embedded.dist.uptodate"
+       targetfile="${dist.dir}/${mulgara.jar}">
+
+      <srcfiles dir="${bin.dir}" includes="**/*"/>
+      <srcfiles dir="${conf.dir}" includes="**/*"/>
+      <srcfiles dir="${lib.dir}" includes="**/*"/>
+      <srcfiles dir="${data.dir}" includes="**/*"/>
+      <srcfiles dir="${obj.dir}/war" includes="webservices.war"/>
+      <srcfiles dir="${basedir}/docs" includes="**/*"/>
+    </uptodate>
+  </target>
+
+  <target name="create-manifest" depends="-prepare-build">
+
+    <mkdir dir="${obj.dir}/META-INF"/>
+
+    <!-- generate the core manifest -->
+    <manifest file="${obj.dir}/META-INF/MANIFEST_Mulgara_BASE.MF">
+      <attribute name="Main-Class" value="org.mulgara.triplestore.Main"/>
+    </manifest>
+
+    <!-- generate the bootstrap manifest -->
+    <manifest file="${obj.dir}/META-INF/MANIFEST_Mulgara_BOOTSTRAP.MF">
+
+      <attribute name="Main-Class" value="org.mulgara.util.Bootstrap"/>
+      <attribute name="Embedded-Main-Class" value="org.mulgara.server.EmbeddedMulgaraServer"/>
+    </manifest>
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Meta testing target, updates source before running tests            -->
+  <!-- =================================================================== -->
+
+  <target name="test"
+          depends="dist, client-test, session-test, resolver-api-test, store-xa-test,
+                   utils-test, jxtest, store-stringpool-xa-loadtest, publish-summary"
+          description="Runs all tests (updates source first)">
+
+    <loadfile property="test.status.success" srcfile="${test.dir}/junit-summary.txt">
+      <filterchain>
+        <linecontainsregexp>
+          <regexp pattern="Success rate *100\.?0?0?%"/>
+        </linecontainsregexp>
+      </filterchain>
+    </loadfile>
+    <fail unless="test.status.success"/>
+  </target>
+
+  <target name="client-test"
+          depends="client-jrdf-test,
+                   demo-mp3-test, driver-test, itql-test, query-test,
+                   descriptor-test"
+          description="Runs client side tests">
+  </target>
+
+  <target name="session-test"
+          depends="jrdf-test, server-test,
+             server-beep-test, server-http-test, server-local-test,
+             server-rmi-test"
+          description="Runs session based tests">
+  </target>
+
+  <target name="resolver-api-test"
+    depends="content-mbox-test, content-mp3-test, content-n3-test,
+             content-rdfxml-test, content-rio-test,
+             resolver-test, resolver-null-test, resolver-file-test,
+             resolver-filesystem-test, resolver-jar-test, resolver-gis-test,
+             resolver-http-test, resolver-lucene-test,
+             resolver-nodetype-test, resolver-prefix-test, resolver-memory-test,
+             resolver-spi-test, resolver-store-test, resolver-relational-test,
+             resolver-url-test, resolver-view-test, resolver-xsd-test,
+             resolver-distributed-test, resolver-test-test,
+             store-stringpool-test"
+    description="Runs resolver API/SPI tests">
+  </target>
+
+  <target name="store-xa-test"
+    depends="store-nodepool-memory-test, store-nodepool-xa-test,
+             store-stringpool-memory-test,
+             store-stringpool-xa-test, tuples-test, tuples-hybrid-test"
+    description="Runs store -xa tests">
+  </target>
+
+  <target name="utils-test"
+    depends="ant-task-test, dtd-test, sofa-test, rules-test, krule-test, tag-test, util-test, util-xa-test"
+    description="Runs miscellaneous utility tests">
+  </target>
+
+  <target name="jxtest"
+    depends="jxunit-test"
+    description="Runs all jxunit based testing">
+  </target>
+
+  <target name="ideSupport" depends="dist,demo-mp3-jar,descriptor-wsdl-client.jar"
+    description="Builds necessary libraries for using the Eclipse IDE.">
+
+     <jar jarfile="${dist.dir}/ideSupport.jar">
+      <zipfileset dir="${obj.dir}/jar/itql/classes" includes="org/mulgara/itql/**"/>
+      <zipfileset dir="${obj.dir}/jar/itql/java" includes="org/mulgara/itql/lexer/lexer.dat"/>
+      <zipfileset dir="${obj.dir}/jar/itql/java" includes="org/mulgara/itql/parser/parser.dat"/>
+      <zipfileset dir="${obj.dir}/jar/config/classes" includes="org/mulgara/config/**"/>
+      <zipfileset dir="${obj.dir}/jar/util/classes" includes="org/mulgara/util/conversion/**"/>
+      <zipfileset dir="${obj.dir}/jar/server-rmi/classes" includes="org/mulgara/server/rmi/**"/>
+      <zipfileset dir="${obj.dir}/jar/server-rmi/classes" includes="edu/emory/**"/>
+	  <zipfileset dir="${obj.dir}/jar/demo-mp3/classes" includes="org/mulgara/demo/mp3/**"/>
+      <zipfileset dir="${obj.dir}/war/webui/classes" includes="org/mulgara/barracuda/**"/>
+      <zipfileset dir="${obj.dir}/war/webui/classes" includes="org/mulgara/webui/**"/>
+      <zipfileset dir="${basedir}" includes="conf/**"/>
+  	  <zipfileset dir="${obj.dir}/jar/descriptor-client/classes" includes="org/mulgara/descriptor/**" excludes="org/mulgara/descriptor/test/**"/>
+      <!-- include pre-bundled webapps -->
+      <zipfileset dir="${bin.dir}" prefix="webapps" includes="${webui.war}"/>
+      <zipfileset dir="${obj.dir}/war" prefix="webapps" includes="webservices.war"/>
+      <zipfileset dir="${lib.dir}" prefix="lib" includes="barracuda*.jar"/>
+      <zipfileset file="${obj.dir}/mulgara-x-config.xml" prefix="conf" />
+
+      <!-- Schemas -->
+      <zipfileset dir="${basedir}/data" prefix="data" includes="**/*.rdfs,**/*.rss,**/*.n3"/>
+
+      <zipfileset dir="${basedir}/docs" prefix="docs" includes="**/*.html, **/*.css, **/images/*, **/images/icons/*, LEGAL.txt"/>
+      <zipfileset dir="${src.docs.dir}" prefix="docs" includes="**/*.html, **/*.htm, **/*.gif, **/*.png, **/*.jpg, **/*.css, **/images/*, **/images/icons/*"/>
+
+      <fileset dir="${src.dir}/jar/dtd" includes="META-INF/**, DTD/**"/>     
+
+    </jar>
+  </target>
+
+  
+</project>

Modified: branches/mgr-121-lockrecovery/common.properties
===================================================================
--- branches/mgr-121-lockrecovery/common.properties	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/common.properties	2008-06-19 03:35:29 UTC (rev 1005)
@@ -49,7 +49,7 @@
 arch.bits=-Dnoop
 
 # VM argument for component test
-jvm.args=-Xmx640M
+jvm.args=-Xmx768M
 
 # test server arguments; can be set with -Dtest.server.args=... on the command line
 test.server.args=

Modified: branches/mgr-121-lockrecovery/common.xml
===================================================================
--- branches/mgr-121-lockrecovery/common.xml	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/common.xml	2008-06-19 03:35:29 UTC (rev 1005)
@@ -152,8 +152,8 @@
                        jotm*.jar, commons-logging-*.jar, Quick4rt.jar,
                        commons-discovery-*.jar, commons-httpclient-*.jar,
                        commons-codec-*.jar, connector-*.jar, jaxrpc-*.jar,
-                       carol*.jar, howl-logger*.jar, ${date-utils.jar},
-                       mulgara-sparql*.jar"
+                       carol*.jar, howl-logger*.jar,
+                       ${joda-time.jar}, mulgara-sparql*.jar"
              excludes="jboss-j2ee.jar"/>
   </path>
 
@@ -584,6 +584,7 @@
       <arg value="-o"/>
       <arg value="${dist.dir}/mulgara-output"/>
       <arg value="${java.home}/bin/java"/>
+      <arg value="-ea"/>
       <arg value="${jvm.args}"/>
       <arg line="-Djava.io.tmpdir=&quot;${tmp.dir}&quot;"/>
       <arg line="-Dorg.mulgara.test=&quot;${org.mulgara.test}&quot;"/>
@@ -604,6 +605,7 @@
       <arg value="${dist.dir}/mulgara-output"/>
       <arg value="${java.home}/bin/java"/>
       <arg value="${arch.bits}"/>
+      <arg value="-ea"/>
       <arg value="${jvm.args}"/>
       <arg line="-Djava.io.tmpdir=&quot;${tmp.dir}&quot;"/>
       <arg value="-cp"/>
@@ -621,6 +623,7 @@
       <arg value="-o"/>
       <arg value="${dist.dir}/mulgara-output"/>
       <arg value="${java.home}/bin/java"/>
+      <arg value="-ea"/>
       <arg value="${jvm.args}"/>
       <arg line="-Djava.io.tmpdir=&quot;${tmp.dir}&quot;"/>
       <arg value="-cp"/>
@@ -639,6 +642,7 @@
       <arg value="-o"/>
       <arg value="${dist.dir}\mulgara-output"/>
       <arg value="${java.home}\bin\javaw"/>
+      <arg value="-ea"/>
       <arg value="${jvm.args}"/>
       <arg line="-Djava.io.tmpdir=&quot;${tmp.dir}&quot;"/>
       <arg value="-cp"/>

Copied: branches/mgr-121-lockrecovery/jxdata/iTQL/advance_queries/queryResult6.txt (from rev 1002, trunk/jxdata/iTQL/advance_queries/queryResult6.txt)
===================================================================
--- branches/mgr-121-lockrecovery/jxdata/iTQL/advance_queries/queryResult6.txt	                        (rev 0)
+++ branches/mgr-121-lockrecovery/jxdata/iTQL/advance_queries/queryResult6.txt	2008-06-19 03:35:29 UTC (rev 1005)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<answer xmlns="http://mulgara.org/tql#"><query><variables><g/><a/><b/></variables><solution><g resource="@server@#"/><a resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#type"/><b resource="http://mulgara.org/mulgara#Model"/></solution><solution><g resource="@server@#data-02"/><a resource="http://example.org/data/x"/><b resource="http://example.org/data/y"/></solution><solution><g resource="@server@#data-02"/><a resource="@server@#data-02"/><b resource="@server@#data-02"/></solution></query></answer>

Copied: branches/mgr-121-lockrecovery/jxdata/iTQL/advance_queries/queryResult7.txt (from rev 1002, trunk/jxdata/iTQL/advance_queries/queryResult7.txt)
===================================================================
--- branches/mgr-121-lockrecovery/jxdata/iTQL/advance_queries/queryResult7.txt	                        (rev 0)
+++ branches/mgr-121-lockrecovery/jxdata/iTQL/advance_queries/queryResult7.txt	2008-06-19 03:35:29 UTC (rev 1005)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<answer xmlns="http://mulgara.org/tql#"><query><variables><g/></variables><solution><g resource="@server@#data-02"/></solution></query></answer>

Copied: branches/mgr-121-lockrecovery/jxdata/iTQL/advance_queries/result2.txt (from rev 1002, trunk/jxdata/iTQL/advance_queries/result2.txt)
===================================================================
--- branches/mgr-121-lockrecovery/jxdata/iTQL/advance_queries/result2.txt	                        (rev 0)
+++ branches/mgr-121-lockrecovery/jxdata/iTQL/advance_queries/result2.txt	2008-06-19 03:35:29 UTC (rev 1005)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<answer xmlns="http://mulgara.org/tql#"><query><message>Successfully loaded 6 statements from @baseuri@/jxtest/iTQL/data-02-ext.ttl into @server@#data-02</message></query></answer>

Modified: branches/mgr-121-lockrecovery/jxdata/iTQL/advance_queries/test.jxu
===================================================================
--- branches/mgr-121-lockrecovery/jxdata/iTQL/advance_queries/test.jxu	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/jxdata/iTQL/advance_queries/test.jxu	2008-06-19 03:35:29 UTC (rev 1005)
@@ -53,5 +53,33 @@
     <fail>Output failed.  Check badQuery5Result.xml for output.</fail>
   </ifEqual>
 
+  <!-- New data set. Test for multiple variables in constraints. data-02-ext.ttl -->
+  <set name="modelName" value="@server@#data-02" />
+  <set name="loadCommand" value="load &lt;@baseuri@/jxtest/iTQL/data-02-ext.ttl&gt; into &lt;@server@#data-02&gt; ;" />
+  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
+
+  <ifEqual converse="true" file="result2.txt" name="loadResult">
+    <save name="loadResult" file="badLoadResult2.xml"/>
+    <fail>Output failed.  Check badLoadResult2.xml for output.</fail>
+  </ifEqual>
+
+  <!-- Test #6: Query for variable as both subject and graph -->
+  <set name="query" value="select $g $a $b from &lt;@server@#&gt; where $g $a $b in $g order by $g $a;"/>
+
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult6.txt" name="queryResult">
+    <save name="queryResult" file="badQuery6Result.xml"/>
+    <fail>Output failed.  Check badQuery6Result.xml for output.</fail>
+  </ifEqual>
+
+  <!-- Test #7: Query for variable as all of subject, predicate, object and graph-->
+  <set name="query" value="select $g from &lt;@server@#&gt; where $g $g $g in $g;"/>
+
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult7.txt" name="queryResult">
+    <save name="queryResult" file="badQuery7Result.xml"/>
+    <fail>Output failed.  Check badQuery7Result.xml for output.</fail>
+  </ifEqual>
+
 </jxu>
 

Copied: branches/mgr-121-lockrecovery/jxdata/iTQL/data-02-ext.ttl (from rev 1002, trunk/jxdata/iTQL/data-02-ext.ttl)
===================================================================
--- branches/mgr-121-lockrecovery/jxdata/iTQL/data-02-ext.ttl	                        (rev 0)
+++ branches/mgr-121-lockrecovery/jxdata/iTQL/data-02-ext.ttl	2008-06-19 03:35:29 UTC (rev 1005)
@@ -0,0 +1,10 @@
+ at prefix : <http://example.org/data/> .
+
+
+:y :y :x .
+:x :y :y .
+:y :x :y .
+:x :x :x .
+<@server@#data-02> :x :y .
+<@server@#data-02> <@server@#data-02> <@server@#data-02> .
+

Modified: branches/mgr-121-lockrecovery/jxdata/iTQL/data_types/dateTime/queryResult17.txt
===================================================================
--- branches/mgr-121-lockrecovery/jxdata/iTQL/data_types/dateTime/queryResult17.txt	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/jxdata/iTQL/data_types/dateTime/queryResult17.txt	2008-06-19 03:35:29 UTC (rev 1005)
@@ -1,2 +1,2 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<answer xmlns="http://mulgara.org/tql#"><query><variables><dateTime/></variables><solution><dateTime datatype="http://www.w3.org/2001/XMLSchema#dateTime">2005-01-01T12:17:00</dateTime></solution><solution><dateTime datatype="http://www.w3.org/2001/XMLSchema#dateTime">2005-01-01T12:17:00.005</dateTime></solution><solution><dateTime datatype="http://www.w3.org/2001/XMLSchema#dateTime">2005-01-01T12:17:00.01</dateTime></solution><solution><dateTime datatype="http://www.w3.org/2001/XMLSchema#dateTime">2005-01-01T12:17:00.05</dateTime></solution></query></answer>
+<answer xmlns="http://mulgara.org/tql#"><query><variables><dateTime/></variables><solution><dateTime datatype="http://www.w3.org/2001/XMLSchema#dateTime">2005-01-01T12:17:00</dateTime></solution><solution><dateTime datatype="http://www.w3.org/2001/XMLSchema#dateTime">2005-01-01T12:17:00.005</dateTime></solution><solution><dateTime datatype="http://www.w3.org/2001/XMLSchema#dateTime">2005-01-01T12:17:00.010</dateTime></solution><solution><dateTime datatype="http://www.w3.org/2001/XMLSchema#dateTime">2005-01-01T12:17:00.05</dateTime></solution></query></answer>

Modified: branches/mgr-121-lockrecovery/jxdata/iTQL/data_types/dateTime/queryResult18.txt
===================================================================
--- branches/mgr-121-lockrecovery/jxdata/iTQL/data_types/dateTime/queryResult18.txt	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/jxdata/iTQL/data_types/dateTime/queryResult18.txt	2008-06-19 03:35:29 UTC (rev 1005)
@@ -1,2 +1,2 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<answer xmlns="http://mulgara.org/tql#"><query><variables><dateTime/></variables><solution><dateTime datatype="http://www.w3.org/2001/XMLSchema#dateTime">2005-01-01T12:17:00</dateTime></solution><solution><dateTime datatype="http://www.w3.org/2001/XMLSchema#dateTime">2005-01-01T12:17:00.005</dateTime></solution><solution><dateTime datatype="http://www.w3.org/2001/XMLSchema#dateTime">2005-01-01T12:17:00.01</dateTime></solution></query></answer>
+<answer xmlns="http://mulgara.org/tql#"><query><variables><dateTime/></variables><solution><dateTime datatype="http://www.w3.org/2001/XMLSchema#dateTime">2005-01-01T12:17:00</dateTime></solution><solution><dateTime datatype="http://www.w3.org/2001/XMLSchema#dateTime">2005-01-01T12:17:00.005</dateTime></solution><solution><dateTime datatype="http://www.w3.org/2001/XMLSchema#dateTime">2005-01-01T12:17:00.010</dateTime></solution></query></answer>

Modified: branches/mgr-121-lockrecovery/jxdata/iTQL/standard_queries/queryResult18.txt
===================================================================
--- branches/mgr-121-lockrecovery/jxdata/iTQL/standard_queries/queryResult18.txt	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/jxdata/iTQL/standard_queries/queryResult18.txt	2008-06-19 03:35:29 UTC (rev 1005)
@@ -1,4 +1,4 @@
 ItqlInterpreter error - Query failed
 Caused by: (QueryException) org.mulgara.query.MulgaraTransactionException: Transaction rollback triggered
 Caused by: (QueryException) Error resolving [$s $p $o $_from] from mailto:foo at bar.com
-Caused by: (QueryException) Unable to extract hostname from: mailto:foo at bar.com
+Caused by: (QueryException) Unknown graph, and no hostname: mailto:foo at bar.com

Modified: branches/mgr-121-lockrecovery/jxdata/iTQL/standard_queries/queryResult19.txt
===================================================================
--- branches/mgr-121-lockrecovery/jxdata/iTQL/standard_queries/queryResult19.txt	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/jxdata/iTQL/standard_queries/queryResult19.txt	2008-06-19 03:35:29 UTC (rev 1005)
@@ -1,3 +1,3 @@
 ItqlInterpreter error - Unable to connect to a server
-Caused by: (SessionFactoryFinderException) Couldn't create session factory for rmi://localhost/server2
+Caused by: (SessionFactoryFinderException) Couldn't create session factory for @server2@
 Caused by: (ClassNotFoundException) org.mulgara.server.local.LocalSessionFactory

Modified: branches/mgr-121-lockrecovery/jxdata/iTQL/standard_queries/test.jxu
===================================================================
--- branches/mgr-121-lockrecovery/jxdata/iTQL/standard_queries/test.jxu	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/jxdata/iTQL/standard_queries/test.jxu	2008-06-19 03:35:29 UTC (rev 1005)
@@ -1,308 +1,308 @@
-<jxu>
-  <set name="debug" value="false" />
-
-  <set name="modelName" value="@server@#model1" />
-  <set name="loadCommand" value="load &lt;@baseuri@/jxdata/iTQL/data.rdf&gt; into &lt;@server@#model1&gt; ;" />
-  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
-
-  <ifEqual converse="true" file="result1.txt" name="loadResult">
-    <save name="loadResult" file="badLoadResult.xml"/>
-    <fail>Output failed.  Check badLoadResult.xml for output.</fail>
-  </ifEqual>
-
-  <set name="modelName" value="@server@#model2" />
-  <set name="loadCommand" value="load &lt;@baseuri@/jxdata/iTQL/coins.rdf&gt; into &lt;@server@#model2&gt; ;" />
-  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
-
-  <ifEqual converse="true" file="result2.txt" name="loadResult">
-    <save name="loadResult" file="badLoadResult2.xml"/>
-    <fail>Output failed.  Check badLoadResult2.xml for output.</fail>
-  </ifEqual>
-
-  <set name="modelName" value="@server@#model3" />
-  <set name="loadCommand" value="load &lt;@baseuri@/jxdata/iTQL/security-tks.rdf&gt; into &lt;@server@#model3&gt; ;" />
-  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
-
-  <ifEqual converse="true" file="result3.txt" name="loadResult">
-    <save name="loadResult" file="badLoadResult3.xml"/>
-    <fail>Output failed.  Check badLoadResult3.xml for output.</fail>
-  </ifEqual>
-
-  <!--  Add a dummy model to test duplicate constraint bug -->
-  <set name="modelName" value="@server@#allsame2" />
-  <set name="loadCommand" value="load &lt;@baseuri@/jxdata/iTQL/testpred.rdf&gt; into &lt;@server@#allsame2&gt; ;" />
-  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
-
-  <ifEqual converse="true" file="result8.txt" name="loadResult">
-    <save name="loadResult" file="badLoadResult8.xml"/>
-    <fail>Output failed.  Check badLoadResult8.xml for output.</fail>
-  </ifEqual>
-
-  <set name="modelName" value="@server@#allsame" />
-  <set name="loadCommand" value="load &lt;@baseuri@/jxdata/iTQL/testsame.rdf&gt; into &lt;@server@#allsame&gt; ;" />
-  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
-
-  <ifEqual converse="true" file="result4.txt" name="loadResult">
-    <save name="loadResult" file="badLoadResult4.xml"/>
-    <fail>Output failed.  Check badLoadResult4.xml for output.</fail>
-  </ifEqual>
-
-  <set name="query" value="select $pmid $title from &lt;@server@#model1&gt; where $date &lt;http://mulgara.org/mulgara/tool/DateExtractor#year&gt; '2000' and $date &lt;http://mulgara.org/mulgara/tool/DateExtractor#month&gt; '08' and $pmid &lt;urn:medline:creationDate&gt; $date and $pmid &lt;http://mulgara.org/mulgara/Document#title&gt; $title order by $pmid $title;"/>
-
-  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
-  <ifEqual converse="true" file="queryResult1.txt" name="queryResult">
-    <save name="queryResult" file="badQuery1Result.xml"/>
-    <fail>Output failed.  Check badQuery1Result.xml for output.</fail>
-  </ifEqual>
-
-  <set name="query" value="select $pmid $title from &lt;@server@#model1&gt; where ( $pmid &lt;http://mulgara.org/mulgara/Document#subject&gt; 'Birds' or $pmid &lt;http://mulgara.org/mulgara/Document#subject&gt; 'Bird Diseases' )  and $pmid &lt;http://mulgara.org/mulgara/Document#title&gt; $title order by $pmid $title;"/>
-
-  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
-  <ifEqual converse="true" file="queryResult2.txt" name="queryResult">
-    <save name="queryResult" file="badQuery2Result.xml"/>
-    <fail>Output failed.  Check badQuery2Result.xml for output.</fail>
-  </ifEqual>
-
-
-  <!-- check for invalid model name -->
-
-  <set name="query" value="select $pmid $title from &lt;@server@#badmodel&gt; where ( $pmid &lt;http://mulgara.org/mulgara/Document#subject&gt; 'Birds' or $pmid &lt;http://mulgara.org/mulgara/Document#subject&gt; 'Bird Diseases' )  and $pmid &lt;http://mulgara.org/mulgara/Document#title&gt; $title order by $pmid $title;"/>
-
-  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
-  <ifEqual converse="true" file="queryResult3.txt" name="queryResult">
-    <save name="queryResult" file="badQuery3Result.xml"/>
-    <fail>Output failed.  Check badQuery3Result.xml for output.</fail>
-  </ifEqual>
-
-  <set name="query"
-  value="select $pmid2 $title from &lt;@server@#model1&gt; where $date &lt;http://mulgara.org/mulgara/tool/DateExtractor#year&gt; '2000' and $date &lt;http://mulgara.org/mulgara/tool/DateExtractor#month&gt; '08' and $pmid &lt;urn:medline:creationDate&gt; $date and $pmid &lt;http://mulgara.org/mulgara/Document#title&gt; $title order by $pmid $title;"/>
-  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
-  <ifEqual converse="true" file="queryResult4.txt" name="queryResult">
-    <save name="queryResult" file="badQuery4Result.xml"/>
-    <fail>Output failed.  Check badQuery4Result.xml for output.</fail>
-  </ifEqual>
-
-
-  <!-- Check for prefix use of HybridTuples -->
-
-  <set name="query" value="select $coin $metal $shape from &lt;@server@#model2&gt; where ( ($coin &lt;coin:metal&gt; $metal) or ($coin &lt;coin:shape&gt; $shape) ) and ( ($metal &lt;coin:value&gt; &lt;coin:high&gt;) or ($shape &lt;coin:surface&gt; &lt;coin:smooth&gt;) ) order by $coin $metal $shape ;"/>
-
-  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
-  <ifEqual converse="true" file="queryResult5.txt" name="queryResult">
-    <save name="queryResult" file="badQuery5Result.xml"/>
-    <fail>Output failed.  Check badQuery5Result.xml for output.</fail>
-  </ifEqual>
-
-<!-- Check for conjunction/disjunction bug -->
-
-  <set name="query" value="select $predicate $object from &lt;@server@#model3&gt; where &lt;http://mulgara.org/mulgara#user/test&gt; $predicate $object and ( $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canCreate&gt; or $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canRead&gt; or $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canWrite&gt; or $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canDelete&gt; ) order by $predicate $object ;" />
-  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
-  <ifEqual converse="true" file="queryResult6.txt" name="queryResult">
-    <save name="queryResult" file="badQuery6Result.xml"/>
-    <fail>Output failed.  Check badQuery6Result.xml for output.</fail>
-  </ifEqual>
-
-  <set name="query" value="select $subject $predicate $object from &lt;@server@#model3&gt; where $subject $predicate $object and $subject &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#user/test&gt; and ( $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canCreate&gt; or $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canRead&gt; or $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canWrite&gt; or $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canDelete&gt; ) order by $predicate $object ;" />
-  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
-  <ifEqual converse="true" file="queryResult7.txt" name="queryResult">
-    <save name="queryResult" file="badQuery7Result.xml"/>
-    <fail>Output failed.  Check badQuery7Result.xml for output.</fail>
-  </ifEqual>
-
-  <set name="query" value="select $predicate $object from &lt;@server@#model3&gt; where &lt;http://mulgara.org/mulgara#group/dev&gt; $predicate $object and ( $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canCreate&gt; or $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canRead&gt; or $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canWrite&gt; or $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canDelete&gt; ) order by $predicate $object ;" />
-  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
-  <ifEqual converse="true" file="queryResult8.txt" name="queryResult">
-    <save name="queryResult" file="badQuery8Result.xml"/>
-    <fail>Output failed.  Check badQuery8Result.xml for output.</fail>
-  </ifEqual>
-
-  <!-- Test positive result (true) with empty select -->
-  <set name="query" value="
-    select
-    from &lt;@server@#model1&gt;
-    where &lt;urn:pmid:10941725&gt; &lt;http://mulgara.org/mulgara/Document#title&gt; 'Methylmercury accumulation in tissues and its effects on growth and appetite in captive great egrets.' ;"/>
-
-  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
-  <ifEqual converse="true" file="queryResult9.txt" name="queryResult">
-    <save name="queryResult" file="badQuery9Result.xml"/>
-    <fail>Output failed.  Check badQuery9Result.xml for output.</fail>
-  </ifEqual>
-
-  <!-- Test positive result (true) with completely constrained results joined with empty select -->
-  <set name="query" value="
-    select
-    from &lt;@server@#model1&gt;
-    where &lt;urn:pmid:10941725&gt; &lt;http://mulgara.org/mulgara/Document#title&gt; 'Methylmercury accumulation in tissues and its effects on growth and appetite in captive great egrets.' 
-    and &lt;urn:pmid:10941725&gt; &lt;http://mulgara.org/mulgara/Document#subject&gt; 'Selenium; pharmacokinetics' ;"/>
-
-  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
-  <ifEqual converse="true" file="queryResult10.txt" name="queryResult">
-    <save name="queryResult" file="badQuery10Result.xml"/>
-    <fail>Output failed.  Check badQuery10Result.xml for output.</fail>
-  </ifEqual>
-
-  <!-- Test negative result (false) empty select -->
-  <set name="query" value="
-  select
-  from &lt;@server@#model1&gt;
-  where &lt;urn:pmid:pmid&gt; &lt;urn:pmid:pmid&gt; &lt;urn:pmid:pmid&gt; ;"/>
-
-  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
-  <ifEqual converse="true" file="queryResult11.txt" name="queryResult">
-    <save name="queryResult" file="badQuery11Result.xml"/>
-    <fail>Output failed.  Check badQuery11Result.xml for output.</fail>
-  </ifEqual>
-
-  <!-- Test positive result (true) with variable constraints joined -->
-  <set name="query" value="
-  select
-  from &lt;@server@#model1&gt;
-  where $s &lt;http://mulgara.org/mulgara/Document#subject&gt; $o 
-  and $o &lt;urn:cas:name&gt; $o2 ;"/>
-
-  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
-  <ifEqual converse="true" file="queryResult12.txt" name="queryResult">
-    <save name="queryResult" file="badQuery12Result.xml"/>
-    <fail>Output failed.  Check badQuery12Result.xml for output.</fail>
-  </ifEqual>
-
-  <!-- Test multiple variables in the select clause -->
-  <set name="query" value="
-  select $pmid $pmid $title $pmid 
-  from &lt;@server@#model1&gt; 
-  where $date &lt;http://mulgara.org/mulgara/tool/DateExtractor#year&gt; '2000' 
-  and $date &lt;http://mulgara.org/mulgara/tool/DateExtractor#month&gt; '08' 
-  and $pmid &lt;urn:medline:creationDate&gt; $date 
-  and $pmid &lt;http://mulgara.org/mulgara/Document#title&gt; $title 
-  order by $pmid $title;"/>
-
-  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
-  <ifEqual converse="true" file="queryResult13.txt" name="queryResult">
-    <save name="queryResult" file="badQuery13Result.xml"/>
-    <fail>Output failed.  Check badQuery13Result.xml for output.</fail>
-  </ifEqual>
-
-  <!-- Check three duplicated variable constraints -->
-  <set name="query" value="
-    select $x
-    from &lt;@server@#allsame&gt;
-    where $x $x $x
-    order by $x;"/>
-
-  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
-  <ifEqual converse="true" file="queryResult14.txt" name="queryResult">
-    <save name="queryResult" file="badQuery14Result.xml"/>
-    <fail>Output failed.  Check badQuery14Result.xml for output.</fail>
-  </ifEqual>
-
-  <!-- Check two duplicated variable constraints -->
-  <set name="query" value="
-    select $x
-    from &lt;@server@#allsame&gt;
-    where $x &lt;urn:test:property&gt; $x
-    order by $x ;"/>
-
-  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
-  <ifEqual converse="true" file="queryResult15.txt" name="queryResult">
-    <save name="queryResult" file="badQuery15Result.xml"/>
-    <fail>Output failed.  Check badQuery15Result.xml for output.</fail>
-  </ifEqual>
-
-  <!-- local and remote model loading -->
-  <set name="modelName" value="@server@#model4" />
-  <set name="loadCommand" value="load local &lt;@baseuri@/jxdata/iTQL/data.rdf&gt; into &lt;@server@#model4&gt; ;" />
-  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
-
-  <ifEqual converse="true" file="result5.txt" name="loadResult">
-    <save name="loadResult" file="badLoadResult5.xml"/>
-    <fail>Output failed.  Check badLoadResult5.xml for output.</fail>
-  </ifEqual>
-
-  <set name="modelName" value="@server@#model5" />
-  <set name="loadCommand" value="load local &lt;@baseuri@/jxdata/iTQL/coins.rdf&gt; into &lt;@server@#model5&gt; ;" />
-  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
-
-  <ifEqual converse="true" file="result6.txt" name="loadResult">
-    <save name="loadResult" file="badLoadResult6.xml"/>
-    <fail>Output failed.  Check badLoadResult6.xml for output.</fail>
-  </ifEqual>
-
-  <set name="modelName" value="@server@#model6" />
-  <set name="loadCommand" value="load remote &lt;@baseuri@/jxdata/iTQL/security-tks.rdf&gt; into &lt;@server@#model6&gt; ;" />
-  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
-
-  <ifEqual converse="true" file="result7.txt" name="loadResult">
-    <save name="loadResult" file="badLoadResult7.xml"/>
-    <fail>Output failed.  Check badLoadResult7.xml for output.</fail>
-  </ifEqual>
-
-  <!-- jar loading -->
-  <set name="modelName" value="@server@#model7" />
-  <set name="loadCommand" value="load remote &lt;jar:@baseuri@/dist/@mulgara.jar@!/data/w3c-news.rss&gt; into &lt;@server@#model7&gt; ;" />
-  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
-
-  <ifEqual converse="true" file="result9.txt" name="loadResult">
-    <save name="loadResult" file="badLoadResult9.xml"/>
-    <fail>Output failed.  Check badLoadResult9.xml for output.</fail>
-  </ifEqual>
-
-  <set name="modelName" value="@server@#model7" />
-  <set name="loadCommand" value="load local &lt;jar:@baseuri@/dist/@mulgara.jar@!/data/w3c-news.rss&gt; into &lt;@server@#model7&gt; ;" />
-  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
-
-  <ifEqual converse="true" file="result9.txt" name="loadResult">
-    <save name="loadResult" file="badLoadResult9.xml"/>
-    <fail>Output failed.  Check badLoadResult9.xml for output.</fail>
-  </ifEqual>
-
-  <set name="modelName" value="@server@#model8" />
-  <set name="loadCommand" value="load local &lt;@baseuri@/jxdata/iTQL/numbers.rdf.gz&gt; into &lt;@server@#model8&gt; ;" />
-  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
-
-  <ifEqual converse="true" file="result10.txt" name="loadResult">
-    <save name="loadResult" file="badLoadResult10.xml"/>
-    <fail>Output failed.  Check badLoadResult10.xml for output.</fail>
-  </ifEqual>
-
-  <set name="query" value="
-    select $model
-    from &lt;@server@#&gt;
-    where $model &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&gt; $type
-    and $s $p $o in $model ; "/>
-
-  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
-
-  <!-- Test error message for non-existant model -->
-  <set name="query" value="
-    insert &lt;http://test.com/&gt;
-      &lt;http://cdls.nstl.gov.cn/cdls2/w3c/2003/Metadata/elements/title&gt;
-      &apos;test2 escape char &lt;&apos; into &lt;rmi://localhost/server1#nomodelexistswiththisname&gt; ; "/>
-
-  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
-  <ifEqual converse="true" file="queryResult17.txt" name="queryResult">
-    <save name="queryResult" file="badQuery17Result.xml"/>
-    <fail>Output failed.  Check badQuery17Result.xml for output.</fail>
-  </ifEqual>
-
-  <!-- Test error message for opaque URI for model name -->
-  <set name="query" value="
-    select $s $p $o from &lt;mailto:foo at bar.com&gt; where $s $p $o ; "/>
-
-  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
-  <ifEqual converse="true" file="queryResult18.txt" name="queryResult">
-    <save name="queryResult" file="badQuery18Result.xml"/>
-    <fail>Output failed.  Check badQuery18Result.xml for output.</fail>
-  </ifEqual>
-
-  <!-- Test error message for non-existant server -->
-  <set name="query" value="
-    insert &lt;http://test.com/&gt;
-      &lt;http://cdls.nstl.gov.cn/cdls2/w3c/2003/Metadata/elements/title&gt;
-      &apos;test2 escape char &lt;&apos; into &lt;rmi://localhost/server2#nomodelexistswiththisname&gt; ; "/>
-
-  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
-  <ifEqual converse="true" file="queryResult19.txt" name="queryResult">
-    <save name="queryResult" file="badQuery19Result.xml"/>
-    <fail>Output failed.  Check badQuery19Result.xml for output.</fail>
-  </ifEqual>
-</jxu>
+<jxu>
+  <set name="debug" value="false" />
+
+  <set name="modelName" value="@server@#model1" />
+  <set name="loadCommand" value="load &lt;@baseuri@/jxdata/iTQL/data.rdf&gt; into &lt;@server@#model1&gt; ;" />
+  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
+
+  <ifEqual converse="true" file="result1.txt" name="loadResult">
+    <save name="loadResult" file="badLoadResult.xml"/>
+    <fail>Output failed.  Check badLoadResult.xml for output.</fail>
+  </ifEqual>
+
+  <set name="modelName" value="@server@#model2" />
+  <set name="loadCommand" value="load &lt;@baseuri@/jxdata/iTQL/coins.rdf&gt; into &lt;@server@#model2&gt; ;" />
+  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
+
+  <ifEqual converse="true" file="result2.txt" name="loadResult">
+    <save name="loadResult" file="badLoadResult2.xml"/>
+    <fail>Output failed.  Check badLoadResult2.xml for output.</fail>
+  </ifEqual>
+
+  <set name="modelName" value="@server@#model3" />
+  <set name="loadCommand" value="load &lt;@baseuri@/jxdata/iTQL/security-tks.rdf&gt; into &lt;@server@#model3&gt; ;" />
+  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
+
+  <ifEqual converse="true" file="result3.txt" name="loadResult">
+    <save name="loadResult" file="badLoadResult3.xml"/>
+    <fail>Output failed.  Check badLoadResult3.xml for output.</fail>
+  </ifEqual>
+
+  <!--  Add a dummy model to test duplicate constraint bug -->
+  <set name="modelName" value="@server@#allsame2" />
+  <set name="loadCommand" value="load &lt;@baseuri@/jxdata/iTQL/testpred.rdf&gt; into &lt;@server@#allsame2&gt; ;" />
+  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
+
+  <ifEqual converse="true" file="result8.txt" name="loadResult">
+    <save name="loadResult" file="badLoadResult8.xml"/>
+    <fail>Output failed.  Check badLoadResult8.xml for output.</fail>
+  </ifEqual>
+
+  <set name="modelName" value="@server@#allsame" />
+  <set name="loadCommand" value="load &lt;@baseuri@/jxdata/iTQL/testsame.rdf&gt; into &lt;@server@#allsame&gt; ;" />
+  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
+
+  <ifEqual converse="true" file="result4.txt" name="loadResult">
+    <save name="loadResult" file="badLoadResult4.xml"/>
+    <fail>Output failed.  Check badLoadResult4.xml for output.</fail>
+  </ifEqual>
+
+  <set name="query" value="select $pmid $title from &lt;@server@#model1&gt; where $date &lt;http://mulgara.org/mulgara/tool/DateExtractor#year&gt; '2000' and $date &lt;http://mulgara.org/mulgara/tool/DateExtractor#month&gt; '08' and $pmid &lt;urn:medline:creationDate&gt; $date and $pmid &lt;http://mulgara.org/mulgara/Document#title&gt; $title order by $pmid $title;"/>
+
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult1.txt" name="queryResult">
+    <save name="queryResult" file="badQuery1Result.xml"/>
+    <fail>Output failed.  Check badQuery1Result.xml for output.</fail>
+  </ifEqual>
+
+  <set name="query" value="select $pmid $title from &lt;@server@#model1&gt; where ( $pmid &lt;http://mulgara.org/mulgara/Document#subject&gt; 'Birds' or $pmid &lt;http://mulgara.org/mulgara/Document#subject&gt; 'Bird Diseases' )  and $pmid &lt;http://mulgara.org/mulgara/Document#title&gt; $title order by $pmid $title;"/>
+
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult2.txt" name="queryResult">
+    <save name="queryResult" file="badQuery2Result.xml"/>
+    <fail>Output failed.  Check badQuery2Result.xml for output.</fail>
+  </ifEqual>
+
+
+  <!-- check for invalid model name -->
+
+  <set name="query" value="select $pmid $title from &lt;@server@#badmodel&gt; where ( $pmid &lt;http://mulgara.org/mulgara/Document#subject&gt; 'Birds' or $pmid &lt;http://mulgara.org/mulgara/Document#subject&gt; 'Bird Diseases' )  and $pmid &lt;http://mulgara.org/mulgara/Document#title&gt; $title order by $pmid $title;"/>
+
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult3.txt" name="queryResult">
+    <save name="queryResult" file="badQuery3Result.xml"/>
+    <fail>Output failed.  Check badQuery3Result.xml for output.</fail>
+  </ifEqual>
+
+  <set name="query"
+  value="select $pmid2 $title from &lt;@server@#model1&gt; where $date &lt;http://mulgara.org/mulgara/tool/DateExtractor#year&gt; '2000' and $date &lt;http://mulgara.org/mulgara/tool/DateExtractor#month&gt; '08' and $pmid &lt;urn:medline:creationDate&gt; $date and $pmid &lt;http://mulgara.org/mulgara/Document#title&gt; $title order by $pmid $title;"/>
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult4.txt" name="queryResult">
+    <save name="queryResult" file="badQuery4Result.xml"/>
+    <fail>Output failed.  Check badQuery4Result.xml for output.</fail>
+  </ifEqual>
+
+
+  <!-- Check for prefix use of HybridTuples -->
+
+  <set name="query" value="select $coin $metal $shape from &lt;@server@#model2&gt; where ( ($coin &lt;coin:metal&gt; $metal) or ($coin &lt;coin:shape&gt; $shape) ) and ( ($metal &lt;coin:value&gt; &lt;coin:high&gt;) or ($shape &lt;coin:surface&gt; &lt;coin:smooth&gt;) ) order by $coin $metal $shape ;"/>
+
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult5.txt" name="queryResult">
+    <save name="queryResult" file="badQuery5Result.xml"/>
+    <fail>Output failed.  Check badQuery5Result.xml for output.</fail>
+  </ifEqual>
+
+<!-- Check for conjunction/disjunction bug -->
+
+  <set name="query" value="select $predicate $object from &lt;@server@#model3&gt; where &lt;http://mulgara.org/mulgara#user/test&gt; $predicate $object and ( $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canCreate&gt; or $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canRead&gt; or $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canWrite&gt; or $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canDelete&gt; ) order by $predicate $object ;" />
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult6.txt" name="queryResult">
+    <save name="queryResult" file="badQuery6Result.xml"/>
+    <fail>Output failed.  Check badQuery6Result.xml for output.</fail>
+  </ifEqual>
+
+  <set name="query" value="select $subject $predicate $object from &lt;@server@#model3&gt; where $subject $predicate $object and $subject &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#user/test&gt; and ( $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canCreate&gt; or $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canRead&gt; or $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canWrite&gt; or $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canDelete&gt; ) order by $predicate $object ;" />
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult7.txt" name="queryResult">
+    <save name="queryResult" file="badQuery7Result.xml"/>
+    <fail>Output failed.  Check badQuery7Result.xml for output.</fail>
+  </ifEqual>
+
+  <set name="query" value="select $predicate $object from &lt;@server@#model3&gt; where &lt;http://mulgara.org/mulgara#group/dev&gt; $predicate $object and ( $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canCreate&gt; or $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canRead&gt; or $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canWrite&gt; or $predicate &lt;http://mulgara.org/mulgara#is&gt; &lt;http://mulgara.org/mulgara#canDelete&gt; ) order by $predicate $object ;" />
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult8.txt" name="queryResult">
+    <save name="queryResult" file="badQuery8Result.xml"/>
+    <fail>Output failed.  Check badQuery8Result.xml for output.</fail>
+  </ifEqual>
+
+  <!-- Test positive result (true) with empty select -->
+  <set name="query" value="
+    select
+    from &lt;@server@#model1&gt;
+    where &lt;urn:pmid:10941725&gt; &lt;http://mulgara.org/mulgara/Document#title&gt; 'Methylmercury accumulation in tissues and its effects on growth and appetite in captive great egrets.' ;"/>
+
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult9.txt" name="queryResult">
+    <save name="queryResult" file="badQuery9Result.xml"/>
+    <fail>Output failed.  Check badQuery9Result.xml for output.</fail>
+  </ifEqual>
+
+  <!-- Test positive result (true) with completely constrained results joined with empty select -->
+  <set name="query" value="
+    select
+    from &lt;@server@#model1&gt;
+    where &lt;urn:pmid:10941725&gt; &lt;http://mulgara.org/mulgara/Document#title&gt; 'Methylmercury accumulation in tissues and its effects on growth and appetite in captive great egrets.' 
+    and &lt;urn:pmid:10941725&gt; &lt;http://mulgara.org/mulgara/Document#subject&gt; 'Selenium; pharmacokinetics' ;"/>
+
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult10.txt" name="queryResult">
+    <save name="queryResult" file="badQuery10Result.xml"/>
+    <fail>Output failed.  Check badQuery10Result.xml for output.</fail>
+  </ifEqual>
+
+  <!-- Test negative result (false) empty select -->
+  <set name="query" value="
+  select
+  from &lt;@server@#model1&gt;
+  where &lt;urn:pmid:pmid&gt; &lt;urn:pmid:pmid&gt; &lt;urn:pmid:pmid&gt; ;"/>
+
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult11.txt" name="queryResult">
+    <save name="queryResult" file="badQuery11Result.xml"/>
+    <fail>Output failed.  Check badQuery11Result.xml for output.</fail>
+  </ifEqual>
+
+  <!-- Test positive result (true) with variable constraints joined -->
+  <set name="query" value="
+  select
+  from &lt;@server@#model1&gt;
+  where $s &lt;http://mulgara.org/mulgara/Document#subject&gt; $o 
+  and $o &lt;urn:cas:name&gt; $o2 ;"/>
+
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult12.txt" name="queryResult">
+    <save name="queryResult" file="badQuery12Result.xml"/>
+    <fail>Output failed.  Check badQuery12Result.xml for output.</fail>
+  </ifEqual>
+
+  <!-- Test multiple variables in the select clause -->
+  <set name="query" value="
+  select $pmid $pmid $title $pmid 
+  from &lt;@server@#model1&gt; 
+  where $date &lt;http://mulgara.org/mulgara/tool/DateExtractor#year&gt; '2000' 
+  and $date &lt;http://mulgara.org/mulgara/tool/DateExtractor#month&gt; '08' 
+  and $pmid &lt;urn:medline:creationDate&gt; $date 
+  and $pmid &lt;http://mulgara.org/mulgara/Document#title&gt; $title 
+  order by $pmid $title;"/>
+
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult13.txt" name="queryResult">
+    <save name="queryResult" file="badQuery13Result.xml"/>
+    <fail>Output failed.  Check badQuery13Result.xml for output.</fail>
+  </ifEqual>
+
+  <!-- Check three duplicated variable constraints -->
+  <set name="query" value="
+    select $x
+    from &lt;@server@#allsame&gt;
+    where $x $x $x
+    order by $x;"/>
+
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult14.txt" name="queryResult">
+    <save name="queryResult" file="badQuery14Result.xml"/>
+    <fail>Output failed.  Check badQuery14Result.xml for output.</fail>
+  </ifEqual>
+
+  <!-- Check two duplicated variable constraints -->
+  <set name="query" value="
+    select $x
+    from &lt;@server@#allsame&gt;
+    where $x &lt;urn:test:property&gt; $x
+    order by $x ;"/>
+
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult15.txt" name="queryResult">
+    <save name="queryResult" file="badQuery15Result.xml"/>
+    <fail>Output failed.  Check badQuery15Result.xml for output.</fail>
+  </ifEqual>
+
+  <!-- local and remote model loading -->
+  <set name="modelName" value="@server@#model4" />
+  <set name="loadCommand" value="load local &lt;@baseuri@/jxdata/iTQL/data.rdf&gt; into &lt;@server@#model4&gt; ;" />
+  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
+
+  <ifEqual converse="true" file="result5.txt" name="loadResult">
+    <save name="loadResult" file="badLoadResult5.xml"/>
+    <fail>Output failed.  Check badLoadResult5.xml for output.</fail>
+  </ifEqual>
+
+  <set name="modelName" value="@server@#model5" />
+  <set name="loadCommand" value="load local &lt;@baseuri@/jxdata/iTQL/coins.rdf&gt; into &lt;@server@#model5&gt; ;" />
+  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
+
+  <ifEqual converse="true" file="result6.txt" name="loadResult">
+    <save name="loadResult" file="badLoadResult6.xml"/>
+    <fail>Output failed.  Check badLoadResult6.xml for output.</fail>
+  </ifEqual>
+
+  <set name="modelName" value="@server@#model6" />
+  <set name="loadCommand" value="load remote &lt;@baseuri@/jxdata/iTQL/security-tks.rdf&gt; into &lt;@server@#model6&gt; ;" />
+  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
+
+  <ifEqual converse="true" file="result7.txt" name="loadResult">
+    <save name="loadResult" file="badLoadResult7.xml"/>
+    <fail>Output failed.  Check badLoadResult7.xml for output.</fail>
+  </ifEqual>
+
+  <!-- jar loading -->
+  <set name="modelName" value="@server@#model7" />
+  <set name="loadCommand" value="load remote &lt;jar:@baseuri@/dist/@mulgara.jar@!/data/w3c-news.rss&gt; into &lt;@server@#model7&gt; ;" />
+  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
+
+  <ifEqual converse="true" file="result9.txt" name="loadResult">
+    <save name="loadResult" file="badLoadResult9.xml"/>
+    <fail>Output failed.  Check badLoadResult9.xml for output.</fail>
+  </ifEqual>
+
+  <set name="modelName" value="@server@#model7" />
+  <set name="loadCommand" value="load local &lt;jar:@baseuri@/dist/@mulgara.jar@!/data/w3c-news.rss&gt; into &lt;@server@#model7&gt; ;" />
+  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
+
+  <ifEqual converse="true" file="result9.txt" name="loadResult">
+    <save name="loadResult" file="badLoadResult9.xml"/>
+    <fail>Output failed.  Check badLoadResult9.xml for output.</fail>
+  </ifEqual>
+
+  <set name="modelName" value="@server@#model8" />
+  <set name="loadCommand" value="load local &lt;@baseuri@/jxdata/iTQL/numbers.rdf.gz&gt; into &lt;@server@#model8&gt; ;" />
+  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
+
+  <ifEqual converse="true" file="result10.txt" name="loadResult">
+    <save name="loadResult" file="badLoadResult10.xml"/>
+    <fail>Output failed.  Check badLoadResult10.xml for output.</fail>
+  </ifEqual>
+
+  <set name="query" value="
+    select $model
+    from &lt;@server@#&gt;
+    where $model &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&gt; $type
+    and $s $p $o in $model ; "/>
+
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+
+  <!-- Test error message for non-existant model -->
+  <set name="query" value="
+    insert &lt;http://test.com/&gt;
+      &lt;http://cdls.nstl.gov.cn/cdls2/w3c/2003/Metadata/elements/title&gt;
+      &apos;test2 escape char &lt;&apos; into &lt;rmi://localhost/server1#nomodelexistswiththisname&gt; ; "/>
+
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult17.txt" name="queryResult">
+    <save name="queryResult" file="badQuery17Result.xml"/>
+    <fail>Output failed.  Check badQuery17Result.xml for output.</fail>
+  </ifEqual>
+
+  <!-- Test error message for opaque URI for model name -->
+  <set name="query" value="
+    select $s $p $o from &lt;mailto:foo at bar.com&gt; where $s $p $o ; "/>
+
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult18.txt" name="queryResult">
+    <save name="queryResult" file="badQuery18Result.xml"/>
+    <fail>Output failed.  Check badQuery18Result.xml for output.</fail>
+  </ifEqual>
+
+  <!-- Test error message for non-existant server -->
+  <set name="query" value="
+    insert &lt;http://test.com/&gt;
+      &lt;http://cdls.nstl.gov.cn/cdls2/w3c/2003/Metadata/elements/title&gt;
+      &apos;test2 escape char &lt;&apos; into &lt;@server2@#nomodelexistswiththisname&gt; ; "/>
+
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult19.txt" name="queryResult">
+    <save name="queryResult" file="badQuery19Result.xml"/>
+    <fail>Output failed.  Check badQuery19Result.xml for output.</fail>
+  </ifEqual>
+</jxu>

Deleted: branches/mgr-121-lockrecovery/lib/DateUtils1.jar
===================================================================
(Binary files differ)

Copied: branches/mgr-121-lockrecovery/lib/joda-time-1.5.2.jar (from rev 1002, trunk/lib/joda-time-1.5.2.jar)
===================================================================
(Binary files differ)

Modified: branches/mgr-121-lockrecovery/lib/jrdf-0.3.4.3.jar
===================================================================
(Binary files differ)

Modified: branches/mgr-121-lockrecovery/lib/mulgara-sparql-0.0.1.jar
===================================================================
(Binary files differ)

Modified: branches/mgr-121-lockrecovery/src/jar/driver/build.xml
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/driver/build.xml	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/driver/build.xml	2008-06-19 03:35:29 UTC (rev 1005)
@@ -94,7 +94,7 @@
 
   <target name="driver-dist"
           depends="driver-jar, driver-jar, itql-jar, query-jar,
-                   server-jar, server-beep-jar, server-rmi-jar, util-jar"
+                   server-jar, server-beep-jar, server-rmi-jar, util-jar, driver-uptodate"
           unless="driver.uptodate"
           description="Performs all tasks related to finalising this driver
                        and readying it for distribution">
@@ -119,6 +119,22 @@
     </jar>
   </target>
 
+  <target name="driver-uptodate">
+
+    <uptodate property="driver.uptodate"
+              targetfile="${dist.dir}/${driver.jar}">
+
+      <srcfiles dir="${driver.dist.dir}" includes="${driver.jar}"/>
+      <srcfiles dir="${itql.dist.dir}" includes="${itql.jar}"/>
+      <srcfiles dir="${rules.dist.dir}" includes="${rules.jar}"/>
+      <srcfiles dir="${query.dist.dir}" includes="${query.jar}"/>
+      <srcfiles dir="${server.dist.dir}" includes="${server.jar}"/>
+      <srcfiles dir="${server-beep.dist.dir}" includes="${server-beep.jar}"/>
+      <srcfiles dir="${server-rmi.dist.dir}" includes="${server-rmi.jar}"/>
+      <srcfiles dir="${util.dist.dir}" includes="${util.jar}"/>
+    </uptodate>
+  </target>
+
   <target name="driver-test"
           depends="driver-jar"
           description="Carries out unit testing for this driver">

Modified: branches/mgr-121-lockrecovery/src/jar/itql/java/org/mulgara/itql/ItqlInterpreterBeanUnitTest.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/itql/java/org/mulgara/itql/ItqlInterpreterBeanUnitTest.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/itql/java/org/mulgara/itql/ItqlInterpreterBeanUnitTest.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -176,6 +176,17 @@
 
     junit.textui.TestRunner.run(suite());
   }
+  
+  /**
+   * Convert Windows line endings...
+   */
+  private static String convertLineEndings(String str) {
+    String converted = str;
+    if (System.getProperty("os.name").toLowerCase().indexOf("win") > -1) {
+      converted = converted.replaceAll("\r\n", "\n");
+    }
+    return converted;
+  }
 
   /**
    * Test the interpreter via a direct call and a SOAP call
@@ -189,6 +200,7 @@
         "/server1#> where $s $p $o ;";
 
     String directAnswer = bean.executeQueryToString(queryString);
+    directAnswer = convertLineEndings(directAnswer);
     String soapAnswer = this.executeSoapCall(queryString);
 
     assertEquals(
@@ -205,6 +217,7 @@
 
     String queryString = "create <rmi://" + hostName + "/server1#model> ;";
     String directAnswer = bean.executeQueryToString(queryString);
+    directAnswer = convertLineEndings(directAnswer);
     String soapAnswer = this.executeSoapCall(queryString);
 
     assertEquals("A CREATE SOAP iTQL result is not the same as a direct call",
@@ -222,13 +235,12 @@
         "insert <http://google.blogspace.com/archives/000999836> <http://purl.org/rss/1.0/description> 'Google needs to stop sending it\\'s cookie and promise to only store aggregate data, with no connection between users and search terms. ; This issue was publically raised almost a year ago that Google still hasnt dealt with its inexcusable....' into <rmi://" +
         hostName + "/server1#model>;";
 
-    String lineChar = System.getProperty("line.separator");
-
     String result =
-        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + lineChar + "<answer xmlns=\"http://mulgara.org/tql#\"><query><message>Successfully inserted statements into rmi://" +
+        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<answer xmlns=\"http://mulgara.org/tql#\"><query><message>Successfully inserted statements into rmi://" +
         hostName + "/server1#model</message></query></answer>";
 
     String directAnswer = bean.executeQueryToString(queryString);
+    directAnswer = convertLineEndings(directAnswer);
     String soapAnswer = this.executeSoapCall(queryString);
 
     if (log.isDebugEnabled()) {
@@ -688,6 +700,7 @@
    *
    * @throws Exception if the test fails
    */
+  @SuppressWarnings("deprecation")
   public void testRestoreApi1() throws Exception {
 
     // log that we're executing the test
@@ -708,6 +721,7 @@
    *
    * @throws Exception if the test fails
    */
+  @SuppressWarnings("deprecation")
   public void testRoundTrip1() throws Exception {
 
     // log that we're executing the test
@@ -833,6 +847,7 @@
    *
    * @throws Exception if the test fails
    */
+  @SuppressWarnings("deprecation")
   public void testExplicitSession() throws Exception {
 
     // log that we're executing the test

Modified: branches/mgr-121-lockrecovery/src/jar/itql/java/org/mulgara/itql/TqlAutoInterpreter.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/itql/java/org/mulgara/itql/TqlAutoInterpreter.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/itql/java/org/mulgara/itql/TqlAutoInterpreter.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -12,9 +12,8 @@
 package org.mulgara.itql;
 
 import java.net.URI;
-import java.util.Collection;
+import java.util.HashMap;
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.Map;
 
 import org.apache.log4j.Logger;
@@ -68,7 +67,7 @@
   private boolean inTransaction;
 
   /** All the connections involved in the current transaction. */
-  private Collection<Connection> transConnections = new LinkedList<Connection>();
+  private Map<URI,Connection> transConnections = new HashMap<URI,Connection>();
   
   /**
    * Holds the client security domain. Need to connect this to URIs,
@@ -211,8 +210,11 @@
     if (serverUri == null && !cmd.isLocalOperation()) {
       // no server URI, but not local. Get a connection for a null URI
       // eg. select .... from <file:///...>
-      Connection connection = connectionFactory.newConnection(serverUri);
-      configureForTransaction(connection);
+      Connection connection = transConnections.get(serverUri);
+      if (connection == null) {
+        connection = connectionFactory.newConnection(serverUri);
+        configureForTransaction(serverUri, connection);
+      }
       return connection;
     }
     
@@ -233,9 +235,18 @@
    */
   Connection establishConnection(URI serverUri) throws ConnectionException, QueryException {
     // get a new connection, or use the local one for non-server operations
-    Connection connection = (serverUri == null) ? localStateConnection : connectionFactory.newConnection(serverUri);
-    // update the connection if it needs to enter a current transaction
-    configureForTransaction(connection);
+    Connection connection = null;
+    if (serverUri == null) {
+      connection = localStateConnection;
+    } else {
+      serverUri = ConnectionFactory.normalizeLocalUri(serverUri);
+      connection = transConnections.get(serverUri);
+      if (connection == null) {
+        connection = connectionFactory.newConnection(serverUri);
+        // update the connection if it needs to enter a current transaction
+        configureForTransaction(serverUri, connection);
+      }
+    }
     return connection;
   }
 
@@ -245,13 +256,13 @@
    * @param connection The connection to configure. The dummy connection is not configured.
    * @throws QueryException An error while setting up the connection for the transaction.
    */
-  private void configureForTransaction(Connection connection) throws QueryException {
+  private void configureForTransaction(URI serverUri, Connection connection) throws QueryException {
     // If in a transaction, turn off autocommit - ignore the dummy connection
     if (inTransaction && connection.getAutoCommit() && connection != localStateConnection) {
       assert !(connection instanceof DummyConnection);
       connection.setAutoCommit(false);
-      assert !transConnections.contains(connection);
-      transConnections.add(connection);
+      assert !transConnections.containsValue(connection);
+      transConnections.put(serverUri, connection);
     }
   }
 
@@ -367,7 +378,7 @@
     String errorMessage = null;
 
     // Operate on all outstanding transactions.
-    Iterator<Connection> c = transConnections.iterator();
+    Iterator<Connection> c = transConnections.values().iterator();
     while (c.hasNext()) {
       try {
         // do the work

Modified: branches/mgr-121-lockrecovery/src/jar/krule/java/org/mulgara/krule/Rule.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/krule/java/org/mulgara/krule/Rule.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/krule/java/org/mulgara/krule/Rule.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -76,7 +76,7 @@
 
   /** The most recent size of the data matching this rule. */
   private long lastCount;
-  
+
   /** The structure containing this rule */
   private RuleStructure ruleStruct;
 
@@ -152,14 +152,14 @@
     return Collections.unmodifiableSet(triggerSet);
   }
 
-  
+
   /**
    * Sets the rule system structure containing this rule.
    * 
    * @param ruleStruct The structure for this rule.
    */
   public void setRuleStruct(RuleStructure ruleStruct) {
-  	this.ruleStruct = ruleStruct;
+    this.ruleStruct = ruleStruct;
   }
 
 
@@ -175,21 +175,21 @@
   public void execute(OperationContext context, Resolver resolver, SystemResolver sysResolver) throws QueryException, TuplesException, ResolverException {
     if (targetGraph == UNINITIALIZED) throw new IllegalStateException("Target graph has not been set");
     // see if this rule needs to be run
-  	Answer answer = null;
-  	try {
-    	try {
-        answer = context.doQuery(query);
-      } catch (Exception e) {
-        throw new QueryException("Unable to access data in rule.", e);
+    Answer answer = null;
+    try {
+      answer = context.doQuery(query);
+    } catch (Exception e) {
+      throw new QueryException("Unable to access data in rule.", e);
+    }
+    try {
+      // compare the size of the result data
+      long newCount = answer.getRowCount();
+      if (newCount == lastCount) {
+        logger.debug("Rule <" + name + "> is up to date.");
+        // this rule does not need to be run
+        return;
       }
-    	// compare the size of the result data  	
-    	long newCount = answer.getRowCount(); 
-    	if (newCount == lastCount) {
-    	  logger.debug("Rule <" + name + "> is up to date.");
-    	  // this rule does not need to be run
-    	  return;
-    	}
-    	logger.debug("Rule <" + name + "> has increased by " + (newCount - lastCount) + " entries");
+      logger.debug("Rule <" + name + "> has increased by " + (newCount - lastCount) + " entries");
       logger.debug("Inserting results of: " + query);
       if (answer instanceof AnswerImpl) {
         AnswerImpl a = (AnswerImpl)answer;
@@ -201,25 +201,25 @@
         list += "]";
         logger.debug("query has " + a.getNumberOfVariables() + " variables: " + list);
       }
-    	// insert the resulting data
+      // insert the resulting data
       insertData(answer, resolver, sysResolver);
       // update the count
       lastCount = newCount;
       logger.debug("Insertion complete, triggering rules for scheduling.");
-  	} finally {
-  	  answer.close();
-  	}
-  	// trigger subsequent rules
-  	scheduleTriggeredRules();
+    } finally {
+      answer.close();
+    }
+    // trigger subsequent rules
+    scheduleTriggeredRules();
   }
 
-  
+
   /**
    * Schedule subsequent rules.
    */
   private void scheduleTriggeredRules() {
-  	Iterator<Rule> it = triggerSet.iterator();
-  	while (it.hasNext()) ruleStruct.schedule(it.next());
+    Iterator<Rule> it = triggerSet.iterator();
+    while (it.hasNext()) ruleStruct.schedule(it.next());
   }
 
 

Modified: branches/mgr-121-lockrecovery/src/jar/query/build.xml
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/query/build.xml	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/query/build.xml	2008-06-19 03:35:29 UTC (rev 1005)
@@ -1,167 +1,171 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE project>
-
-<!-- =================================================================== -->
-<!--                       Project definition                            -->
-<!-- =================================================================== -->
-<project name="query" default="query-jar" basedir="../../..">
-
-  <!-- =================================================================== -->
-  <!--                      Property Definitions                           -->
-  <!-- =================================================================== -->
-
-  <!-- =================================================================== -->
-  <!--                              Imports                                -->
-  <!-- =================================================================== -->
-
-  <!-- =================================================================== -->
-  <!--                          Path Definitions                           -->
-  <!-- =================================================================== -->
-  <path id="query-classpath">
-
-    <path refid="common-classpath"/>
-    <fileset file="${util.dist.dir}/${util.jar}"/>
-    <fileset file="${rules.dist.dir}/${rules.jar}"/>
-  </path>
-
-  <path id="query-test-classpath">
-
-    <path refid="query-classpath"/>
-
-    <fileset file="${query.dist.dir}/${query.jar}"/>
-    <fileset file="${rules.dist.dir}/${rules.jar}"/>
-  </path>
-
-  <target name="query-clean"
-          description="Removes all compile generated files for the query">
-
-    <tstamp/>
-
-    <delete dir="${query.obj.dir}"/>
-    <delete dir="${query.test.dir}"/>
-    <delete dir="${query.dist.dir}"/>
-  </target>
-
-  <target name="-query-prepare"
-          description="Creates all directories associated with the query's
-                       compilation"
-          depends="-prepare-build">
-
-    <mkdir dir="${query.obj.dir}"/>
-    <mkdir dir="${query.test.dir}"/>
-    <mkdir dir="${query.dist.dir}"/>
-    <mkdir dir="${query.obj.dir}/classes"/>
-    <mkdir dir="${query.obj.dir}/classes/conf"/>
-    <mkdir dir="${query.obj.dir}/java"/>
-  </target>
-
-  <target name="-query-unjar-config"
-          depends="-query-unjar-config-uptodate"
-          unless="query.unjar.config.uptodate">
-
-    <unjar src="${bin.dir}/${config.jar}" dest="${query.obj.dir}/classes"/>
-  </target>
-
-  <target name="-query-unjar-config-uptodate">
-
-    <available file="${query.obj.dir}/classes/org/mulgara/config/MulgaraConfig.class"
-               property="query.unjar.config.uptodate"/>
-  </target>
-
-  <target name="query-compile"
-          depends="-query-prepare, util-jar, rules-jar, config-jar, -query-unjar-config"
-          description="Compiles all query related files included generated
-                       source code"
-          unless="query.classes.uptodate">
-
-    <javac destdir="${query.obj.dir}/classes" debug="on"
-           deprecation="on" source="1.5">
-
-      <classpath refid="query-classpath"/>
-
-      <src path="${driver.src.dir}/java"/>
-      <src path="${query.src.dir}/java"/>
-    </javac>
-  </target>
-
-  <target name="query-jar"
-          depends="query-compile, config-database, -query-jar-uptodate"
-          unless="query.jar.uptodate"
-          description="Creates the query's jar/s">
-
-    <copy file="${obj.dir}/mulgara-x-config.xml"
-          tofile="${query.obj.dir}/classes/conf/mulgara-x-config.xml"/>
-
-    <jar jarfile="${query.dist.dir}/${query.jar}">
-
-      <fileset dir="${query.obj.dir}/classes"/>
-      <fileset dir="${query.obj.dir}/java" includes="**/*.dat"/>
-    </jar>
-  </target>
-
-  <target name="-query-jar-uptodate">
-
-    <uptodate property="query.jar.uptodate"
-              targetfile="${query.dist.dir}/${query.jar}">
-      <srcfiles dir="${query.obj.dir}" includes="**/*"/>
-    </uptodate>
-  </target>
-
-  <target name="query-dist"
-          depends="query-jar"
-          unless="query.uptodate"
-          description="Performs all tasks related to finalising this query
-                       and readying it for distribution">
-
-    <!-- All that's involved in the final version of the query library
-         is the jar so we don't need to do anything because the dependencies
-         take care of the work. -->
-  </target>
-
-  <target name="query-test"
-          depends="query-jar"
-          description="Carries out unit testing for this query">
-
-    <antcall target="component-test">
-
-      <param name="classpath.id" value="query-test-classpath"/>
-      <param name="dir" value="${query.src.dir}"/>
-      <param name="jar" value="${query.jar}"/>
-    </antcall>
-  </target>
-
-  <target name="query-javadoc"
-          depends="query-jar"
-          description="Creates the javadoc for this query">
-
-    <antcall target="javadoc">
-
-      <param name="javadoc.package" value="org.mulgara.query.*,
-                                           org.mulgara.server.*"/>
-      <param name="javadoc.classpath" value="query-classpath"/>
-      <param name="javadoc.sourcepath" value="${query.src.dir}/java"/>
-    </antcall>
-  </target>
-
-  <target name="query-help"
-          description="Displays the help information for this query">
-
-    <!-- This is similar to the main project's help except the information
-         is specific to this query -->
-
-    <echo message="Welcome to the build script for ${name}."/>
-    <echo message=""/>
-    <echo message="These targets can be invoked as follows:"/>
-    <echo message="  ./build.sh &lt;target&gt;"/>
-    <echo message=""/>
-
-    <java fork="false" classname="org.apache.tools.ant.Main"
-          newenvironment="false">
-
-      <jvmarg value="${arch.bits}"/>
-
-      <arg line="-buildfile ${query.src.dir}/build.xml -projecthelp"/>
-    </java>
-
-  </target>
-</project>
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE project>
+
+<!-- =================================================================== -->
+<!--                       Project definition                            -->
+<!-- =================================================================== -->
+<project name="query" default="query-jar" basedir="../../..">
+
+  <!-- =================================================================== -->
+  <!--                      Property Definitions                           -->
+  <!-- =================================================================== -->
+
+  <!-- =================================================================== -->
+  <!--                              Imports                                -->
+  <!-- =================================================================== -->
+
+  <!-- =================================================================== -->
+  <!--                          Path Definitions                           -->
+  <!-- =================================================================== -->
+  <path id="query-classpath">
+
+    <path refid="common-classpath"/>
+    <fileset file="${util.dist.dir}/${util.jar}"/>
+    <fileset file="${rules.dist.dir}/${rules.jar}"/>
+  </path>
+
+  <path id="query-test-classpath">
+
+    <path refid="query-classpath"/>
+
+    <fileset file="${query.dist.dir}/${query.jar}"/>
+    <fileset file="${rules.dist.dir}/${rules.jar}"/>
+    <fileset file="${server-rmi.dist.dir}/${server-rmi.jar}"/>
+    <fileset file="${server-local.dist.dir}/${server-local.jar}"/>
+  </path>
+
+  <target name="query-clean"
+          description="Removes all compile generated files for the query">
+
+    <tstamp/>
+
+    <delete dir="${query.obj.dir}"/>
+    <delete dir="${query.test.dir}"/>
+    <delete dir="${query.dist.dir}"/>
+  </target>
+
+  <target name="-query-prepare"
+          description="Creates all directories associated with the query's
+                       compilation"
+          depends="-prepare-build">
+
+    <mkdir dir="${query.obj.dir}"/>
+    <mkdir dir="${query.test.dir}"/>
+    <mkdir dir="${query.dist.dir}"/>
+    <mkdir dir="${query.obj.dir}/classes"/>
+    <mkdir dir="${query.obj.dir}/classes/conf"/>
+    <mkdir dir="${query.obj.dir}/java"/>
+  </target>
+
+  <target name="-query-unjar-config"
+          depends="-query-unjar-config-uptodate"
+          unless="query.unjar.config.uptodate">
+
+    <unjar src="${bin.dir}/${config.jar}" dest="${query.obj.dir}/classes"/>
+  </target>
+
+  <target name="-query-unjar-config-uptodate">
+
+    <available file="${query.obj.dir}/classes/org/mulgara/config/MulgaraConfig.class"
+               property="query.unjar.config.uptodate"/>
+  </target>
+
+  <target name="query-compile"
+          depends="-query-prepare, util-jar, rules-jar, config-jar, -query-unjar-config"
+          description="Compiles all query related files included generated
+                       source code"
+          unless="query.classes.uptodate">
+
+    <javac destdir="${query.obj.dir}/classes" debug="on"
+           deprecation="on" source="1.5">
+
+      <classpath refid="query-classpath"/>
+
+      <src path="${driver.src.dir}/java"/>
+      <src path="${query.src.dir}/java"/>
+    </javac>
+  </target>
+
+  <target name="query-jar"
+          depends="query-compile, config-database, -query-jar-uptodate"
+          unless="query.jar.uptodate"
+          description="Creates the query's jar/s">
+
+    <copy file="${obj.dir}/mulgara-x-config.xml"
+          tofile="${query.obj.dir}/classes/conf/mulgara-x-config.xml"/>
+
+    <jar jarfile="${query.dist.dir}/${query.jar}">
+
+      <fileset dir="${query.obj.dir}/classes"/>
+      <fileset dir="${query.obj.dir}/java" includes="**/*.dat"/>
+    </jar>
+  </target>
+
+  <target name="-query-jar-uptodate">
+
+    <uptodate property="query.jar.uptodate"
+              targetfile="${query.dist.dir}/${query.jar}">
+      <srcfiles dir="${query.obj.dir}" includes="**/*"/>
+    </uptodate>
+  </target>
+
+  <target name="query-dist"
+          depends="query-jar"
+          unless="query.uptodate"
+          description="Performs all tasks related to finalising this query
+                       and readying it for distribution">
+
+    <!-- All that's involved in the final version of the query library
+         is the jar so we don't need to do anything because the dependencies
+         take care of the work. -->
+  </target>
+
+  <target name="query-test"
+          depends="query-jar, server-rmi-jar, server-local-jar"
+          description="Carries out unit testing for this query">
+
+    <antcall target="start"/>
+    <antcall target="component-test">
+
+      <param name="classpath.id" value="query-test-classpath"/>
+      <param name="dir" value="${query.src.dir}"/>
+      <param name="jar" value="${query.jar}"/>
+    </antcall>
+    <antcall target="stop"/>
+  </target>
+
+  <target name="query-javadoc"
+          depends="query-jar"
+          description="Creates the javadoc for this query">
+
+    <antcall target="javadoc">
+
+      <param name="javadoc.package" value="org.mulgara.query.*,
+                                           org.mulgara.server.*"/>
+      <param name="javadoc.classpath" value="query-classpath"/>
+      <param name="javadoc.sourcepath" value="${query.src.dir}/java"/>
+    </antcall>
+  </target>
+
+  <target name="query-help"
+          description="Displays the help information for this query">
+
+    <!-- This is similar to the main project's help except the information
+         is specific to this query -->
+
+    <echo message="Welcome to the build script for ${name}."/>
+    <echo message=""/>
+    <echo message="These targets can be invoked as follows:"/>
+    <echo message="  ./build.sh &lt;target&gt;"/>
+    <echo message=""/>
+
+    <java fork="false" classname="org.apache.tools.ant.Main"
+          newenvironment="false">
+
+      <jvmarg value="${arch.bits}"/>
+
+      <arg line="-buildfile ${query.src.dir}/build.xml -projecthelp"/>
+    </java>
+
+  </target>
+</project>

Modified: branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/connection/Connection.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/connection/Connection.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/connection/Connection.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -21,15 +21,31 @@
 import org.mulgara.query.operation.*;
 
 /**
- * This class abstracts connections to a server, holding any information relevant to that
+ * This interface abstracts connections to a server, holding any information relevant to that
  * connection.  For those operations that are to be performed on a server, this interface
  * is used to send the operations.  Other operations can be kept local, but the mechanism
  * appears the same to the user, thereby abstracting away the interaction that each command
  * has with servers.
  *
- * While Connections can be created with the normal constructor, it may be preferable to use
- * an instance of {@link org.mulgara.connection.ConnectionFactory} in order to cache connections
- * based on the server URI.
+ * The preferred method for instantiating a Connection is using the {@link ConnectionFactory}
+ * class.  The ConnectionFactory allows for re-use of underlying resources when connecting to
+ * servers using the server URI.  It is synchronized for use by multiple clients in a 
+ * multi-threaded environment; connections obtained concurrently by separate clients from the 
+ * same factory will not interfere with each other.  Note that while the factory is synchronized
+ * for concurrent access, the connection itself is not and should only be accessed by a single
+ * thread.  When a client connection is no longer in use, its underlying resources are returned
+ * to the factory for re-use by other clients.
+ * 
+ * Connections which are no longer in use should be closed using the {@link #close()} method.
+ * Calling this method allows the underlying session backing the connection to be released back
+ * to the factory for re-use by other clients.  This will result in increased performance in an
+ * environment where there are many short-lived connections in use.  Since the session stores
+ * credentials that are passed to the connection, a factory should only be used to cache
+ * connections in a single-user environment.  Alternatively, the {@link #dispose()} method may
+ * be used to explicitly destroy the underlying session, in which case it will not be cached and
+ * re-used by the factory.  Calling either {@link #close()} or {@link #dispose()} will cause the
+ * connection to be invalidated, and any subsequent attempts to execute an operation on it will
+ * cause an exception to be thrown.
  *
  * {@link org.mulgara.query.operation.Command}s to be issued may be executed with a Connection
  * as a parameter, or can be passed to a Connection.  The appropriate use depends on the usage.
@@ -116,6 +132,12 @@
    * Closes the current connection.
    */
   public void close() throws QueryException;
+  
+  /**
+   * Closes the current connection, disposing of any underlying resources rather
+   * than returning them to the factory for re-use.
+   */
+  public void dispose() throws QueryException;
 
   // Central execution of Command operations
 

Modified: branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/connection/ConnectionFactory.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/connection/ConnectionFactory.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/connection/ConnectionFactory.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -17,6 +17,7 @@
 import java.net.UnknownHostException;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -29,7 +30,11 @@
 
 /**
  * Creates new connections or reloads from a cache when possible connections.
- * This must NOT be shared between users, as it is designed to cache security credentials!
+ * This class is designed to be thread-safe, so that connections obtained from a factory
+ * simultaneously from different threads will be backed by different Sessions and will not
+ * interfere with each other.  When a connection is closed, it will release its underlying
+ * Session back to factory to be added to a cache for re-use by other clients.
+ * This factory must NOT be shared between users, as it is designed to cache security credentials!
  *
  * @created 2007-08-21
  * @author Paul Gearon
@@ -47,11 +52,17 @@
   /** IP constant for localhost, saved as a string */
   private final static String LOCALHOST_IP = "127.0.0.1";
   
+  /** Canonical hostname, used to normalize RMI connections on localhost */
+  private static String LOCALHOST_CANONICAL;
+  
   /** The scheme name for the local protocol */
   private final static String LOCAL_PROTOCOL = "local";
   
+  /** The scheme name for the RMI protocol */
+  private final static String RMI_PROTOCOL = "rmi";
+  
   /** The list of known protocols. */
-  private final static String[] PROTOCOLS = { "rmi", "beep", LOCAL_PROTOCOL };
+  private final static String[] PROTOCOLS = { RMI_PROTOCOL, "beep", LOCAL_PROTOCOL };
   
   /** The list of known local host aliases. */
   private final static List<String> LOCALHOSTS = new LinkedList<String>();
@@ -63,95 +74,185 @@
     try {
       LOCALHOSTS.add(InetAddress.getLocalHost().getHostAddress());
       LOCALHOSTS.add(InetAddress.getLocalHost().getHostName());
+      String name = InetAddress.getLocalHost().getCanonicalHostName();
+      LOCALHOSTS.add(name);
+      LOCALHOST_CANONICAL = name;
     } catch (UnknownHostException e) {
+      LOCALHOST_CANONICAL = LOCALHOST_NAME;
       logger.error("Unable to get local host address", e);
     }
   }
-
-  /** Cache of Connections, based on their server URI. */
-  private Map<URI,SessionConnection> cacheOnUri;
-  /** Cache of Connections, based on their session data. */
-  private Map<Session,SessionConnection> cacheOnSession;
   
-  /** A local connection.  This is only used if a local session is provided. */
-  private SessionConnection localConnection = null;
-
+  /** Cache to hold Sessions that have been released by closed connections. */
+  private Map<URI,Set<Session>> cacheOnUri;
+  
   /**
+   * Maintain references to all active sessions to prevent them from being
+   * garbage-collected.  This is necessary because we attempt to reclaim sessions from
+   * connections that have been abandoned but not closed.
+   */
+  private Set<Session> sessionsInUse;
+ 
+  /**
    * Default constructor.
    */
   public ConnectionFactory() {
-    cacheOnUri = new HashMap<URI,SessionConnection>();
-    cacheOnSession = new HashMap<Session,SessionConnection>();
+    cacheOnUri = new HashMap<URI,Set<Session>>();
+    sessionsInUse = new HashSet<Session>();
   }
+  
 
   /**
-   * Retrieve a connection based on a server URI.
+   * Retrieve a connection based on a server URI.  If there is already a cached Session
+   * for the server URI, it will be used; otherwise a new Session will be created when
+   * the SessionConnection is instantiated.
    * @param serverUri The URI to get the connection to.
    * @return The new Connection.
    * @throws ConnectionException There was an error getting a connection.
    */
   public Connection newConnection(URI serverUri) throws ConnectionException {
-    SessionConnection c = cacheOnUri.get(serverUri);
-    if (c == null) {
+    SessionConnection c = null;
+    Session session = null;
+    
+    // Try to map all addresses for localhost to the same server URI so they can share Sessions
+    serverUri = normalizeLocalUri(serverUri);
+    
+    synchronized(cacheOnUri) {
+      session = getFromCache(serverUri);
+    }
+    
+    // Let the existing re-try mecanism attempt to re-establish connectivity if necessary.
+    if (session != null && !isSessionValid(session)) {
+      session = null;
+    }
+      
+    if (session == null) {
       if (isLocalServer(serverUri)) {
-        c = (localConnection != null) ? localConnection : new SessionConnection(serverUri, false);
-        addLocalConnection(serverUri, c);
+        c = new SessionConnection(serverUri, false);
       } else {
         c = new SessionConnection(serverUri);
       }
-      cacheOnUri.put(serverUri, c);
-      cacheOnSession.put(c.getSession(), c);
+    } else {
+      c = new SessionConnection(session, null, serverUri);
     }
+    c.setFactory(this);
+    
+    // Maintain a reference to prevent garbage collection of the Session.
+    synchronized(cacheOnUri) {
+      sessionsInUse.add(c.getSession());
+    }
+     
     return c;
   }
 
 
   /**
-   * Retrieve a connection for a given session.
+   * Retrieve a connection for a given session.  This method bypasses the cache altogether
+   * and it is the responsibility of the client to manage the lifecycle of Connections and
+   * Sessions used with this method.
    * @param session The Session the Connection will use..
    * @return The new Connection.
    * @throws ConnectionException There was an error getting a connection.
    */
   public Connection newConnection(Session session) throws ConnectionException {
-    SessionConnection c = cacheOnSession.get(session);
-    if (c == null) {
-      c = new SessionConnection(session);
-      cacheOnSession.put(session, c);
-      URI serverURI = c.getServerUri();
-      if (serverURI != null) {
-        cacheOnUri.put(serverURI, c);
-        if (session.isLocal()) addLocalConnection(serverURI, c);
-      }
-      if (session.isLocal()) localConnection = c;
-    }
-    return c;
+    return new SessionConnection(session, null, null);
   }
 
 
   /**
-   * Close all connections served by this factory. Exceptions are logged, but not acted on.
+   * Close all Sessions cached by this factory. Sessions belonging to connections which are
+   * still in use will not be affected. Exceptions are logged, but not acted on.
    */
   public void closeAll() {
-    Set<SessionConnection> connectionsToClose = new HashSet<SessionConnection>(cacheOnSession.values());
-    connectionsToClose.addAll(cacheOnUri.values());
-    safeCloseAll(connectionsToClose);
+    Set<Session> sessionsToClose = null;
+    synchronized(cacheOnUri) {
+      sessionsToClose = clearCache();
+      sessionsToClose.addAll(sessionsInUse);
+      sessionsInUse.clear();
+    }
+    safeCloseAll(sessionsToClose);
   }
 
 
   /**
-   * Closes all connections in a collection. Exceptions are logged, but not acted on.
-   * @param connections The connections to close.
+   * Closes all sessions in a collection. Exceptions are logged, but not acted on.
+   * @param sessions The sessions to close.
    */
-  private void safeCloseAll(Iterable<SessionConnection> connections) {
-    for (Connection c: connections) {
+  private void safeCloseAll(Iterable<Session> sessions) {
+    for (Session s: sessions) {
       try {
-        c.close();
+        s.close();
       } catch (QueryException qe) {
-        logger.warn("Unable to close connection", qe);
+        logger.warn("Unable to close session", qe);
       }
     }
   }
   
+  
+  /**
+   * Returns a session to the cache to be re-used by new connections.  Removes it from the
+   * list of active sessions.
+   * @param serverUri The URI of the 
+   */
+  void releaseSession(URI serverUri, Session session) {
+    synchronized(cacheOnUri) {
+      addToCache(serverUri, session);
+      // The session is now referenced by the cache, no need to hold on to a second reference
+      sessionsInUse.remove(session);
+    }
+  }
+  
+  
+  /**
+   * Remove the session from the list of active sessions so it may be garbage-collected.
+   */
+  void disposeSession(Session session) {
+    synchronized(cacheOnUri) {
+      // The session was closed by the SessionConnection, no need to hold on to it any more.
+      sessionsInUse.remove(session);
+    }
+  }
+  
+  
+  /**
+   * If the given server URI uses the RMI scheme and the host is an alias for localhost,
+   * then attempt to construct a canonical server URI.  The purpose of this method is to
+   * allow multiple aliased URI's to the same server to share the same cached Sessions.
+   * @param serverUri A server URI
+   * @return The normalized server URI.
+   */
+  public static URI normalizeLocalUri(URI serverUri)
+  {
+    if (serverUri == null) {
+      return null;
+    }
+    
+    URI normalized = serverUri;
+    
+    if (RMI_PROTOCOL.equals(serverUri.getScheme())) {
+      String host = serverUri.getHost();
+      
+      boolean isLocal = false;
+      for (String h : LOCALHOSTS) {
+        if (h.equalsIgnoreCase(host)) {
+          isLocal = true;
+          break;
+        }
+      }
+      
+      if (isLocal) {
+        try {
+          normalized = new URI(RMI_PROTOCOL, null, LOCALHOST_CANONICAL, serverUri.getPort(), 
+              serverUri.getPath(), serverUri.getQuery(), serverUri.getFragment());
+        } catch (URISyntaxException use) {
+          logger.info("Error normalizing server URI to local host", use);
+        }
+      }
+    }
+    
+    return normalized;
+  }
+  
 
   /**
    * Test if a given URI is a local URI.
@@ -181,24 +282,82 @@
     // no matching hostnames
     return false;
   }
+  
+  
+  /**
+   * Tests whether the given cached Session is still valid.  This method uses the
+   * {@link Session#ping()} method to check connectivity with the remote server, and relies
+   * on the retry mechanism build into the remote session proxy to re-establish connectivity
+   * if it is lost.
+   * @param session A session.
+   * @return <code>true</code> if connectivity on the session was established.
+   */
+  static boolean isSessionValid(Session session) {
+    boolean valid;
+    try {
+      valid = session.ping();
+    }
+    catch (QueryException qe) {
+      logger.info("Error establishing connection with remote session", qe);
+      valid = false;
+    }
+    return valid;
+  }
 
 
   /**
-   * Maps all the possible localhost aliases onto the requested connection.
-   * @param serverUri The basic form of the localhost URI.
-   * @param connection The connection to associate with the local host.
+   * Retrieves a cached session for the given server URI.  If multiple sessions were
+   * cached for this URI, the first one found is returned in no particular order.  The
+   * calling code is responsible for synchronizing access to this method.  If a session is
+   * found, then it is removed from the cache and returned.
+   * @param serverURI A server URI
+   * @return A cached session for the server URI, or <code>null</code> if none was found.
    */
-  private void addLocalConnection(URI serverUri, SessionConnection connection) {
-    String path = serverUri.getRawPath();
-    for (String protocol: PROTOCOLS) {
-      for (String alias: LOCALHOSTS) {
-        try {
-          URI uri = new URI(protocol, alias, path, null);
-          cacheOnUri.put(uri, connection);
-        } catch (URISyntaxException e) {
-          logger.error("Unable to create a localhost alias URI.");
-        }
+  private Session getFromCache(URI serverURI) {
+    Session session = null;
+    
+    Set<Session> sessions = cacheOnUri.get(serverURI);
+    if (sessions != null) {
+      Iterator<Session> iter = sessions.iterator();
+      if (iter.hasNext()) {
+        session = iter.next();
       }
+      sessions.remove(session);
     }
+    
+    return session;
   }
+  
+  
+  /**
+   * Adds a session to the cache for the given URI.  The calling code is responsible for
+   * synchronizing access to this method.
+   * @param serverURI A server URI.
+   * @param session The session to cache for the server URI.
+   */
+  private void addToCache(URI serverURI, Session session) {
+    Set<Session> sessions = cacheOnUri.get(serverURI);
+    if (sessions == null) {
+      sessions = new HashSet<Session>();
+      cacheOnUri.put(serverURI, sessions);
+    }
+    sessions.add(session);
+  }
+  
+  
+  /**
+   * Clears all the contents of the cache, and returns a collection of all the Sessions that
+   * were in the cache.  The calling code is responsible for synchronizing access to this method.
+   * @return The cached Sessions.
+   */
+  private Set<Session> clearCache() {
+    Set<Session> sessions = new HashSet<Session>();
+    for (Map.Entry<URI,Set<Session>> entry : cacheOnUri.entrySet()) {
+      Set<Session> set = entry.getValue();
+      sessions.addAll(set);
+      set.clear();
+    }
+    cacheOnUri.clear();
+    return sessions;
+  }
 }

Copied: branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/connection/ConnectionFactoryUnitTest.java (from rev 1002, trunk/src/jar/query/java/org/mulgara/connection/ConnectionFactoryUnitTest.java)
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/connection/ConnectionFactoryUnitTest.java	                        (rev 0)
+++ branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/connection/ConnectionFactoryUnitTest.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -0,0 +1,308 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+package org.mulgara.connection;
+
+import java.net.InetAddress;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.mulgara.query.Answer;
+import org.mulgara.query.ConstraintImpl;
+import org.mulgara.query.ModelResource;
+import org.mulgara.query.Order;
+import org.mulgara.query.Query;
+import org.mulgara.query.SelectElement;
+import org.mulgara.query.UnconstrainedAnswer;
+import org.mulgara.query.Variable;
+import org.mulgara.server.Session;
+import org.mulgara.server.driver.SessionFactoryFinder;
+
+/**
+ * Test case for {@link ConnectionFactory}
+ * @created 2008-05-20
+ * @author Alex Hall
+ * @copyright &copy; 2008 <a href="http://www.revelytix.com">Revelytix, Inc.</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class ConnectionFactoryUnitTest extends TestCase {
+  
+  /** Factory under testing */
+  private ConnectionFactory factory;
+  /** Server that we will connect to */
+  private URI serverURI = URI.create("rmi://localhost/server1");
+  /** Simple query to execute on a Connection */
+  private Query query;
+  
+  public ConnectionFactoryUnitTest(String name) {
+    super(name);
+  }
+  
+  public static Test suite() {
+    TestSuite suite = new TestSuite();
+    suite.addTest(new ConnectionFactoryUnitTest("testConnection"));
+    suite.addTest(new ConnectionFactoryUnitTest("testCloseConnection"));
+    suite.addTest(new ConnectionFactoryUnitTest("testCacheSession"));
+    suite.addTest(new ConnectionFactoryUnitTest("testMultipleConnections"));
+    suite.addTest(new ConnectionFactoryUnitTest("testDisposeConnection"));
+    suite.addTest(new ConnectionFactoryUnitTest("testCloseAll"));
+    suite.addTest(new ConnectionFactoryUnitTest("testLocalAliasing"));
+    suite.addTest(new ConnectionFactoryUnitTest("testSessionConnection"));
+    suite.addTest(new ConnectionFactoryUnitTest("testValidSession"));
+    return suite;
+  }
+  
+  protected void setUp() throws Exception {
+    factory = new ConnectionFactory();
+    
+    // Set up a simple query to execute on the connection
+    Variable subjectVariable   = new Variable("subject");
+    Variable predicateVariable = new Variable("predicate");
+    Variable objectVariable    = new Variable("object");
+
+    List<SelectElement> selectList = new ArrayList<SelectElement>(3);
+    selectList.add(subjectVariable);
+    selectList.add(predicateVariable);
+    selectList.add(objectVariable);
+
+    query = new Query(
+      selectList,                                       // SELECT
+      new ModelResource(URI.create("rmi://localhost/server1#")), // FROM
+      new ConstraintImpl(subjectVariable,               // WHERE
+                     predicateVariable,
+                     objectVariable),
+      null,                                             // HAVING
+      Arrays.asList(new Order[] {                       // ORDER BY
+        new Order(subjectVariable, true),
+        new Order(predicateVariable, true),
+        new Order(objectVariable, true)
+      }),
+      null,                                             // LIMIT
+      0,                                                // OFFSET
+      new UnconstrainedAnswer()                         // GIVEN
+    );
+  }
+  
+  protected void tearDown() {
+    factory.closeAll();
+  }
+  
+  public void testConnection() throws Exception {
+    // Execute a simple query to ensure no exceptions.
+    Connection conn = factory.newConnection(serverURI);
+    conn.execute(query);
+  }
+  
+  private void checkValidConnection(Connection c) {
+    try {
+      Answer answer = c.execute(query);
+      answer.close();
+    } catch (Exception e) {
+      fail("Error executing query on connection that should be valid: " + e.getMessage());
+    }
+  }
+  
+  public void testCloseConnection() throws Exception {
+    Connection conn1 = factory.newConnection(serverURI);
+    Session session1 = conn1.getSession();
+    conn1.close();
+    
+    try {
+      conn1.execute(query);
+      fail("Access to closed Connection should have thrown IllegalStateException");
+    } catch (IllegalStateException ise) {
+      // Do nothing -- expected failure.
+    }
+    
+    // Should still be able to query on the underlying session.
+    Answer answer = session1.query(query);
+    answer.close();
+    
+    Connection conn2 = factory.newConnection(serverURI);
+    checkValidConnection(conn2);
+    conn2.close();
+  }
+  
+  public void testCacheSession() throws Exception {
+    Connection conn1 = factory.newConnection(serverURI);
+    checkValidConnection(conn1);
+    Session session1 = conn1.getSession();
+    conn1.close();
+    
+    Connection conn2 = factory.newConnection(serverURI);
+    checkValidConnection(conn2);
+    Session session2 = conn2.getSession();
+    
+    Connection conn3 = factory.newConnection(serverURI);
+    checkValidConnection(conn3);
+    Session session3 = conn3.getSession();
+    
+    conn2.close();
+    Connection conn4 = factory.newConnection(serverURI);
+    checkValidConnection(conn4);
+    Session session4 = conn4.getSession();
+    
+    conn3.close();
+    conn4.close();
+    
+    assertTrue("Session should be re-used between connections", session1 == session2);
+    assertTrue("Session should be re-used between connections", session1 == session4);
+    assertFalse("Session should not be shared between active connections", session1 == session3);
+  }
+  
+  public void testMultipleConnections() throws Exception {
+    Set<Session> firstSessions = new HashSet<Session>();
+    Set<Session> secondSessions = new HashSet<Session>();
+    
+    Connection conn1 = factory.newConnection(serverURI);
+    Connection conn2 = factory.newConnection(serverURI);
+    
+    checkValidConnection(conn1);
+    checkValidConnection(conn2);
+    
+    firstSessions.add(conn1.getSession());
+    firstSessions.add(conn2.getSession());
+    
+    conn1.close();
+    conn2.close();
+    
+    Connection conn3 = factory.newConnection(serverURI);
+    Connection conn4 = factory.newConnection(serverURI);
+    
+    checkValidConnection(conn3);
+    checkValidConnection(conn4);
+    
+    secondSessions.add(conn3.getSession());
+    secondSessions.add(conn4.getSession());
+    
+    conn3.close();
+    conn4.close();
+    
+    assertEquals(2, firstSessions.size());
+    assertEquals(2, secondSessions.size());
+    assertEquals(firstSessions, secondSessions);
+  }
+  
+  public void testDisposeConnection() throws Exception {
+    Connection conn1 = factory.newConnection(serverURI);
+    checkValidConnection(conn1);
+    Session session1 = conn1.getSession();
+    conn1.dispose();
+    
+    try {
+      session1.query(query);
+      fail("Session for disposed connection should be closed");
+    } catch (Exception e) {
+      // Do nothing -- expected failure.
+    }
+    
+    Connection conn2 = factory.newConnection(serverURI);
+    checkValidConnection(conn2);
+    Session session2 = conn2.getSession();
+    conn2.close();
+    
+    assertFalse(session1 == session2);
+  }
+  
+  public void testCloseAll() throws Exception {
+    Connection conn1 = factory.newConnection(serverURI);
+    checkValidConnection(conn1);
+    
+    Session session1 = conn1.getSession();
+    conn1.close();
+    factory.closeAll();
+    
+    try {
+      session1.query(query);
+      fail("Session should be closed after ConnectionFactory.closeAll()");
+    } catch (Exception e) {
+      // Do nothing -- expected failure.
+    }
+    
+    Connection conn2 = factory.newConnection(serverURI);
+    Session session2 = conn2.getSession();
+    
+    factory.closeAll();
+    try {
+      conn2.execute(query);
+      fail("Session should be closed after ConnectionFactory.closeAll()");
+    } catch (Exception e) {
+      // Do nothing -- expected failure
+    }
+    
+    conn2.close();
+    
+    Connection conn3 = factory.newConnection(serverURI);
+    checkValidConnection(conn3);
+    conn3.close();
+    
+    assertFalse(session1 == session2);    
+  }
+  
+  public void testLocalAliasing() throws Exception {
+    String localhost = InetAddress.getLocalHost().getHostName();
+    if ("localhost".equals(localhost)) {
+      localhost = "127.0.0.1";
+    }
+    URI localhostUri = URI.create("rmi://" + localhost + "/server1");
+    
+    Connection conn1 = factory.newConnection(serverURI);
+    checkValidConnection(conn1);
+    Session session1 = conn1.getSession();
+    conn1.close();
+    
+    Connection conn2 = factory.newConnection(localhostUri);
+    checkValidConnection(conn2);
+    Session session2 = conn2.getSession();
+    conn2.close();
+    
+    assertTrue("Aliases to localhost should have mapped to same session", session1 == session2);
+  }
+  
+  public void testSessionConnection() throws Exception {
+    Session session1 = SessionFactoryFinder.newSessionFactory(serverURI, true).newSession();
+    Connection conn1 = factory.newConnection(session1);
+    checkValidConnection(conn1);
+    conn1.close();
+    
+    factory.closeAll();
+    Answer answer = session1.query(query);
+    answer.close();
+    
+    Connection conn2 = factory.newConnection(serverURI);
+    checkValidConnection(conn2);
+    Session session2 = conn2.getSession();
+    conn2.close();
+    
+    // Session passed to ConnectionFactory.newConnection(Session) should not be cached by factory
+    assertFalse(session1 == session2);
+  }
+  
+  public void testValidSession() throws Exception {
+    Connection conn1 = factory.newConnection(serverURI);
+    checkValidConnection(conn1);
+    Session session = conn1.getSession();
+    conn1.close();
+    session.close();
+    
+    // The session was manually closed after being cached; the factory should pick up on this.
+    Connection conn2 = factory.newConnection(serverURI);
+    checkValidConnection(conn2);
+  }
+}

Modified: branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/connection/DummyConnection.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/connection/DummyConnection.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/connection/DummyConnection.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -95,4 +95,11 @@
   public void close() throws QueryException {
   }
   
+  
+  /**
+   * Disposes of the current connection.  Does nothing for this class.
+   */
+  public void dispose() throws QueryException {
+  }
+  
 }

Modified: branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/connection/SessionConnection.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/connection/SessionConnection.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/connection/SessionConnection.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -42,9 +42,15 @@
   
   /** The session to use for this connection. */
   private Session session;
-
+  
+  /** The factory used to create this connection */
+  private ConnectionFactory factory = null;
+  
   /** Indicates the current autocommit state */
   private boolean autoCommit = true;
+  
+  /** Indicates the connection has been closed */
+  private boolean closed = false;
 
   /**
    * Creates a new connection, given a URI to a server.
@@ -63,7 +69,7 @@
    * @param isRemote <code>true</code> for a remote session, <code>false</code> for local.
    * @throws ConnectionException There was a problem establishing the details needed for a connection.
    */
-  SessionConnection(URI serverUri, boolean isRemote) throws ConnectionException {
+  public SessionConnection(URI serverUri, boolean isRemote) throws ConnectionException {
     setServerUri(serverUri, isRemote);
   }
 
@@ -71,25 +77,54 @@
   /**
    * Creates a new connection, given a preassigned session.
    * @param session The session to connect with.
-   * @throws ConnectionException There was a problem establishing the details needed for a connection.
    */
   public SessionConnection(Session session) {
-    this(session, null);
+    this(session, null, null);
   }
   
-  
   /**
    * Creates a new connection, given a preassigned session.
    * @param session The session to connect with.
-   * @throws ConnectionException There was a problem establishing the details needed for a connection.
+   * @param securityDomainUri The security domain URI for the session
    */
   public SessionConnection(Session session, URI securityDomainUri) {
+    this(session, securityDomainUri, null);
+  }
+  
+  
+  /**
+   * Creates a new connection, given a preassigned session
+   * @param session The session to connect with
+   * @param securityDomainUri The security domain URI for the session
+   * @param serverUri The server URI, needed for re-caching the session with the factory
+   */
+  public SessionConnection(Session session, URI securityDomainUri, URI serverUri) {
     if (session == null) throw new IllegalArgumentException("Cannot create a connection without a server.");
-    setSession(session, securityDomainUri);
+    setSession(session, securityDomainUri, serverUri);    
   }
   
+    
+  /**
+   * If a Connection was abandoned by the client without being closed first, attempt to
+   * reclaim the session for use by future clients.
+   */
+  protected void finalize() throws QueryException {
+    if (!closed) {
+      close();
+    }
+  }
   
   /**
+   * Used to set a reference back to the factory that created it.  If the factory
+   * reference is set, then the session will be re-cached when this connection is closed.
+   * @param factory The factory that created this connection.
+   */
+  void setFactory(ConnectionFactory factory) {
+    this.factory = factory;
+  }
+  
+  
+  /**
    * Give login credentials and security domain to the current session.  This should only be needed
    * once since the session does not change.
    * @param securityDomainUri The security domain for the login.
@@ -97,6 +132,7 @@
    * @param password The password for the given username.
    */
   public void setCredentials(URI securityDomainUri, String user, char[] password) {
+    checkState();
     if (securityDomainUri == null) throw new IllegalArgumentException("Must have a security domain to yuse credentials");
     this.securityDomainUri = securityDomainUri;
     setCredentials(user, password);
@@ -111,6 +147,7 @@
    * @param password The password for the given username.
    */
   public void setCredentials(String user, char[] password) {
+    checkState();
     if (securityDomainUri == null) throw new IllegalArgumentException("Must have a security domain to yuse credentials");
     session.login(securityDomainUri, user, password);
   }
@@ -120,6 +157,7 @@
    * @return the session
    */
   public Session getSession() {
+    checkState();
     return session;
   }
 
@@ -131,6 +169,7 @@
    * @throws QueryException The session could not change state.
    */
   public void setAutoCommit(boolean autoCommit) throws QueryException {
+    checkState();
     if (this.autoCommit != autoCommit) {
       this.autoCommit = autoCommit;
       session.setAutoCommit(autoCommit);
@@ -142,6 +181,7 @@
    * @return the autoCommit value
    */
   public boolean getAutoCommit() {
+    checkState();
     return autoCommit;
   }
 
@@ -150,6 +190,26 @@
    * Closes the current connection.
    */
   public void close() throws QueryException {
+    checkState();
+    closed = true;
+    
+    if (factory != null) {
+      factory.releaseSession(serverUri, session);
+    }
+  }
+  
+  
+  /**
+   * Disposes of the current connection and any underlying resources.
+   */
+  public void dispose() throws QueryException {
+    checkState();
+    closed = true;
+    
+    if (factory != null) {
+      factory.disposeSession(session);
+    }
+    
     if (session != null) {
       session.close();
       session = null;
@@ -173,15 +233,26 @@
     return securityDomainUri;
   }
 
+  
+  /**
+   * Throws an IllegalStateException if the connection has already been closed.
+   */
+  private void checkState() {
+    if (closed) {
+      throw new IllegalStateException("Attempt to access a closed connection");
+    }
+  }
 
   /**
    * Sets the session information for this connection
    * @param session The session to set to.
    * @param securityDomainURI The security domain to use for the session.
    */
-  private void setSession(Session session, URI securityDomainUri) {
+  private void setSession(Session session, URI securityDomainUri, URI serverUri) {
     this.session = session;
     this.securityDomainUri = securityDomainUri;
+    this.serverUri = serverUri;
+    if (logger.isDebugEnabled()) logger.debug("Set server URI to: " + serverUri);
   }
 
 
@@ -196,21 +267,18 @@
     try {
       if (uri == null) {
         // no model given, and the factory didn't cache a connection, so make one up.
-        serverUri = SessionFactoryFinder.findServerURI();
-      } else {
-        serverUri = uri;
+        uri = SessionFactoryFinder.findServerURI();
       }
-      if (logger.isDebugEnabled()) logger.debug("Set server URI to: " + serverUri);
 
       if (logger.isDebugEnabled()) logger.debug("Finding session factory for " + uri);
       
-      SessionFactory sessionFactory = SessionFactoryFinder.newSessionFactory(serverUri, isRemote);
+      SessionFactory sessionFactory = SessionFactoryFinder.newSessionFactory(uri, isRemote);
       if (logger.isDebugEnabled()) logger.debug("Found " + sessionFactory.getClass() +
           " session factory, obtaining session with " + uri);
 
       // create a new session and set this connection to it
       if (securityDomainUri == null) securityDomainUri = sessionFactory.getSecurityDomain();
-      setSession(sessionFactory.newSession(), sessionFactory.getSecurityDomain());
+      setSession(sessionFactory.newSession(), sessionFactory.getSecurityDomain(), uri);
 
     } catch (SessionFactoryFinderException e) {
       throw new ConnectionException("Unable to connect to a server", e);

Modified: branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/query/filter/value/Var.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/query/filter/value/Var.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/query/filter/value/Var.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -177,6 +177,7 @@
 
   /** {@inheritDoc} */
   public boolean sameTerm(RDFTerm v) throws QueryException {
+    if (Var.class.equals(v.getClass())) return resolveLocal() == ((Var)v).resolveLocal();
     return resolve().sameTerm(v);
   }
 
@@ -214,7 +215,7 @@
    * @throws QueryException Indicates an error getting data out of the context, or globalizing.
    */
   public RDFTerm resolve() throws QueryException {
-    long gNode = getLocalContext().getColumnValue(varIndex);
+    long gNode = resolveLocal();
 
     Node node;
     try {
@@ -227,6 +228,15 @@
   }
 
   /**
+   * Resolve this variable to the internal gNode.
+   * @return A gNode that this variable resolves to.
+   * @throws QueryException Indicates an error getting data out of the context.
+   */
+  public long resolveLocal() throws QueryException {
+    return getLocalContext().getColumnValue(varIndex);
+  }
+
+  /**
    * Converts a node to an appropriate ExpressionValue
    * @param node The node to convert
    * @return A new ExpressionValue

Modified: branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/query/rdf/LiteralImpl.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/query/rdf/LiteralImpl.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/query/rdf/LiteralImpl.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -37,13 +37,8 @@
 // Third party packages
 import org.jrdf.graph.*;  // JRDF
 
-// Date utils
-import com.mousepushers.date.DateParser;
-import com.mousepushers.date.DateFormatter;
 
-
 // Locally written packages
-import org.mulgara.query.ConstraintElement;
 import org.mulgara.query.Value;
 
 /**
@@ -64,7 +59,7 @@
  *
  * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
  */
-public class LiteralImpl extends AbstractLiteral implements Comparable,
+public class LiteralImpl extends AbstractLiteral implements Comparable<Node>,
     Serializable, Value {
 
   /**
@@ -148,25 +143,18 @@
    * @param object PARAMETER TO DO
    * @return RETURNED VALUE TO DO
    */
-  public int compareTo(java.lang.Object object) {
+  public int compareTo(Node object) {
 
     if (object instanceof BlankNode) {
-
       return 1;
     }
 
     if (object instanceof URIReference) {
-
       return 1;
-    }
-    else if (object instanceof Literal) {
-
+    } else if (object instanceof Literal) {
       Literal literal = (Literal) object;
-
       return getLexicalForm().compareTo(literal.getLexicalForm());
-    }
-    else {
-
+    } else {
       throw new ClassCastException("Not an RDF node");
     }
   }

Modified: branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/query/rdf/XSD.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/query/rdf/XSD.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/query/rdf/XSD.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -31,14 +31,9 @@
 import java.net.URI;
 import java.util.Date;
 import java.util.HashSet;
-import java.util.Locale;
 import java.util.Set;
-import java.text.ParseException;
 
-// Date utils
-import com.mousepushers.date.DateParser;
-import com.mousepushers.date.DateFormats;
-import com.mousepushers.date.DateFormatter;
+import org.mulgara.util.LexicalDateTime;
 
 /**
  * XML Schema datatype constants.
@@ -198,70 +193,14 @@
   public final static URI BASE64_BINARY_URI = URI.create(NAMESPACE + "base64Binary");
 
   /**
-   * Date format used by <code>xsd:date</code>.
-   * This is a highly abbreviated version of ISO 8601.
-   */
-  public final static String DATE_FORMAT = DateFormats.yyyy_MM_dd_format;
-
-  /**
-   * Date format used by <code>xsd:dateTime</code>.
-   * This is a highly abbreviated version of ISO 8601.
-   */
-  public final static String DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS";
-
-  /** Date format used by <code>xsd:gYear</code>. */
-  public final static String YEAR_FORMAT = "yyyy";
-
-
-  // Set up dates for 0000 and 0001
-  public static Date ONE_BCE;
-  public static Date ONE_CE;
-
-  static {
-    try {
-      ONE_BCE = DateParser.parse("0000", YEAR_FORMAT, Locale.getDefault());
-      ONE_CE = DateParser.parse("0001", YEAR_FORMAT, Locale.getDefault());
-    } catch (ParseException e) {
-      // Should never be thrown
-      throw new IllegalArgumentException("Cannot parse date");
-    }
-  }
-
-  /**
    * Returns the lexical form of the XSD dateTime value according to
    * "3.2.7.2 Canonical representation" of
    * http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/
-   * with the following exceptions:
-   * - Timezones are not supported
-   * - Dates before 1 CE (i.e. 1 AD) are handled according to ISO 8601:2000
-   *   Second Edition:
-   *     "0000" is the lexical representation of 1 BCE
-   *     "-0001" is the lexical representation of 2 BCE
+   * with the following exception:
+   * - Timezones are not displayed, and are presumed to be default
    * @return the lexical form of the XSD dateTime value
    */
   public static String getLexicalForm(Date date) {
-    StringBuffer lexicalForm;
-    String dateTime = DateFormatter.formatDate(date, XSD.DATE_TIME_FORMAT, Locale.getDefault());
-    int len = dateTime.length();
-    if (dateTime.indexOf('.', len - 4) != -1) {
-      while (dateTime.charAt(len - 1) == '0') len--;
-      if (dateTime.charAt(len - 1) == '.') len--;
-
-      lexicalForm = new StringBuffer(dateTime.substring(0, len));
-    } else {
-      lexicalForm = new StringBuffer(dateTime);
-    }
-
-    if (date.before(ONE_CE)) {
-      StringBuffer year = new StringBuffer(String.valueOf(Integer.parseInt(
-          DateFormatter.formatDate(date, YEAR_FORMAT, Locale.getDefault())) - 1));
-
-      while (year.length() < 4) year.insert(0, '0');
-
-      lexicalForm.replace(0, lexicalForm.indexOf("-", 4), year.toString());
-
-      if (date.before(ONE_BCE)) lexicalForm.insert(0, "-");
-    }
-    return lexicalForm.toString();
+    return new LexicalDateTime(date.getTime()).toString();
   }
 }

Modified: branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/server/Session.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/server/Session.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/query/java/org/mulgara/server/Session.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -340,6 +340,14 @@
    */
   public XAResource getXAResource() throws QueryException;
   public XAResource getReadOnlyXAResource() throws QueryException;
+  
+  /**
+   * Test the connectivity of a session.  All implementing classes should return
+   * <code>true</code>.  This method is intended for session proxies to establish
+   * connectivity on a remote session.
+   * @return <code>true</code> if connectivity with the session was established.
+   */
+  public boolean ping() throws QueryException;
 
   /**
    * This class is just a devious way to get static initialization for the

Modified: branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/AppendAggregateTuples.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/AppendAggregateTuples.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/AppendAggregateTuples.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -135,9 +135,12 @@
 
     // Prep variable list
     Variable[] tupleVars = this.tuples.getVariables();
+    // the size of variableList may be larger due to repeated variables,
+    // while the size of the tuples may be larger due to aggregates
+    int uniqueTupleVarLen = Math.min(variableList.size(), tupleVars.length);
 
     Set newVariableList = new LinkedHashSet();
-    for (int i = 0; i < tupleVars.length; i++) {
+    for (int i = 0; i < uniqueTupleVarLen; i++) {
       assert variableList.contains(tupleVars[i]);
 
       newVariableList.add(tupleVars[i]);
@@ -148,7 +151,7 @@
       columnIsAggregate[i] = false;
     }
     if (logger.isDebugEnabled()) {
-      logger.debug("" + hashCode() + " tupleVars.length = " + tupleVars.length);
+      logger.debug("" + hashCode() + " tupleVars.length = " + tupleVars.length + " unique vars = " + uniqueTupleVarLen);
     }
 
     // Calculate the rest of the variable list
@@ -157,14 +160,13 @@
     for (int i = 0; i < variableList.size(); i++) {
       Object element = variableList.get(i);
       if (element instanceof Count) {
-        columnAggregateIndex[tupleVars.length +
-            aggregateIndex] = aggregateIndex;
+        columnAggregateIndex[uniqueTupleVarLen + aggregateIndex] = aggregateIndex;
         if (logger.isDebugEnabled()) {
           logger.debug("" + hashCode() + " columnAggregateIndex[" +
-              tupleVars.length + aggregateIndex + "] = " + aggregateIndex);
+              uniqueTupleVarLen + aggregateIndex + "] = " + aggregateIndex);
         }
-        newVariableList.add(((Count) element).getVariable());
-        columnIsAggregate[tupleVars.length + aggregateIndex] = true;
+        newVariableList.add(((Count)element).getVariable());
+        columnIsAggregate[uniqueTupleVarLen + aggregateIndex] = true;
         aggregateIndex++;
 
         Query query = ((Count)element).getQuery();

Modified: branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/ConstraintOperations.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/ConstraintOperations.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/ConstraintOperations.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -43,6 +43,7 @@
 import org.mulgara.resolver.spi.ConstraintLocalization;
 import org.mulgara.resolver.spi.ConstraintModelRewrite;
 import org.mulgara.resolver.spi.ConstraintResolutionHandler;
+import org.mulgara.resolver.spi.ConstraintVariableRewrite;
 import org.mulgara.resolver.spi.ModelResolutionHandler;
 import org.mulgara.resolver.spi.QueryEvaluationContext;
 import org.mulgara.store.tuples.Tuples;
@@ -79,7 +80,10 @@
       new HashMap<Class<? extends ConstraintExpression>,Object>();
   static Map<Class<? extends ConstraintExpression>,Object> constraintModelRewrites =
       new HashMap<Class<? extends ConstraintExpression>,Object>();
+  static Map<Class<? extends ConstraintExpression>,Object> constraintVariableRewrites =
+    new HashMap<Class<? extends ConstraintExpression>,Object>();
 
+
   static {
     DefaultConstraintHandlers.initializeHandlers();
   }
@@ -106,6 +110,11 @@
              ConstraintExpression.class, ConstraintModelRewrite.class);
   }
 
+  static void addConstraintVariableRewrites(NVPair<Class<? extends ConstraintExpression>,Object>[] resolutionHandlers) throws RuntimeException {
+    addToMap(resolutionHandlers, constraintVariableRewrites,
+             ConstraintExpression.class, ConstraintVariableRewrite.class);
+  }
+
   static void addConstraintLocalizations(NVPair<Class<? extends ConstraintExpression>,Object>[] resolutionHandlers) throws RuntimeException {
     addToMap(resolutionHandlers, constraintLocalizations,
              Constraint.class, ConstraintLocalization.class);
@@ -264,6 +273,31 @@
   }
 
 
+  public static Constraint rewriteConstraintVariable(Variable modelVar, Variable newVar, Constraint constraint) throws QueryException {
+    try {
+      if (logger.isDebugEnabled()) {
+        logger.debug("Rewriting variable " + modelVar + " in " + constraint + " and setting graph");
+      }
+
+      ConstraintVariableRewrite op = (ConstraintVariableRewrite)constraintVariableRewrites.get(constraint.getClass());
+      if (op == null) {
+        throw new QueryException("Unknown Constraint type: " + constraint.getClass() + " known types: " + constraintVariableRewrites.keySet());
+      }
+      Constraint result = op.rewrite(modelVar, newVar, constraint);
+
+      if (logger.isDebugEnabled()) {
+        logger.debug("Rewrote Graph " + modelVar + " in " + constraint + " to " + result);
+      }
+
+      return result;
+    } catch (QueryException eq) {
+      throw eq;
+    } catch (Exception e) {
+      throw new QueryException("Rewriting constraint failed", e);
+    }
+  }
+
+
   public static Constraint replace(Map<Variable,Value> bindings, Constraint constraint) throws QueryException {
     return ConstraintFactory.newConstraint(replace(bindings, constraint.getElement(0)),
                                            replace(bindings, constraint.getElement(1)),

Modified: branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/Database.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/Database.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/Database.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -60,6 +60,7 @@
 import org.mulgara.query.QueryException;
 import org.mulgara.query.rdf.Mulgara;
 import org.mulgara.resolver.spi.DatabaseMetadata;
+import org.mulgara.resolver.spi.DuplicateVariableTransformer;
 import org.mulgara.resolver.spi.FactoryInitializer;
 import org.mulgara.resolver.spi.InitializerException;
 import org.mulgara.resolver.spi.LocalizeException;
@@ -719,11 +720,15 @@
                                         metadata.getSystemModelNode())
     );
 
+    addModelType(((SystemResolverFactory)temporaryResolverFactory).getSystemModelTypeURI(),
+          temporaryResolverFactory);
+
     // Add the mandatory security adapter that protects the system model
     securityAdapterList.add(
       new SystemModelSecurityAdapter(metadata.getSystemModelNode())
     );
 
+    addSymbolicTransformation(new DuplicateVariableTransformer());
     this.ruleLoaderClassName = ruleLoaderClassName;
 
     if (logger.isDebugEnabled()) {
@@ -966,9 +971,14 @@
 
     // Make sure some other resolver factory hasn't claimed this model type
     if (internalResolverFactoryMap.containsKey(modelTypeURI)) {
-      throw new InitializerException(
-          "Model type " + modelTypeURI + " is already registered to " +
-          internalResolverFactoryMap.get(modelTypeURI));
+      // check if the other resolver factory is actually the current one
+      InternalResolverFactory rf = internalResolverFactoryMap.get(modelTypeURI);
+      if (!rf.resolverFactory.getClass().equals(resolverFactory.getClass())) {
+        throw new InitializerException("Model type " + modelTypeURI + " is already registered to " + rf.resolverFactory);
+      } else {
+        // already registered
+        return;
+      }
     }
 
     // Register this resolver factory as handling this model type

Modified: branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -235,8 +235,7 @@
           // Ensure that the host name can be extracted - in case there's an
           // opaque hostname.
           if (tmpModelName.isOpaque()) {
-            throw new QueryException("Unable to extract hostname from: " +
-                tmpModelName);
+            throw new QueryException("Unknown graph, and no hostname: " + tmpModelName);
           }
 
           // Do not test for locality if jar or file protocol

Modified: branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/DatabaseResolverFactoryInitializer.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/DatabaseResolverFactoryInitializer.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/DatabaseResolverFactoryInitializer.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -41,6 +41,8 @@
 import org.mulgara.query.Constraint;
 import org.mulgara.query.QueryException;
 import org.mulgara.resolver.spi.*;
+import org.mulgara.server.Session;
+import org.mulgara.server.SessionFactory;
 import org.mulgara.util.NVPair;
 
 // Local packages
@@ -63,6 +65,7 @@
   private final DatabaseMetadata metadata;
   private final ContentHandlerManager contentHandlerManager;
   private final ResolverFactory systemResolverFactory;
+  private final SessionFactory restrictedSessionFactory;
 
   /**
    * Sole constructor.
@@ -73,7 +76,7 @@
    */
   public DatabaseResolverFactoryInitializer(
            Set<ResolverFactory>  cachedResolverFactorySet,
-           Database              database,
+           final Database        database,
            DatabaseMetadata      metadata,
            File                  persistenceDirectory,
            ContentHandlerManager contentHandlerManager,
@@ -94,6 +97,14 @@
     this.metadata                 = metadata;
     this.contentHandlerManager    = contentHandlerManager;
     this.systemResolverFactory    = systemResolverFactory;
+
+    this.restrictedSessionFactory = new SessionFactory() {
+      public URI getSecurityDomain() throws QueryException  { return database.getSecurityDomain(); }
+      public Session newSession() throws QueryException     { return database.newSession(); }
+      public Session newJRDFSession() throws QueryException { return database.newJRDFSession(); }
+      public void close() throws QueryException  { throw new UnsupportedOperationException(); }
+      public void delete() throws QueryException { throw new UnsupportedOperationException(); }
+    };
   }
 
 
@@ -198,4 +209,8 @@
       logger.warn("Attempted to register " + constraintClass + " twice");
     }
   }
+
+  public SessionFactory getSessionFactory() {
+    return restrictedSessionFactory;
+  }
 }

Modified: branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -728,4 +728,8 @@
   public long getTransactionTimeout() {
     return transactionTimeout;
   }
+
+  public boolean ping() {
+    return true;
+  }
 }

Modified: branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/DefaultConstraintHandlers.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/DefaultConstraintHandlers.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/DefaultConstraintHandlers.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -54,11 +54,14 @@
 
 // Local packages
 import org.mulgara.query.*;
+import org.mulgara.query.filter.SameTerm;
+import org.mulgara.query.filter.value.Var;
 import org.mulgara.query.rdf.URIReferenceImpl;
 import org.mulgara.resolver.spi.ConstraintBindingHandler;
 import org.mulgara.resolver.spi.ConstraintLocalization;
 import org.mulgara.resolver.spi.ConstraintModelRewrite;
 import org.mulgara.resolver.spi.ConstraintResolutionHandler;
+import org.mulgara.resolver.spi.ConstraintVariableRewrite;
 import org.mulgara.resolver.spi.ModelResolutionHandler;
 import org.mulgara.resolver.spi.QueryEvaluationContext;
 import org.mulgara.store.tuples.Tuples;
@@ -84,6 +87,7 @@
     initializeConstraintResolutionHandlers();
     initializeConstraintBindingHandlers();
     initializeConstraintModelRewrites();
+    initializeConstraintVariableRewrites();
     initializeConstraintLocalizations();
   }
 
@@ -130,12 +134,25 @@
         new NVPair(ModelVariable.class, new ModelResolutionHandler() {
           public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr,
                                 Constraint constraint) throws Exception {
-            return context.resolve(null, ConstraintOperations.rewriteConstraintModel(((ModelVariable)modelExpr).getVariable(), constraint));
+            Variable modelVar = ((ModelVariable)modelExpr).getVariable();
+            if (constraint.getVariables().contains(modelVar)) {
+              // need to change the re-write and wrap the result in a filter
+              Variable newVar = new Variable("*" + modelVar.getName() + "0");
+              constraint = ConstraintOperations.rewriteConstraintVariable(modelVar, newVar, constraint);
+              Tuples result = context.resolve(null, constraint);
+              return TuplesOperations.filter(result, new SameTerm(convert(newVar), convert(modelVar)), context);
+            }
+            return context.resolve(null, ConstraintOperations.rewriteConstraintModel(modelVar, constraint));
           }
         })
       });
   }
 
+  /** Utility for converting a Variable to a filterable Var */
+  static Var convert(Variable v) {
+    return new Var(v.getName());
+  }
+
   @SuppressWarnings("unchecked")
   static void initializeConstraintResolutionHandlers() {
     ConstraintOperations.addConstraintResolutionHandlers(new NVPair[]
@@ -201,16 +218,22 @@
         }),
         new NVPair(ConstraintImpl.class, new ConstraintResolutionHandler() {
           public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
-            ConstraintElement constraintElem =
-              ((ConstraintImpl) constraintExpr).getModel();
+            ConstraintImpl constraint = (ConstraintImpl)constraintExpr;
+            ConstraintElement constraintElem = constraint.getModel();
             assert constraintElem != null;
             if (constraintElem.equals(Variable.FROM)) {
-              return ConstraintOperations.resolveModelExpression(context, modelExpr, (Constraint)constraintExpr);
+              return ConstraintOperations.resolveModelExpression(context, modelExpr, constraint);
             } else if (constraintElem instanceof URIReference) {
-              return ConstraintOperations.resolveModelExpression(context, new ModelResource(((URIReference)constraintElem).getURI()), (Constraint)constraintExpr);
+              return ConstraintOperations.resolveModelExpression(context, new ModelResource(((URIReference)constraintElem).getURI()), constraint);
             } else if (constraintElem instanceof LocalNode) {
-              return context.resolve(null, (ConstraintImpl)constraintExpr);
+              return context.resolve(null, constraint);
             } else if (constraintElem instanceof Variable) {
+              for (int i = 0; i < 3; i++) {
+                if (constraintElem.equals(constraint.getElement(i))) {
+                  ModelVariable modelVar = new ModelVariable((Variable)constraintElem);
+                  return ConstraintOperations.resolveModelExpression(context, modelVar, constraint);
+                }
+              }
               return context.resolve(null, (ConstraintImpl)constraintExpr);
             }
             else {
@@ -344,6 +367,25 @@
   }
 
   @SuppressWarnings("unchecked")
+  static void initializeConstraintVariableRewrites() {
+    ConstraintOperations.addConstraintVariableRewrites(new NVPair[]
+      {
+        new NVPair(ConstraintImpl.class, new ConstraintVariableRewrite() {
+          public Constraint rewrite(Variable modelVar, Variable newVar, Constraint constraint) throws Exception {
+            ConstraintElement[] ce = new ConstraintElement[3];
+            for (int e = 0; e < ce.length; e++) {
+              ce[e] = constraint.getElement(e);
+              if (ce[e] instanceof Variable && ((Variable)ce[e]).getName().equals(modelVar.getName())) {
+                ce[e] = newVar;
+              }
+            }
+            return new ConstraintImpl(ce[0], ce[1], ce[2], modelVar);
+          }
+        }),
+      });
+  }
+
+  @SuppressWarnings("unchecked")
   static void initializeConstraintLocalizations() {
     ConstraintOperations.addConstraintLocalizations(new NVPair[]
       {

Modified: branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransactionFactory.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransactionFactory.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransactionFactory.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -133,7 +133,8 @@
               }
             }
           } finally {
-            manager.releaseWriteLock(session);
+            if (manager.isHoldingWriteLock(session))    // normally this will have been released
+              manager.releaseWriteLock(session);
           }
         } else {
           logger.debug("Session does not hold write-lock");

Modified: branches/mgr-121-lockrecovery/src/jar/resolver-null/java/org/mulgara/resolver/nullres/NullResolution.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/resolver-null/java/org/mulgara/resolver/nullres/NullResolution.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/resolver-null/java/org/mulgara/resolver/nullres/NullResolution.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -53,9 +53,14 @@
     return constraint;
   }
 
-  /** @see org.mulgara.resolver.spi.Resolution#isComplete() */
+  /**
+   * @see org.mulgara.resolver.spi.Resolution#isComplete()
+   * Complete means that no other resolvers can answer this resolution,
+   * so even if they return data they will be discarded. Hence, this is
+   * never complete, so that it can be appended to.
+   */
   public boolean isComplete() {
-    return true;
+    return false;
   }
 
   /** @see org.mulgara.store.tuples.Tuples#beforeFirst(long[], int) */

Modified: branches/mgr-121-lockrecovery/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalResolver.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalResolver.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalResolver.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -242,6 +242,7 @@
     }
 
     if (!(constraint instanceof RelationalConstraint)) {
+      if (constraint.getModel() instanceof Variable) return new EmptyResolution(constraint, false);
       throw new QueryException("Relational Resolver unable to resolve constraint: " + constraint);
     }
     

Copied: branches/mgr-121-lockrecovery/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintVariableRewrite.java (from rev 1002, trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintVariableRewrite.java)
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintVariableRewrite.java	                        (rev 0)
+++ branches/mgr-121-lockrecovery/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintVariableRewrite.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -0,0 +1,38 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.resolver.spi;
+
+// Local packages
+import org.mulgara.query.Constraint;
+import org.mulgara.query.Variable;
+
+/**
+ * Used to update a given variable in a constraint to a new name.
+ *
+ * @created May 29, 2008
+ * @author Paul Gearon
+ * @copyright &copy; 2008 <a href="http://www.topazproject.org/">The Topaz Project</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+
+public interface ConstraintVariableRewrite {
+
+  /**
+   * Rewrite this constraint to use a new variable name
+   *
+   * @param graphVar the graph variable. This will appear elsewhere in the constraint.
+   * @param newVar the new variable to replace the graph variable with outside of the graph position.
+   * @param constraint the constraint to update
+   */
+    public Constraint rewrite(Variable graphVar, Variable newVar, Constraint constraint) throws Exception;
+}

Copied: branches/mgr-121-lockrecovery/src/jar/resolver-spi/java/org/mulgara/resolver/spi/DuplicateVariableTransformer.java (from rev 1002, trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/DuplicateVariableTransformer.java)
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/resolver-spi/java/org/mulgara/resolver/spi/DuplicateVariableTransformer.java	                        (rev 0)
+++ branches/mgr-121-lockrecovery/src/jar/resolver-spi/java/org/mulgara/resolver/spi/DuplicateVariableTransformer.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -0,0 +1,256 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.resolver.spi;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.mulgara.query.Constraint;
+import org.mulgara.query.ConstraintConjunction;
+import org.mulgara.query.ConstraintDifference;
+import org.mulgara.query.ConstraintDisjunction;
+import org.mulgara.query.ConstraintElement;
+import org.mulgara.query.ConstraintExpression;
+import org.mulgara.query.ConstraintFilter;
+import org.mulgara.query.ConstraintImpl;
+import org.mulgara.query.ConstraintIn;
+import org.mulgara.query.ConstraintOperation;
+import org.mulgara.query.ConstraintOptionalJoin;
+import org.mulgara.query.Variable;
+import org.mulgara.query.filter.And;
+import org.mulgara.query.filter.Filter;
+import org.mulgara.query.filter.SameTerm;
+import org.mulgara.query.filter.value.Var;
+
+/**
+ * Transforms constraint expressions to remove duplicate variables, and replace the
+ * existing constraints with filters that select matching variable values.
+ *
+ * @created May 19, 2008
+ * @author Paul Gearon
+ * @copyright &copy; 2008 <a href="http://www.topazproject.org/">The Topaz Project</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class DuplicateVariableTransformer implements SymbolicTransformation {
+
+  /**
+   * @see org.mulgara.resolver.spi.SymbolicTransformation#transform(org.mulgara.resolver.spi.SymbolicTransformationContext, org.mulgara.resolver.spi.MutableLocalQuery)
+   */
+  public void transform(SymbolicTransformationContext context, MutableLocalQuery mutableLocalQuery)
+        throws SymbolicTransformationException {
+    ConstraintExpression expr = mutableLocalQuery.getConstraintExpression();
+    ConstraintExpression trans = transformExpr(expr);
+
+    if (expr != trans) {
+      mutableLocalQuery.setConstraintExpression(trans);
+    }
+  }
+
+  public ConstraintExpression transformExpr(ConstraintExpression expr) throws SymbolicTransformationException {
+    // explicitly handle all the recursive types
+    if (expr instanceof ConstraintFilter) return transformFilter(expr);
+    if (expr instanceof ConstraintIn) return transformIn(expr);
+    if (expr instanceof ConstraintOperation) return transformOperation(expr);
+    // do the actual work of this transformer
+    if (expr instanceof Constraint) return transformConstraint(expr);
+    // By default we do not recognise the constraint type, so pass it unchanged.
+    return expr;
+  }
+
+  ConstraintFilter transformFilter(ConstraintExpression expr) throws SymbolicTransformationException {
+    ConstraintFilter filter = (ConstraintFilter)expr;
+    ConstraintExpression inner = filter.getUnfilteredConstraint();
+    ConstraintExpression tx = transformExpr(inner);
+    return (tx == inner) ? filter : new ConstraintFilter(tx, filter.getFilter());
+  }
+  
+  ConstraintIn transformIn(ConstraintExpression expr) throws SymbolicTransformationException {
+    ConstraintIn in = (ConstraintIn)expr;
+    ConstraintExpression inner = in.getConstraintParam();
+    ConstraintExpression tx = transformExpr(inner);
+    return (tx == inner) ? in : new ConstraintIn(tx, in.getGraph());
+  }
+
+  ConstraintOperation transformOperation(ConstraintExpression expr) throws SymbolicTransformationException {
+    ConstraintOperation operation = (ConstraintOperation)expr;
+    List<ConstraintExpression> ops = operation.getElements();
+    List<ConstraintExpression> newOps = new ArrayList<ConstraintExpression>(ops.size());
+    boolean changed = false;
+    for (ConstraintExpression op: ops) {
+      ConstraintExpression tx = transformExpr(op);
+      newOps.add(tx);
+      if (tx != op) changed = true;
+    }
+    if (changed) {
+      OpType operationType = OpType.getType(operation);
+      if (operationType == null) throw new SymbolicTransformationException("Encountered an unknown operation type: " + operation.getClass());
+      return operationType.newOp(newOps);
+    }
+    return operation; 
+  }
+
+  /**
+   * All the work of this class is performed in this method. It ignores general constraints,
+   * and converts a ConstraintImpls with repeated variables into a conjunction of terms
+   * which have non-repeating variables, joined in an equivalent way to the original constraint.
+   * @param expr The expression to transform.
+   * @return The original constraint, or else a new equivalent conjunction if expr contains
+   *         a repeated variable.
+   * @throws SymbolicTransformationException If there is an error in the constraint structure.
+   */
+  ConstraintExpression transformConstraint(ConstraintExpression expr) throws SymbolicTransformationException {
+    if (!((Constraint)expr).isRepeating()) return (Constraint)expr;
+    ConstraintImpl cnstr = (ConstraintImpl)expr;
+    VarFreq vf = new VarFreq(cnstr);
+
+    // build the equivalent term
+    ConstraintElement[] elements = buildElements(cnstr, vf);
+    expr = new ConstraintImpl(elements[0], elements[1], elements[2], elements[3]);
+
+    // if there was only a pair then return it as a simple filter
+    if (vf.frequency == 2) return new ConstraintFilter(expr, createSameTermPair(vf.repeatedVar, 1));
+
+    // build a conjunction of filters
+    int matches = vf.frequency - 1;
+    Filter[] sameTerms = new Filter[matches];
+    for (int f = 0; f < matches; f++) sameTerms[f] = createSameTermPair(vf.repeatedVar, f + 1);
+    return new ConstraintFilter(expr, new And(sameTerms));
+  }
+
+  /**
+   * Creates a filter which compares a pair of related variables for equality 
+   * @param var The initial variable to compare.
+   * @param offset The offset from the initial variable name. This is greater than 0.
+   * @return A new filter that checks that both variables are equal.
+   */
+  private Filter createSameTermPair(Variable var, int offset) {
+    assert offset > 0;
+    return new SameTerm(new Var(var.getName()), new Var(offsetName(var, offset)));
+  }
+
+  /**
+   * Creates the elements required for a new ConstraintImpl with no repeating variables.
+   * @param constraint The original constraint with repeating variables.
+   * @param vfStruct The structure of the variable repetition in the constraint.
+   * @return A ConstraintElement array with the variables all made unique, and a cycle starting at offset.
+   */
+  private ConstraintElement[] buildElements(ConstraintImpl constraint, VarFreq vfStruct) {
+    ConstraintElement[] ops = new ConstraintElement[4];
+    int offset = 0;
+    for (int e = 0; e < 4; e++) {
+      ConstraintElement elt = constraint.getElement(e);
+      if (!vfStruct.repeatedVar.equals(elt)) ops[e] = elt;
+      else {
+        ops[e] = createOffsetVar(vfStruct.repeatedVar, offset);
+        offset = (offset + 1);
+      }
+    }
+    return ops;
+  }
+
+  /**
+   * Creates an internal variable. The name contains characters that are illegal in
+   * the query language, so they should not cause any conflicts.
+   * @param startVar The variable to base the new variable from.
+   * @param offset The change from the original variable.
+   * @return A variable with name related to the name of startVar by the value of offset,
+   *         or the original startVar if offset is 0.
+   */
+  private Variable createOffsetVar(Variable startVar, int offset) {
+    if (offset == 0) return startVar;
+    return new Variable(offsetName(startVar, offset));
+  }
+
+  /**
+   * Creates a new name for an internal variable, based on an initial variable
+   * and an offset from that variable.
+   * @param v The initial variable.
+   * @param offset The offset from the initial variable
+   * @return A new variable name.
+   */
+  private String offsetName(Variable v, int offset) {
+    return "*" + v.getName() + offset;
+  }
+
+  /**
+   * Internal analysis of a ConstraintImpl to find the repeated variables,
+   * and the resulting structure.
+   */
+  private static class VarFreq {
+    /** The number of times the repeated variable appears */
+    public final int frequency;
+    /** The repeating variable */
+    public final Variable repeatedVar;
+
+    public VarFreq(ConstraintImpl constraint) throws SymbolicTransformationException {
+      int frequency = 0;
+      Variable repeatedVar = null;
+
+      // find the repeating variable name, and frequency
+      List<Variable> vars = new ArrayList<Variable>(4);
+      for (int e = 0; e < 4; e++) {
+        ConstraintElement elt = constraint.getElement(e);
+        if (elt instanceof Variable) {
+          if (vars.contains(elt)) {
+            if (repeatedVar != null) {
+              if (!repeatedVar.equals(elt)) continue;
+            } else {
+              repeatedVar = (Variable)elt;
+              frequency++; // increment the initial count, since this variable has been seen before
+            }
+            frequency++;
+          } else {
+            vars.add((Variable)elt);
+          }
+        }
+      }
+      if (frequency < 2) throw new SymbolicTransformationException("No repeats found in a constraint that reported repetition.");
+      if (repeatedVar == null) throw new SymbolicTransformationException("No repeating variable found, despite counting a repetition of: " + frequency);
+      assert (vars.contains(repeatedVar));
+      this.frequency = frequency;
+      this.repeatedVar = repeatedVar;
+    }
+  }
+
+  /**
+   * This enum enumerates the ConstraintOperation types. It has been built to deal with
+   * the fact that constructors for the various types cannot be passed as a lambda.
+   * It also provides a map for the enumerated types to their enumerations, making it
+   * easy for an operation to get to an appropriate constructor.
+   */
+  private static enum OpType {
+    difference {
+      ConstraintOperation newOp(List<ConstraintExpression> ops) { return new ConstraintDifference(ops.get(0), ops.get(1)); }
+    },
+    optional {
+      ConstraintOperation newOp(List<ConstraintExpression> ops) { return new ConstraintOptionalJoin(ops.get(0), ops.get(1)); }
+    },
+    conjunction {
+      ConstraintOperation newOp(List<ConstraintExpression> ops) { return new ConstraintConjunction(ops); }
+    },
+    disjunction {
+      ConstraintOperation newOp(List<ConstraintExpression> ops) { return new ConstraintDisjunction(ops); }
+    };
+    abstract ConstraintOperation newOp(List<ConstraintExpression> ops);
+    private static Map<Class<? extends ConstraintOperation>, OpType> opMap = new HashMap<Class<? extends ConstraintOperation>, OpType>();
+    public static OpType getType(ConstraintOperation op) { return opMap.get(op.getClass()); }
+    static {
+      opMap.put(ConstraintDifference.class, difference);
+      opMap.put(ConstraintOptionalJoin.class, optional);
+      opMap.put(ConstraintConjunction.class, conjunction);
+      opMap.put(ConstraintDisjunction.class, disjunction);
+    }
+  }
+}

Modified: branches/mgr-121-lockrecovery/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ResolverFactoryInitializer.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ResolverFactoryInitializer.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ResolverFactoryInitializer.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -37,6 +37,7 @@
 import org.mulgara.content.ContentHandler;
 import org.mulgara.content.ContentHandlerManager;
 import org.mulgara.server.Session;
+import org.mulgara.server.SessionFactory;
 import org.mulgara.store.stringpool.StringPool;
 
 /**
@@ -165,5 +166,19 @@
    * Register new Constraint Type
    * @throws InitializerException if the constraint class specified has already been registered
    */
-   public void registerNewConstraint(ConstraintDescriptor descriptor) throws InitializerException;
+  public void registerNewConstraint(ConstraintDescriptor descriptor) throws InitializerException;
+
+  /**
+   * Obtain the session-factory the resolver-factory is being loaded by.
+   *
+   * There are a couple restrictions on the returned session-factory. For one, the methods
+   * {@link SessionFactory#close close()} and {@link SessionFactory#delete delete()} may not
+   * be used and will throw an exception. The second restriction is that operations on different
+   * session's may not be nested, which means that if a resolver or resolver-factory creates any
+   * sessions using this session-factory then it must use a separate thread for operations on
+   * those sessions.
+   *
+   * @return the owning session-factory
+   */
+  public SessionFactory getSessionFactory();
 }

Modified: branches/mgr-121-lockrecovery/src/jar/resolver-store/java/org/mulgara/resolver/store/StatementStoreResolver.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/resolver-store/java/org/mulgara/resolver/store/StatementStoreResolver.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/resolver-store/java/org/mulgara/resolver/store/StatementStoreResolver.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -33,21 +33,15 @@
 import java.io.IOException;
 import java.io.Writer;
 import java.net.URI;
-import java.util.Iterator;
-import java.util.Set;
 import javax.transaction.xa.XAResource;
 
 // Third party packages
 import org.apache.log4j.Logger;
-import org.jrdf.graph.GraphException;
 import org.jrdf.graph.Node;
-import org.jrdf.graph.Triple;
 import org.jrdf.graph.URIReference;
-import org.jrdf.vocabulary.RDF;
 
 // Locally written packages
 import org.mulgara.query.*;
-import org.mulgara.query.rdf.URIReferenceImpl;
 import org.mulgara.resolver.spi.*;
 import org.mulgara.store.nodepool.NodePool;
 import org.mulgara.store.nodepool.NodePoolException;
@@ -57,7 +51,6 @@
 import org.mulgara.store.stringpool.SPObjectFactory;
 import org.mulgara.store.stringpool.StringPoolException;
 import org.mulgara.store.tuples.Tuples;
-import org.mulgara.store.tuples.TuplesOperations;
 import org.mulgara.store.xa.SimpleXAResource;
 import org.mulgara.store.xa.SimpleXAResourceException;
 import org.mulgara.store.xa.XAResolverSession;
@@ -117,6 +110,7 @@
 
   private final XAResource xaresource;
 
+  @SuppressWarnings("unused")
   private boolean isSystemResolver;
 
   private long systemModel;
@@ -405,7 +399,7 @@
             throw new QueryException("Unable to resolve constraint " + constraint + " unknown type");
           }
         } else {
-          return new StatementStoreDuplicateResolution(constraint, statementStore);
+          throw new QueryException("Duplicate variable found during resolution");
         }
       } else {
         return new EmptyResolution(constraint, true);
@@ -509,33 +503,6 @@
   // Internal methods
   //
 
-  /**
-   * Convert {@link ConstraintElement} objects into node numbers suitable for
-   * invoking the {@link StatementStore#findTuples}.
-   *
-   * @param constraintElement  the element to convert
-   * @return {@link NodePool#NONE} if the <var>constraintElement</var> is
-   *  {@link Variable}, otherwise the node number if it's a {@link LocalNode}
-   * @throws QueryException if <var>constraintElement</var> is neither a
-   *  {@link Variable} nor a {@link LocalNode}
-   */
-  private static long toGraphTuplesIndex(ConstraintElement constraintElement)
-    throws QueryException
-  {
-    assert constraintElement != null;
-
-    if (constraintElement instanceof Variable) {
-      return NodePool.NONE;
-    } else if (constraintElement instanceof LocalNode) {
-      return ((LocalNode) constraintElement).getValue();
-    } else {
-      throw new QueryException("Unsupported constraint element: " +
-                               constraintElement + " (" +
-                               constraintElement.getClass() + ")");
-    }
-  }
-
-
   public void abort() {
     try {
       try {

Modified: branches/mgr-121-lockrecovery/src/jar/server-beep/java/org/mulgara/server/beep/BEEPSession.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/server-beep/java/org/mulgara/server/beep/BEEPSession.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/server-beep/java/org/mulgara/server/beep/BEEPSession.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -203,8 +203,7 @@
    * @param outputStream The stream to receive the contents
    * @throws QueryException if the backup cannot be completed.
    */
-  public void backup(URI serverURI, OutputStream outputStream)
-    throws QueryException {
+  public void backup(URI serverURI, OutputStream outputStream) throws QueryException {
     throw new QueryException("Backup not implemented");
   }
 
@@ -233,8 +232,7 @@
    * @param sourceURI The URI of the backup file to restore from.
    * @throws QueryException if the restore cannot be completed.
    */
-  public void restore(InputStream inputStream, URI serverURI, URI sourceURI)
-      throws QueryException {
+  public void restore(InputStream inputStream, URI serverURI, URI sourceURI) throws QueryException {
     throw new QueryException("Restore not implemented");
   }
 
@@ -250,12 +248,9 @@
     Channel queryChannel;
     try {
       queryChannel = beepSession.startChannel(QueryProfile.URI);
+    } catch (BEEPException e) {
+      throw new QueryException("Couldn't open BEEP channel using Query profile", e);
     }
-    catch (BEEPException e) {
-      throw new QueryException(
-          "Couldn't open BEEP channel using Query profile", e
-          );
-    }
     assert queryChannel != null;
 
     // Beyond this point, we have to ensure that the channel gets closed.
@@ -287,8 +282,7 @@
                 message.getDataStream().getInputStream()
                 ));
             throw new QueryException(reader.readLine());
-          }
-          catch (IOException e) {
+          } catch (IOException e) {
             throw new QueryException("Unidentified error on BEEP channel");
           }
 
@@ -297,256 +291,242 @@
                 "Unexpected BEEP message type " + message.getMessageType()
                 );
       }
-    }
-
     // Only leave the BEEP channel unclosed if a BEEPAnswer capable of taking
     // responsibility for doing this was returned.  If exiting exceptionally,
     // the channel must be explicitly closed.
-    catch (BEEPException e) {
+    } catch (BEEPException e) {
       close(queryChannel);
       throw new QueryException("Couldn't communicate with BEEP server", e);
-    }
-    catch (IOException e) {
+    } catch (IOException e) {
       close(queryChannel);
       throw new QueryException("Couldn't generate BEEP query", e);
-    }
-    catch (QueryException e) {
+    } catch (QueryException e) {
       close(queryChannel);
       throw e;
-    }
-    catch (StreamFormatException e) {
+    } catch (StreamFormatException e) {
       close(queryChannel);
       throw new QueryException("Couldn't interpret BEEP reply", e);
     }
   }
 
- /**
-  * Make a list of TQL queries.
-  *
-  * @param queries the list of queries
-  * @return a list of non-<code>null</code> answers to the <var>queries</var>
-  * @throws QueryException if <var>query</var> can't be answered
-  */
- public List query(List queries) throws QueryException {
-   throw new QueryException("Multiple queries not implemented");
- }
+  /**
+   * Make a list of TQL queries.
+   *
+   * @param queries the list of queries
+   * @return a list of non-<code>null</code> answers to the <var>queries</var>
+   * @throws QueryException if <var>query</var> can't be answered
+   */
+  public List query(List queries) throws QueryException {
+    throw new QueryException("Multiple queries not implemented");
+  }
 
- /**
-  * Test the model for the occurrence of the triple.  A null value for any
-  * of the parts of a triple are treated as unconstrained, any values will be
-  * returned.
-  *
-  * @param modelURI URI of the model to be checked
-  * @param triple Triple to be found
-  * @throws QueryException if the model cannot be checked
-  * @return boolean true if the model contains the triple.
-  */
- public boolean contains(URI modelURI, Triple triple) throws QueryException {
+  /**
+   * Test the model for the occurrence of the triple.  A null value for any
+   * of the parts of a triple are treated as unconstrained, any values will be
+   * returned.
+   *
+   * @param modelURI URI of the model to be checked
+   * @param triple Triple to be found
+   * @throws QueryException if the model cannot be checked
+   * @return boolean true if the model contains the triple.
+   */
+  public boolean contains(URI modelURI, Triple triple) throws QueryException {
+    throw new QueryException("Contains not implemented.");
+  }
 
-   throw new QueryException("Contains not implemented.");
- }
+  /**
+   * Returns an answer containing a set of statements in the model that match a
+   * given triple. A null value for any of the parts of a triple are treated as
+   * unconstrained, any values will be returned.
+   *
+   * @param modelURI URI of the model to be searched
+   * @param triple Triple constraint used to match the triples
+   * @throws QueryException if the model cannot be searched
+   * @return Answer containing the triples that matcth the constraint
+   */
+  public Answer find(URI modelURI, Triple triple) throws QueryException {
+    throw new QueryException("Find not implemented.");
+  }
 
- /**
-  * Returns an answer containing a set of statements in the model that match a
-  * given triple. A null value for any of the parts of a triple are treated as
-  * unconstrained, any values will be returned.
-  *
-  * @param modelURI URI of the model to be searched
-  * @param triple Triple constraint used to match the triples
-  * @throws QueryException if the model cannot be searched
-  * @return Answer containing the triples that matcth the constraint
-  */
- public Answer find(URI modelURI, Triple triple) throws QueryException {
 
-   throw new QueryException("Find not implemented.");
- }
+  /**
+   * Create a new model.
+   *
+   * @param modelURI the {@link URI} of the new model
+   * @param modelTypeURI the {@link URI} identifying whether the new model is
+   *   backed by a triple store (<code>mulgara:Model</code>) or by a Lucene full
+   *   text index (<code>mulgara:LuceneModel</code>)
+   * @throws QueryException if the model can't be created
+   */
+  public void createModel(URI modelURI, URI modelTypeURI) throws QueryException {
+    throw new QueryException("Create Model not implemented");
+  }
 
+  /**
+   * Remove an existing model.
+   *
+   * @param uri the {@link URI} of the doomed model
+   * @throws QueryException if the model can't be removed
+   */
+  public void removeModel(URI uri) throws QueryException {
+    throw new QueryException("Remove model not implemented");
+  }
 
- /**
-  * Create a new model.
-  *
-  * @param modelURI the {@link URI} of the new model
-  * @param modelTypeURI the {@link URI} identifying whether the new model is
-  *   backed by a triple store (<code>mulgara:Model</code>) or by a Lucene full
-  *   text index (<code>mulgara:LuceneModel</code>)
-  * @throws QueryException if the model can't be created
-  */
- public void createModel(URI modelURI, URI modelTypeURI) throws QueryException {
-   throw new QueryException("Create Model not implemented");
- }
+  public boolean modelExists(URI uri) throws QueryException {
+    throw new QueryException("Remove model not implemented");
+  }
 
- /**
-  * Remove an existing model.
-  *
-  * @param uri the {@link URI} of the doomed model
-  * @throws QueryException if the model can't be removed
-  */
- public void removeModel(URI uri) throws QueryException {
-   throw new QueryException("Remove model not implemented");
- }
+  /**
+   * Define the contents of a model.
+   *
+   * @param uri the {@link URI} of the model to be redefined
+   * @param modelExpression the new content for the model
+   * @return The number of statements inserted into the model
+   * @throws QueryException if the model can't be modified
+   */
+  public long setModel(URI uri, ModelExpression modelExpression) throws QueryException {
+    throw new QueryException("Set Model not implemented");
+  }
 
- public boolean modelExists(URI uri) throws QueryException {
-   throw new QueryException("Remove model not implemented");
- }
+  /**
+   * Define the contents of a model.
+   *
+   * @param inputstream a remote inputstream
+   * @param uri the {@link URI} of the model to be redefined
+   * @param modelExpression the new content for the model
+   * @return The number of statements inserted into the model
+   * @throws QueryException if the model can't be modified
+   */
+  public long setModel(InputStream inputstream, URI uri, ModelExpression modelExpression) throws QueryException {
+    throw new QueryException("Set Model not implemented");
+  }
 
- /**
-  * Define the contents of a model.
-  *
-  * @param uri the {@link URI} of the model to be redefined
-  * @param modelExpression the new content for the model
-  * @return The number of statements inserted into the model
-  * @throws QueryException if the model can't be modified
-  */
- public long setModel(URI uri,
-     ModelExpression modelExpression) throws QueryException {
-   throw new QueryException("Set Model not implemented");
- }
 
- /**
-  * Define the contents of a model.
-  *
-  * @param inputstream a remote inputstream
-  * @param uri the {@link URI} of the model to be redefined
-  * @param modelExpression the new content for the model
-  * @return The number of statements inserted into the model
-  * @throws QueryException if the model can't be modified
-  */
- public long setModel(InputStream inputstream, URI uri,
-     ModelExpression modelExpression) throws QueryException {
-   throw new QueryException("Set Model not implemented");
- }
+  /**
+   * Sets the AutoCommit attribute of the Session object
+   *
+   * @param autoCommit The new AutoCommit value
+   * @throws QueryException EXCEPTION TO DO
+   */
+  public void setAutoCommit(boolean autoCommit) throws QueryException {
+    /*
+    try {
+      // Send the command message
+      Reply reply = new Reply();
+      commandChannel.sendMSG(new StringOutputDataStream("autocommit "+autoCommit), reply);
 
+      // Process the reply to the query message
+      assert reply.hasNext();
+      Message message = reply.getNextReply();
+      switch (message.getMessageType()) {
+        case Message.MESSAGE_TYPE_NUL:
+          return;
 
- /**
-  * Sets the AutoCommit attribute of the Session object
-  *
-  * @param autoCommit The new AutoCommit value
-  * @throws QueryException EXCEPTION TO DO
-  */
- public void setAutoCommit(boolean autoCommit) throws QueryException {
-   /*
-        try {
-     // Send the command message
-     Reply reply = new Reply();
-     commandChannel.sendMSG(
-       new StringOutputDataStream("autocommit "+autoCommit),
-       reply
-     );
+        case Message.MESSAGE_TYPE_ERR:
+          try {
+            BufferedReader reader =
+                new BufferedReader(new InputStreamReader(message.getDataStream().getInputStream()));
+            throw new QueryException(reader.readLine());
+          } catch (IOException e) {
+            throw new QueryException("Unidentified error on BEEP channel");
+          }
 
-     // Process the reply to the query message
-     assert reply.hasNext();
-     Message message = reply.getNextReply();
-     switch (message.getMessageType()) {
-     case Message.MESSAGE_TYPE_NUL:
-       return;
+        default:
+          throw new QueryException("Unexpected BEEP message type "+message.getMessageType());
+      }
+    }
+    catch (BEEPException e) {
+      throw new QueryException("Couldn't communicate with BEEP server", e);
+    }
+     */
+  }
 
-     case Message.MESSAGE_TYPE_ERR:
-       try {
-         BufferedReader reader = new BufferedReader(new InputStreamReader(
-                                   message.getDataStream().getInputStream()
-                                 ));
-         throw new QueryException(reader.readLine());
-       }
-       catch (IOException e) {
-         throw new QueryException("Unidentified error on BEEP channel");
-       }
+  /**
+   * METHOD TO DO
+   *
+   * @throws QueryException EXCEPTION TO DO
+   */
+  public void commit() throws QueryException {
+    throw new QueryException("Commit not implemented");
+  }
 
-     default:
-       throw new QueryException(
-         "Unexpected BEEP message type "+message.getMessageType()
-       );
-     }
-        }
-        catch (BEEPException e) {
-     throw new QueryException("Couldn't communicate with BEEP server", e);
-        }
-    */
- }
+  /**
+   * METHOD TO DO
+   *
+   * @throws QueryException EXCEPTION TO DO
+   */
+  public void rollback() throws QueryException {
+    throw new QueryException("Rollback not implemented");
+  }
 
- /**
-  * METHOD TO DO
-  *
-  * @throws QueryException EXCEPTION TO DO
-  */
- public void commit() throws QueryException {
-   throw new QueryException("Commit not implemented");
- }
+  /**
+   * Release resources associated with this session.
+   *
+   * The session won't be usable after this method is invoked.
+   */
+  public void close() {
+    try {
+      beepSession.close();
+    } catch (BEEPException e) {
+      logger.warn("Unable to close BEEP session", e);
+    }
 
- /**
-  * METHOD TO DO
-  *
-  * @throws QueryException EXCEPTION TO DO
-  */
- public void rollback() throws QueryException {
-   throw new QueryException("Rollback not implemented");
- }
+    beepSession = null;
+  }
 
- /**
-  * Release resources associated with this session.
-  *
-  * The session won't be usable after this method is invoked.
-  */
- public void close() {
-   try {
-     beepSession.close();
-   }
-   catch (BEEPException e) {
-     logger.warn("Unable to close BEEP session", e);
-   }
+  public void login(URI securityDomain, String username, char[] password) {
+    logger.error("Login not implemented");
+  }
 
-   beepSession = null;
- }
+  //
+  // Internal methods
+  //
 
- public void login(URI securityDomain, String username, char[] password) {
-   logger.error("Login not implemented");
- }
+  /**
+   * This method attempts to close a BEEP channel.
+   *
+   * If it fails, it only logs the fact rather than throwing an exception.
+   *
+   * @param channel  a BEEP channel to close
+   */
+  private void close(Channel channel) {
+    try {
+      channel.close();
+    } catch (BEEPException e) {
+      logger.warn("Unable to close BEEP channel (ignoring)", e);
+    }
+  }
 
- //
- // Internal methods
- //
+  public boolean isLocal() {
+    return false;
+  }
 
- /**
-  * This method attempts to close a BEEP channel.
-  *
-  * If it fails, it only logs the fact rather than throwing an exception.
-  *
-  * @param channel  a BEEP channel to close
-  */
- private void close(Channel channel) {
-   try {
-     channel.close();
-   }
-   catch (BEEPException e) {
-     logger.warn("Unable to close BEEP channel (ignoring)", e);
-   }
- }
+  /**
+   * {@inheritDoc}
+   */
+  public RulesRef buildRules(URI ruleModel, URI baseModel, URI destModel) throws QueryException, org.mulgara.rules.InitializerException {
+    throw new UnsupportedOperationException("This operation is only supported on local sessions.");
+  }
 
- public boolean isLocal() {
-   return false;
- }
+  /**
+   * {@inheritDoc}
+   */
+  public void applyRules(RulesRef rules) {
+    throw new UnsupportedOperationException("This operation is only supported on local sessions.");
+  }
 
- /**
-  * {@inheritDoc}
-  */
- public RulesRef buildRules(URI ruleModel, URI baseModel, URI destModel) throws QueryException, org.mulgara.rules.InitializerException {
-   throw new UnsupportedOperationException("This operation is only supported on local sessions.");
- }
+  public XAResource getXAResource() throws QueryException {
+    throw new QueryException("External transactions not implemented under Beep");
+  }
 
- /**
-  * {@inheritDoc}
-  */
- public void applyRules(RulesRef rules) {
-   throw new UnsupportedOperationException("This operation is only supported on local sessions.");
- }
+  public XAResource getReadOnlyXAResource() throws QueryException {
+    throw new QueryException("External transactions not implemented under Beep");
+  }
 
- public XAResource getXAResource() throws QueryException {
-   throw new QueryException("External transactions not implemented under Beep");
- }
+  public boolean ping() {
+    return true;
+  }
 
- public XAResource getReadOnlyXAResource() throws QueryException {
-   throw new QueryException("External transactions not implemented under Beep");
- }
-
   public void setIdleTimeout(long millis) {
     throw new UnsupportedOperationException("Timeouts not implemented under beep.");
   }

Modified: branches/mgr-121-lockrecovery/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSession.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSession.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSession.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -328,4 +328,10 @@
    * @throws RemoteException 
    */
   public void setTransactionTimeout(long millis) throws QueryException, RemoteException;
+
+  /**
+   * Test the connectivity of the remote session.
+   * @return <code>true</code> if connectivity was established.
+   */
+  public boolean ping() throws QueryException, RemoteException;
 }

Modified: branches/mgr-121-lockrecovery/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSessionWrapperSession.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSessionWrapperSession.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSessionWrapperSession.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -647,4 +647,15 @@
       setTransactionTimeout(millis);
     }
   }
+
+  public boolean ping() throws QueryException {
+    try {
+      boolean ping = remoteSession.ping();
+      resetRetries();
+      return ping;
+    } catch (RemoteException re) {
+      testRetry(re);
+      return ping();
+    }
+  }
 }

Modified: branches/mgr-121-lockrecovery/src/jar/server-rmi/java/org/mulgara/server/rmi/SessionWrapperRemoteSession.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/server-rmi/java/org/mulgara/server/rmi/SessionWrapperRemoteSession.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/server-rmi/java/org/mulgara/server/rmi/SessionWrapperRemoteSession.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -32,6 +32,7 @@
 import java.io.*;
 import java.net.URI;
 import java.rmi.*;
+import java.rmi.server.Unreferenced;
 import java.util.*;
 
 // Third party packages
@@ -63,7 +64,7 @@
  *      Software Pty Ltd</A>
  * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
  */
-class SessionWrapperRemoteSession implements RemoteSession {
+class SessionWrapperRemoteSession implements RemoteSession, Unreferenced  {
 
   @SuppressWarnings("unused")
   /** Logger.  */
@@ -492,6 +493,25 @@
     }
   }
 
+  public boolean ping() throws QueryException, RemoteException {
+    try {
+      return session.ping();
+    } catch (Throwable t) {
+      throw convertToQueryException(t);
+    }
+  }
+
+  public void unreferenced() {
+    if (logger.isDebugEnabled())
+      logger.debug("Closing unreferenced remote session " + session);
+
+    try {
+      close();
+    } catch (Exception e) {
+      logger.warn("Error closing unreferenced session " + session, e);
+    }
+  }
+
   // Construct an exception chain that will pass over RMI.
   protected Throwable mapThrowable(Throwable t) {
     Throwable cause = t.getCause();

Modified: branches/mgr-121-lockrecovery/src/jar/sparql-interpreter/java/org/mulgara/sparql/SparqlInterpreter.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/sparql-interpreter/java/org/mulgara/sparql/SparqlInterpreter.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/sparql-interpreter/java/org/mulgara/sparql/SparqlInterpreter.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -66,8 +66,9 @@
    * Sets the default graph to use in parsed queries.
    * @param graph The graph URI to use as the default graph.
    */
-  public void setDefaultGraphUri(URI graphUri) {
+  public SparqlInterpreter setDefaultGraphUri(URI graphUri) {
     defaultGraphUri = graphUri;
+    return this;
   }
 
   /**

Modified: branches/mgr-121-lockrecovery/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateImpl.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateImpl.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateImpl.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -30,18 +30,14 @@
 // Java 2 standard packages
 import java.net.URI;
 import java.nio.ByteBuffer;
-import java.text.ParseException;
 import java.util.Date;
-import java.util.Locale;
 
 // Third party packages
 import org.apache.log4j.Logger;
 
-// Date utils
-import com.mousepushers.date.DateParser;
-import com.mousepushers.date.DateFormatter;
-
 // Locally written packages
+import org.joda.time.format.DateTimeFormatter;
+import org.joda.time.format.ISODateTimeFormat;
 import org.mulgara.query.rdf.XSD;
 import org.mulgara.store.stringpool.*;
 import org.mulgara.util.Constants;
@@ -69,6 +65,7 @@
  */
 public final class SPDateImpl extends AbstractSPTypedLiteral {
 
+  @SuppressWarnings("unused")
   private final static Logger logger = Logger.getLogger(SPDateImpl.class);
 
   static final int TYPE_ID = 5; // Unique ID
@@ -100,13 +97,9 @@
 
 
   static SPDateImpl newInstance(String lexicalForm) {
-    try {
-      Date date = DateParser.parse(lexicalForm, XSD.DATE_FORMAT,
-          Locale.getDefault());
-      return new SPDateImpl(date);
-    } catch (ParseException ex) {
-      throw new IllegalArgumentException("Cannot parse date: " + lexicalForm);
-    }
+    DateTimeFormatter parser = ISODateTimeFormat.dateElementParser();
+    Date date = new Date(parser.parseDateTime(lexicalForm).getMillis());
+    return new SPDateImpl(date);
   }
 
 
@@ -126,9 +119,7 @@
 
 
   public String getLexicalForm() {
-    String dateTime = DateFormatter.formatDate(date, XSD.DATE_FORMAT,
-        Locale.getDefault());
-    return dateTime;
+    return ISODateTimeFormat.date().print(date.getTime());
   }
 
 

Modified: branches/mgr-121-lockrecovery/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateTimeImpl.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateTimeImpl.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateTimeImpl.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -32,18 +32,15 @@
 import java.nio.ByteBuffer;
 import java.text.ParseException;
 import java.util.Date;
-import java.util.Locale;
 
 // Third party packages
 import org.apache.log4j.Logger;
 
-// Date utils
-import com.mousepushers.date.DateParser;
-
 // Locally written packages
 import org.mulgara.query.rdf.XSD;
 import org.mulgara.store.stringpool.*;
-import org.mulgara.util.Constants;
+import org.mulgara.util.LexicalDateTime;
+import static org.mulgara.util.Constants.SIZEOF_LONG;
 
 
 /**
@@ -53,88 +50,82 @@
  *
  * @author David Makepeace
  * @author Edwin Shin
- *
- * @version $Revision: 1.1 $
- *
- * @modified $Date: 2005/03/11 04:15:22 $
- *
- * @maintenanceAuthor $Author: raboczi $
- *
+ * @author Paul Gearon
  * @company <A href="mailto:info at PIsoftware.com">Plugged In Software</A>
- *
  * @copyright &copy; 2004 <A href="http://www.PIsoftware.com/">Plugged In
  *      Software Pty Ltd</A>
- *
  * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
  */
 public final class SPDateTimeImpl extends AbstractSPTypedLiteral {
 
+  @SuppressWarnings("unused")
   private final static Logger logger = Logger.getLogger(SPDateTimeImpl.class);
 
   static final int TYPE_ID = 6; // Unique ID
 
   static final URI TYPE_URI = XSD.DATE_TIME_URI;
 
-  private Date date;
+  private LexicalDateTime dateTime;
 
 
-  SPDateTimeImpl(Date date) {
+  /**
+   * Creates a dateTime using a LexicalDateTime.
+   * @param date A {@link java.util.Date} representing the dateTime.
+   */
+  SPDateTimeImpl(LexicalDateTime dateTime) {
     super(TYPE_ID, TYPE_URI);
+    if (dateTime == null) throw new IllegalArgumentException("Null \"dateTime\" parameter");
+    this.dateTime = dateTime;
+  }
 
-    if (date == null) {
-      throw new IllegalArgumentException("Null \"date\" parameter");
-    }
 
-    this.date = date;
+  /**
+   * Creates a dateTime in the default timezone for this system. Not recommended.
+   * @param date A {@link java.util.Date} representing the dateTime.
+   */
+  SPDateTimeImpl(Date date) {
+    super(TYPE_ID, TYPE_URI);
+    if (date == null) throw new IllegalArgumentException("Null \"date\" parameter");
+    this.dateTime = new LexicalDateTime(date.getTime());
   }
 
 
+  /**
+   * Creates a dateTime from encoded data in a buffer.
+   * @param data The encoded data.
+   */
   SPDateTimeImpl(ByteBuffer data) {
-    this(data.getLong());
+    super(TYPE_ID, TYPE_URI);
+    if (data.limit() == SIZEOF_LONG)    // backwards compat with <= 1.x
+      this.dateTime = new LexicalDateTime(data.getLong(0));
+    else
+      this.dateTime = LexicalDateTime.decode(data);
   }
 
 
+  /**
+   * Creates a dateTime in the default timezone for this system. Not recommended.
+   * @param l The number of milliseconds since the epoch.
+   */
   SPDateTimeImpl(long l) {
-    this(new Date(l));
+    super(TYPE_ID, TYPE_URI);
+    this.dateTime = new LexicalDateTime(l);
   }
 
 
   static SPDateTimeImpl newInstance(String lexicalForm) {
-
-    StringBuffer sb = new StringBuffer(lexicalForm);
-    int pos = sb.length() - 4;
-    int index = sb.indexOf(".", pos);
-    if (index == -1) {
-      sb.append(".000");
-    }
-    else {
-      if (index == sb.length() - 1) {
-        throw new IllegalArgumentException("Cannot parse date: " + lexicalForm);
-      }
-      int pad = pos - index;
-      while (pad < 0) {
-        sb.append("0");
-        pad++;
-      }
-    }
-    lexicalForm = sb.toString();
     try {
-      Date date = DateParser.parse(lexicalForm, XSD.DATE_TIME_FORMAT,
-          Locale.getDefault());
-      return new SPDateTimeImpl(date);
-    }
-    catch (ParseException ex) {
+      return new SPDateTimeImpl(LexicalDateTime.parseDateTime(lexicalForm));
+    } catch (ParseException ex) {
       throw new IllegalArgumentException("Cannot parse date: " + lexicalForm);
     }
-
   }
 
   /* from SPObject interface. */
 
   public ByteBuffer getData() {
-    ByteBuffer data = ByteBuffer.allocate(Constants.SIZEOF_LONG);
-    data.putLong(date.getTime());
-    data.flip();
+    ByteBuffer data = ByteBuffer.allocate(LexicalDateTime.requiredBufferSize());
+    dateTime.encode(data);
     return data;
   }
 
@@ -143,19 +134,12 @@
   }
 
   /**
-   * Returns the lexical form of the XSD dateTime value according to
-   * "3.2.7.2 Canonical representation" of
-   * http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/
-   * with the following exceptions:
-   * - Timezones are not supported
-   * - Dates before 1 CE (i.e. 1 AD) are handled according to ISO 8601:2000
-   *   Second Edition:
-   *     "0000" is the lexical representation of 1 BCE
-   *     "-0001" is the lexical representation of 2 BCE
+   * Returns the lexical form of the XSD dateTime value, using the original form of the
+   * lexical value.
    * @return the lexical form of the XSD dateTime value
    */
   public String getLexicalForm() {
-    return XSD.getLexicalForm(date);
+    return dateTime.toString();
   }
 
   /* from Comparable interface. */
@@ -166,14 +150,16 @@
     if (c != 0) return c;
 
     // Compare the Dates.
-    return date.compareTo(((SPDateTimeImpl)o).date);
+    long a = dateTime.getMillis();
+    long b = (((SPDateTimeImpl)o).dateTime).getMillis();
+    return a == b ? 0 : (a < b ? -1 : 1);
   }
 
 
   /* from Object. */
 
   public int hashCode() {
-    return date.hashCode();
+    return dateTime.hashCode();
   }
 
 
@@ -182,7 +168,7 @@
     if (obj == null) return false;
 
     try {
-      return date.equals(((SPDateTimeImpl)obj).date);
+      return dateTime.equals(((SPDateTimeImpl)obj).dateTime);
     } catch (ClassCastException ex) {
       // obj was not an SPDateTimeImpl.
       return false;
@@ -190,11 +176,14 @@
   }
 
 
-  /** Compares the binary representations of two SPDateTimeImpl objects. */
+  /**
+   * Compares the binary representations of two SPDateTimeImpl objects.
+   * Performs comparisons on the canonical representations, so 2 different
+   * values can compare the same, so long as they refer to the same time.
+   */
   public static class SPDateTimeComparator implements SPComparator {
 
-    private static final SPDateTimeComparator INSTANCE =
-        new SPDateTimeComparator();
+    private static final SPDateTimeComparator INSTANCE = new SPDateTimeComparator();
 
     public static SPDateTimeComparator getInstance() {
       return INSTANCE;

Modified: branches/mgr-121-lockrecovery/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateTimeUnitTest.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateTimeUnitTest.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateTimeUnitTest.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -27,7 +27,6 @@
 
 // Standard Java
 import java.util.Date;
-import java.util.Locale;
 import java.text.SimpleDateFormat;
 import java.nio.ByteBuffer;
 
@@ -37,12 +36,10 @@
 // Log4j
 import org.apache.log4j.*;
 
-// Date Utils
-import com.mousepushers.date.DateParser;
-
 // Internal Packages
 import org.mulgara.query.rdf.XSD;
 import org.mulgara.util.Constants;
+import org.mulgara.util.LexicalDateTime;
 
 /**
  * Unit test for testing an xsd:datetime wrapper.
@@ -70,22 +67,14 @@
   private static SimpleDateFormat format;
 
   private static final String VALID_XSD_DATETIME = "2005-01-19T20:40:17";
-  private static final String VALID_JAVA_DATETIME = VALID_XSD_DATETIME + ".000";
 
   private static final String VALID_XSD_DATETIME2 = "2005-01-19T20:40:17.001";
-  private static final String VALID_JAVA_DATETIME2 = VALID_XSD_DATETIME2;
 
   private static final String VALID_XSD_DATETIME3 = "2005-01-19T20:40:17.1";
-  private static final String VALID_JAVA_DATETIME3 = VALID_XSD_DATETIME3 + "00";
 
-  private static final String VALID_XSD_DATETIME4 =
-      "123456789-01-19T20:40:17.123";
-  private static final String VALID_JAVA_DATETIME4 = VALID_XSD_DATETIME4;
+  private static final String VALID_XSD_DATETIME4 = "123456789-01-19T20:40:17.123";
 
-  private static final String VALID_XSD_DATETIME5 =
-      "-123456789-01-19T20:40:17.123";
-  private static final String VALID_JAVA_DATETIME5 =
-      "-123456790-01-19T20:40:17.123";
+  private static final String VALID_XSD_DATETIME5 = "-123456789-01-19T20:40:17.123";
 
   private static final String VALID_XSD_DATETIME6 = "0123-01-19T20:40:17.456";
   private static final String VALID_JAVA_DATETIME6 = VALID_XSD_DATETIME6;
@@ -98,16 +87,17 @@
 
   /** Constant valid test date (1 CE) */
   private static final String XSD_1CE = "0001-01-01T00:00:00";
-  private static final String JAVA_1CE = XSD_1CE + ".000";
 
-  /** Constant valid test date (1 BCE) */
-  private static final String XSD_1BCE = "0000-01-01T00:00:00";
-  private static final String JAVA_1BCE = XSD_1BCE + ".000";
+  // Not valid in XSD-2
+  /** Constant invalid test date (0 CE in XSD-2, 1 BCE and valid in later revisions) */
+  private static final String XSD_0CE = "0000-01-01T00:00:00";
 
-  /** Constant valid test date (2 BCE) */
-  private static final String XSD_2BCE = "-0001-01-01T00:00:00";
-  private static final String JAVA_2BCE = XSD_2BCE + ".000";
+  /** Constant valid test date (1 BCE in XSD-2) */
+  private static final String XSD_1BCE = "-0001-01-01T00:00:00";
 
+  /** Constant valid test date (2 BCE in XSD-2) */
+  private static final String XSD_2BCE = "-0002-01-01T00:00:00";
+
   /**
    * Constructs a new test with the given name.
    *
@@ -123,7 +113,7 @@
    * @return The test suite
    */
   public static Test suite() {
-    format = new SimpleDateFormat(XSD.DATE_TIME_FORMAT);
+    format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
 
     TestSuite suite = new TestSuite();
     suite.addTest(new SPDateTimeUnitTest("testValid"));
@@ -168,17 +158,19 @@
     Date dtDate = new Date(dtLong);
 
     // Format the resulting day
-    String dt = format.format(dtDate);
+    format.format(dtDate);
 
     // Test the correct value is stored
-    assertEquals(VALID_JAVA_DATETIME, getDateString(dateTime));
+    assertEquals(VALID_XSD_DATETIME, getDateString(dateTime));
 
     // Byte buffer to hold our date information
-    ByteBuffer buffer = ByteBuffer.wrap(new byte[Constants.SIZEOF_LONG]);
+    ByteBuffer buffer = ByteBuffer.wrap(new byte[Constants.SIZEOF_LONG + Constants.SIZEOF_INT]);
 
     // If the previous step passed then we know the long value is what we want,
     // so store it in our buffer
     buffer.putLong(dtLong);
+    buffer.put((byte)0x02);  // The value of the "local" flag
+    buffer.put((byte)0);
 
     // Reset the buffer for reading
     buffer.flip();
@@ -190,6 +182,8 @@
 
       log.debug("Original dateTime long vs. stored long: " + dtLong + " vs. " +
           buffer.getLong());
+      log.debug("Stored timezone code: " + buffer.get());
+      log.debug("Stored decimal places: " + buffer.get());
 
       // Reset the buffer
       buffer.flip();
@@ -202,7 +196,7 @@
     assertEquals(VALID_XSD_DATETIME, dateTime.getLexicalForm());
 
     // Test the correct value is stored
-    assertEquals(VALID_JAVA_DATETIME, getDateString(dateTime));
+    assertEquals(VALID_XSD_DATETIME, getDateString(dateTime));
 
     // Create a dateTime object by lexical string
     dateTime = (SPDateTimeImpl) factory.newSPTypedLiteral(XSD.DATE_TIME_URI,
@@ -212,7 +206,7 @@
     assertEquals(VALID_XSD_DATETIME2, dateTime.getLexicalForm());
 
     // Test the correct value is stored
-    assertEquals(VALID_JAVA_DATETIME2, getDateString(dateTime));
+    assertEquals(VALID_XSD_DATETIME2, getDateString(dateTime));
 
     // Create a dateTime object by lexical string
     dateTime = (SPDateTimeImpl) factory.newSPTypedLiteral(XSD.DATE_TIME_URI,
@@ -222,7 +216,7 @@
     assertEquals(VALID_XSD_DATETIME3, dateTime.getLexicalForm());
 
     // Test the correct value is stored
-    assertEquals(VALID_JAVA_DATETIME3, getDateString(dateTime));
+    assertEquals(VALID_XSD_DATETIME3, getDateString(dateTime));
 
     // Create a dateTime object by lexical string
     dateTime = (SPDateTimeImpl) factory.newSPTypedLiteral(XSD.DATE_TIME_URI,
@@ -232,7 +226,7 @@
     assertEquals(VALID_XSD_DATETIME4, dateTime.getLexicalForm());
 
     // Test the correct value is stored
-    assertEquals(VALID_JAVA_DATETIME4, getDateString(dateTime));
+    assertEquals(VALID_XSD_DATETIME4, getDateString(dateTime));
 
     // Create a dateTime object by lexical string
     dateTime = (SPDateTimeImpl) factory.newSPTypedLiteral(XSD.DATE_TIME_URI,
@@ -242,7 +236,7 @@
     assertEquals(VALID_XSD_DATETIME5, dateTime.getLexicalForm());
 
     // Test the correct value is stored
-    assertEquals(VALID_JAVA_DATETIME5, getDateString(dateTime));
+    assertEquals(VALID_XSD_DATETIME5, getDateString(dateTime));
 
     // Create a dateTime object by lexical string
     dateTime = (SPDateTimeImpl) factory.newSPTypedLiteral(XSD.DATE_TIME_URI,
@@ -266,36 +260,40 @@
     try {
       SPDateTimeImpl dateTime = (SPDateTimeImpl) factory.newSPTypedLiteral(XSD.
           DATE_TIME_URI, INVALID_XSD_DATETIME);
-      fail("Successfully parsed an invalid date: " + INVALID_XSD_DATETIME);
+      fail("Successfully parsed an invalid date: " + INVALID_XSD_DATETIME + " -> " + dateTime);
+    } catch (IllegalArgumentException e) {
+      assertTrue(true);
     }
-    catch (IllegalArgumentException e) {
+
+    try {
+      SPDateTimeImpl dateTime = (SPDateTimeImpl) factory.newSPTypedLiteral(XSD.
+          DATE_TIME_URI, INVALID_XSD_DATETIME2);
+      fail("Successfully parsed an invalid date: " + INVALID_XSD_DATETIME2 + " -> " + dateTime);
+    } catch (IllegalArgumentException e) {
       assertTrue(true);
     }
 
     try {
       SPDateTimeImpl dateTime = (SPDateTimeImpl) factory.newSPTypedLiteral(XSD.
           DATE_TIME_URI, INVALID_XSD_DATETIME3);
-      fail("Successfully parsed an invalid date: " + INVALID_XSD_DATETIME3);
-    }
-    catch (IllegalArgumentException e) {
+      fail("Successfully parsed an invalid date: " + INVALID_XSD_DATETIME3 + " -> " + dateTime);
+    } catch (IllegalArgumentException e) {
       assertTrue(true);
     }
 
     try {
       SPDateTimeImpl dateTime = (SPDateTimeImpl) factory.newSPTypedLiteral(XSD.
           DATE_TIME_URI, INVALID_XSD_DATETIME4);
-      fail("Successfully parsed an invalid date: " + INVALID_XSD_DATETIME4);
-    }
-    catch (IllegalArgumentException e) {
+      fail("Successfully parsed an invalid date: " + INVALID_XSD_DATETIME4 + " -> " + dateTime);
+    } catch (IllegalArgumentException e) {
       assertTrue(true);
     }
 
     try {
       SPDateTimeImpl dateTime = (SPDateTimeImpl) factory.newSPTypedLiteral(XSD.
           DATE_TIME_URI, INVALID_XSD_DATETIME5);
-      fail("Successfully parsed an invalid date: " + INVALID_XSD_DATETIME5);
-    }
-    catch (IllegalArgumentException e) {
+      fail("Successfully parsed an invalid date: " + INVALID_XSD_DATETIME5 + " -> " + dateTime);
+    } catch (IllegalArgumentException e) {
       assertTrue(true);
     }
 
@@ -330,27 +328,28 @@
   public void testBoundaryDates() throws Exception {
     // Create a new factory
     SPDateTimeFactory factory = new SPDateTimeFactory();
-    SPDateTimeImpl oneCE, oneBCE, twoBCE;
+    SPDateTimeImpl oneCE, oneBCE, twoBCE, invalidBCE;
 
     // Test 1 CE
     oneCE = (SPDateTimeImpl) factory.newSPTypedLiteral(XSD.
         DATE_TIME_URI, XSD_1CE);
-    assertTrue(XSD.ONE_CE.equals(getDate(oneCE)));
     assertEquals(XSD_1CE, oneCE.getLexicalForm());
 
+    // Test 0 CE
+    try {
+      invalidBCE = (SPDateTimeImpl) factory.newSPTypedLiteral(XSD.DATE_TIME_URI, XSD_0CE);
+      fail("Year 0000 incorrectly accepted: " + invalidBCE.toString());
+    } catch (Throwable t) {
+    }
+
     // Test 1 BCE
-    oneBCE = (SPDateTimeImpl) factory.newSPTypedLiteral(XSD.
-        DATE_TIME_URI, XSD_1BCE);
-    assertTrue(XSD.ONE_BCE.equals(getDate(oneBCE)));
+    oneBCE = (SPDateTimeImpl) factory.newSPTypedLiteral(XSD.DATE_TIME_URI, XSD_1BCE);
 
     // Test that the lexical form of the date is correct
     assertEquals(XSD_1BCE, oneBCE.getLexicalForm());
 
     // Test 2 BCE
-    twoBCE = (SPDateTimeImpl) factory.newSPTypedLiteral(XSD.
-        DATE_TIME_URI, XSD_2BCE);
-    assertTrue(DateParser.parse("-0001", XSD.YEAR_FORMAT, Locale.getDefault()).
-        equals(getDate(twoBCE)));
+    twoBCE = (SPDateTimeImpl) factory.newSPTypedLiteral(XSD.DATE_TIME_URI, XSD_2BCE);
 
     // Test that the lexical form of the date is correct
     assertEquals(XSD_2BCE, twoBCE.getLexicalForm());
@@ -372,12 +371,7 @@
   }
 
   private String getDateString(SPDateTimeImpl dateTime) {
-    Date date = getDate(dateTime);
-    String dateString = new SimpleDateFormat(XSD.DATE_TIME_FORMAT).format(date);
-    if (date.before(XSD.ONE_CE)) {
-      dateString = "-" + dateString;
-    }
-    return dateString;
+    return new LexicalDateTime(getDate(dateTime).getTime()).toString();
   }
 
 

Modified: branches/mgr-121-lockrecovery/src/jar/store-stringpool-memory/build.xml
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/store-stringpool-memory/build.xml	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/store-stringpool-memory/build.xml	2008-06-19 03:35:29 UTC (rev 1005)
@@ -26,6 +26,7 @@
     <fileset file="${store-stringpool-xa.dist.dir}/${store-stringpool-xa.jar}"/>
     <fileset file="${resolver-spi.dist.dir}/${resolver-spi.jar}"/>
     <fileset file="${tuples.dist.dir}/${tuples.jar}"/>
+    <fileset file="${util.dist.dir}/${util.jar}"/>
     <fileset file="${store-nodepool-memory.dist.dir}/${store-nodepool-memory.jar}"/>
   </path>
 

Modified: branches/mgr-121-lockrecovery/src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory/MemoryStringPoolImplTest.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory/MemoryStringPoolImplTest.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory/MemoryStringPoolImplTest.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -28,9 +28,7 @@
 package org.mulgara.store.stringpool.memory;
 
 // Java 2 standard packages
-import java.io.*;
 import java.net.*;
-import java.util.*;
 
 // third party packages
 import junit.framework.*;
@@ -200,10 +198,10 @@
     stringPool.put(6, spoFactory.newSPDouble(42));
     stringPool.put(7, spoFactory.newSPDouble(123));
     stringPool.put(8, spoFactory.newSPTypedLiteral(
-        "1966-9-18T15:00:00", XSD.DATE_TIME_URI
+        "1966-09-18T15:00:00", XSD.DATE_TIME_URI
     ));
     stringPool.put(9, spoFactory.newSPTypedLiteral(
-        "1971-12-20T0:20:00", XSD.DATE_TIME_URI
+        "1971-12-20T00:20:00", XSD.DATE_TIME_URI
     ));
 
     assertEquals(2, stringPool.findGNode(spoFactory.newSPString("alpha")));
@@ -215,10 +213,10 @@
     assertEquals(6, stringPool.findGNode(spoFactory.newSPDouble(42)));
     assertEquals(7, stringPool.findGNode(spoFactory.newSPDouble(123)));
     assertEquals(8, stringPool.findGNode(spoFactory.newSPTypedLiteral(
-        "1966-9-18T15:00:00", XSD.DATE_TIME_URI
+        "1966-09-18T15:00:00", XSD.DATE_TIME_URI
     )));
     assertEquals(9, stringPool.findGNode(spoFactory.newSPTypedLiteral(
-        "1971-12-20T0:20:00", XSD.DATE_TIME_URI
+        "1971-12-20T00:20:00", XSD.DATE_TIME_URI
     )));
 
     // Make sure that URIs don't appear as strings.

Modified: branches/mgr-121-lockrecovery/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImplTest.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImplTest.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImplTest.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -402,10 +402,10 @@
     stringPool.put(15, spoFactory.newSPDouble(42));
     stringPool.put(16, spoFactory.newSPDouble(123));
     stringPool.put(17, spoFactory.newSPTypedLiteral(
-        "1966-9-18T15:00:00", XSD.DATE_TIME_URI
+        "1966-09-18T15:00:00", XSD.DATE_TIME_URI
     ));
     stringPool.put(18, spoFactory.newSPTypedLiteral(
-        "1971-12-20T0:20:00", XSD.DATE_TIME_URI
+        "1971-12-20T00:20:00", XSD.DATE_TIME_URI
     ));
 
     assertEquals(11, stringPool.findGNode(spoFactory.newSPString("alpha")));
@@ -415,10 +415,10 @@
     assertEquals(15, stringPool.findGNode(spoFactory.newSPDouble(42)));
     assertEquals(16, stringPool.findGNode(spoFactory.newSPDouble(123)));
     assertEquals(17, stringPool.findGNode(spoFactory.newSPTypedLiteral(
-        "1966-9-18T15:00:00", XSD.DATE_TIME_URI
+        "1966-09-18T15:00:00", XSD.DATE_TIME_URI
     )));
     assertEquals(18, stringPool.findGNode(spoFactory.newSPTypedLiteral(
-        "1971-12-20T0:20:00", XSD.DATE_TIME_URI
+        "1971-12-20T00:20:00", XSD.DATE_TIME_URI
     )));
 
     // Make sure that URIs don't appear as strings.
@@ -480,10 +480,10 @@
     stringPool.put(15, spoFactory.newSPDouble(42));
     stringPool.put(16, spoFactory.newSPDouble(123));
     stringPool.put(17, spoFactory.newSPTypedLiteral(
-        "1966-9-18T15:00:00", XSD.DATE_TIME_URI
+        "1966-09-18T15:00:00", XSD.DATE_TIME_URI
     ));
     stringPool.put(18, spoFactory.newSPTypedLiteral(
-        "1971-12-20T0:20:00", XSD.DATE_TIME_URI
+        "1971-12-20T00:20:00", XSD.DATE_TIME_URI
     ));
     stringPool.put(19, spoFactory.newSPString("foxtrot"));
     stringPool.put(20, spoFactory.newSPString("golf"));
@@ -508,31 +508,31 @@
     stringPool.put(39, spoFactory.newSPDouble(1003));
     stringPool.put(40, spoFactory.newSPDouble(90));
     stringPool.put(41, spoFactory.newSPTypedLiteral(
-        "1977-1-1T0:00:00", XSD.DATE_TIME_URI
+        "1977-01-01T00:00:00", XSD.DATE_TIME_URI
     ));
     stringPool.put(42, spoFactory.newSPTypedLiteral(
-        "1968-7-5T0:00:00", XSD.DATE_TIME_URI
+        "1968-07-05T00:00:00", XSD.DATE_TIME_URI
     ));
     stringPool.put(43, spoFactory.newSPTypedLiteral(
-        "1981-1-10T0:00:00", XSD.DATE_TIME_URI
+        "1981-01-10T00:00:00", XSD.DATE_TIME_URI
     ));
     stringPool.put(44, spoFactory.newSPTypedLiteral(
-        "1999-9-9T0:00:00", XSD.DATE_TIME_URI
+        "1999-09-09T00:00:00", XSD.DATE_TIME_URI
     ));
     stringPool.put(45, spoFactory.newSPTypedLiteral(
-        "1977-1-1T0:00:01", XSD.DATE_TIME_URI
+        "1977-01-01T00:00:01", XSD.DATE_TIME_URI
     ));
     stringPool.put(46, spoFactory.newSPTypedLiteral(
-        "2000-1-1T0:00:00", XSD.DATE_TIME_URI
+        "2000-01-01T00:00:00", XSD.DATE_TIME_URI
     ));
     stringPool.put(47, spoFactory.newSPTypedLiteral(
         "1999-12-31T23:59:59", XSD.DATE_TIME_URI
     ));
     stringPool.put(48, spoFactory.newSPTypedLiteral(
-        "1977-1-1T0:00:02", XSD.DATE_TIME_URI
+        "1977-01-01T00:00:02", XSD.DATE_TIME_URI
     ));
     stringPool.put(49, spoFactory.newSPTypedLiteral(
-        "1970-1-1T0:00:00", XSD.DATE_TIME_URI
+        "1970-01-01T00:00:00", XSD.DATE_TIME_URI
     ));
     stringPool.put(50, spoFactory.newSPTypedLiteral(
         "1969-12-31T23:59:59", XSD.DATE_TIME_URI
@@ -710,10 +710,10 @@
 
     t = stringPool.findGNodes(
         spoFactory.newSPTypedLiteral(
-            "1971-12-20T0:20:00", XSD.DATE_TIME_URI
+            "1971-12-20T00:20:00", XSD.DATE_TIME_URI
         ), true,
         spoFactory.newSPTypedLiteral(
-            "1999-9-9T0:00:00", XSD.DATE_TIME_URI
+            "1999-09-09T00:00:00", XSD.DATE_TIME_URI
         ), true
     );
     assertEquals(allDates.subList(4, 10), asList(t));
@@ -721,10 +721,10 @@
 
     t = stringPool.findGNodes(
         spoFactory.newSPTypedLiteral(
-            "1971-12-19T0:00:00", XSD.DATE_TIME_URI
+            "1971-12-19T00:00:00", XSD.DATE_TIME_URI
         ), true,
         spoFactory.newSPTypedLiteral(
-            "1999-9-10T0:00:00", XSD.DATE_TIME_URI
+            "1999-09-10T00:00:00", XSD.DATE_TIME_URI
         ), true
     );
     assertEquals(allDates.subList(4, 10), asList(t));
@@ -732,10 +732,10 @@
 
     t = stringPool.findGNodes(
         spoFactory.newSPTypedLiteral(
-            "1971-12-19T0:00:00", XSD.DATE_TIME_URI
+            "1971-12-19T00:00:00", XSD.DATE_TIME_URI
         ), false,
         spoFactory.newSPTypedLiteral(
-            "1999-9-10T0:00:00", XSD.DATE_TIME_URI
+            "1999-09-10T00:00:00", XSD.DATE_TIME_URI
         ), false
     );
     assertEquals(allDates.subList(4, 10), asList(t));
@@ -743,10 +743,10 @@
 
     t = stringPool.findGNodes(
         spoFactory.newSPTypedLiteral(
-            "1971-12-20T0:20:00", XSD.DATE_TIME_URI
+            "1971-12-20T00:20:00", XSD.DATE_TIME_URI
         ), false,
         spoFactory.newSPTypedLiteral(
-            "1999-9-9T0:00:00", XSD.DATE_TIME_URI
+            "1999-09-09T00:00:00", XSD.DATE_TIME_URI
         ), true
     );
     assertEquals(allDates.subList(5, 10), asList(t));
@@ -754,10 +754,10 @@
 
     t = stringPool.findGNodes(
         spoFactory.newSPTypedLiteral(
-            "1971-12-21T0:00:00", XSD.DATE_TIME_URI
+            "1971-12-21T00:00:00", XSD.DATE_TIME_URI
         ), true,
         spoFactory.newSPTypedLiteral(
-            "1999-9-9T0:00:00", XSD.DATE_TIME_URI
+            "1999-09-09T00:00:00", XSD.DATE_TIME_URI
         ), true
     );
     assertEquals(allDates.subList(5, 10), asList(t));
@@ -765,10 +765,10 @@
 
     t = stringPool.findGNodes(
         spoFactory.newSPTypedLiteral(
-            "1971-12-20T0:20:00", XSD.DATE_TIME_URI
+            "1971-12-20T00:20:00", XSD.DATE_TIME_URI
         ), true,
         spoFactory.newSPTypedLiteral(
-            "1999-9-9T0:00:00", XSD.DATE_TIME_URI
+            "1999-09-09T00:00:00", XSD.DATE_TIME_URI
         ), false
     );
     assertEquals(allDates.subList(4, 9), asList(t));
@@ -776,10 +776,10 @@
 
     t = stringPool.findGNodes(
         spoFactory.newSPTypedLiteral(
-            "1971-12-20T0:20:00", XSD.DATE_TIME_URI
+            "1971-12-20T00:20:00", XSD.DATE_TIME_URI
         ), false,
         spoFactory.newSPTypedLiteral(
-            "1999-9-9T0:00:00", XSD.DATE_TIME_URI
+            "1999-09-09T00:00:00", XSD.DATE_TIME_URI
         ), false
     );
     assertEquals(allDates.subList(5, 9), asList(t));
@@ -788,10 +788,10 @@
     // Matching high value on last node in index (inclusive).
     t = stringPool.findGNodes(
         spoFactory.newSPTypedLiteral(
-            "1977-1-1T0:00:01", XSD.DATE_TIME_URI
+            "1977-01-01T00:00:01", XSD.DATE_TIME_URI
         ), false,
         spoFactory.newSPTypedLiteral(
-            "2000-1-1T0:00:00", XSD.DATE_TIME_URI
+            "2000-01-01T00:00:00", XSD.DATE_TIME_URI
         ), true
     );
     assertEquals(allDates.subList(7, 12), asList(t));
@@ -801,7 +801,7 @@
     // last node in index.
     t = stringPool.findGNodes(
         spoFactory.newSPTypedLiteral(
-            "2000-1-1T0:00:00", XSD.DATE_TIME_URI
+            "2000-01-01T00:00:00", XSD.DATE_TIME_URI
         ), false, null, false
     );
     assertTrue(asList(t).isEmpty());

Modified: branches/mgr-121-lockrecovery/src/jar/tuples-hybrid/java/org/mulgara/store/xa/BlockCacheLine.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/tuples-hybrid/java/org/mulgara/store/xa/BlockCacheLine.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/src/jar/tuples-hybrid/java/org/mulgara/store/xa/BlockCacheLine.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -351,7 +351,7 @@
 
 
   private int compareBlockWithPrefix(Block block, long[] prefix) {
-    assert prefix.length < width;
+    assert prefix.length <= width;
 
     long[] first = new long[width];
     loadTupleFromBlock(first, block, 0);

Copied: branches/mgr-121-lockrecovery/src/jar/util/java/org/mulgara/util/LexicalDateTime.java (from rev 1002, trunk/src/jar/util/java/org/mulgara/util/LexicalDateTime.java)
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/util/java/org/mulgara/util/LexicalDateTime.java	                        (rev 0)
+++ branches/mgr-121-lockrecovery/src/jar/util/java/org/mulgara/util/LexicalDateTime.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -0,0 +1,496 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.util;
+
+import java.text.ParseException;
+import java.nio.ByteBuffer;
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+import static org.joda.time.DateTimeZone.UTC;
+import static org.mulgara.util.Constants.SIZEOF_LONG;
+
+/**
+ * This class represents a dateTime value, preserving its lexical representation exactly.
+ * It stores the value of the dateTime in the canonical form, but also contains values which
+ * allow the preservation of the non-canonical format.
+ *
+ * @created Jun 5, 2008
+ * @author Paul Gearon
+ * @copyright &copy; 2008 <a href="http://www.topazproject.org/">The Topaz Project</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class LexicalDateTime {
+
+  /** The character for separating date elements */
+  private static final char DATE_SEPARATOR = '-';
+
+  /** The character for separating the date part from the time part */
+  private static final char DATE_TIME_SEPARATOR = 'T';
+
+  /** The character for separating time elements */
+  private static final char TIME_SEPARATOR = ':';
+
+  /** The character for separating the milliseconds from the seconds */
+  private static final char MILLI_SEPARATOR = '.';
+
+  /** The string form for the character separating the milliseconds from the seconds */
+  private static final String MILLI_SEPARATOR_STR = ".";
+
+  /** The character for indicating the UTC timezone (Zulu time). */
+  private static final char ZULU = 'Z';
+
+  /** The string form for the character indicating the UTC timezone (Zulu time). */
+  private static final String ZULU_STR = "Z";
+
+  /** The character for indicating a positive timezone offset */
+  private static final char POS_TZ = '+';
+
+  /** The character for indicating a negative timezone offset */
+  private static final char NEG_TZ = '-';
+
+  /** The hour value for midnight */
+  private static final int MIDNIGHT = 24;
+
+  /** The string representation of midnight when the midnight flag is set */
+  private static final String MIDNIGHT_STR = "24:00:00";
+
+  /** Standard start of parsing error messages */
+  private static final String BAD_FORMAT = "Bad format in ";
+
+  /** Output format for the dateTime */
+  private static final String LEXICAL_PATTERN = "yyyy-MM-dd'T'HH:mm:ss";
+
+  /** Output format for the date portion of the dateTime */
+  private static final String SHORT_PATTERN = "yyyy-MM-dd'T'";
+
+  /** The formatter used for converting the dateTime into a lexical form */
+  private static final DateTimeFormatter MAIN_FORMATTER = DateTimeFormat.forPattern(LEXICAL_PATTERN);
+
+  /** A supplemantary formatter for outputting the date, when the time has to be represented in non-canonical form */
+  private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormat.forPattern(SHORT_PATTERN);
+
+  /** The number of milliseconds in a second */
+  private static final int MILLIS = 1000;
+
+  /** The number of milliseconds in a minute */
+  private static final int MILLIS_IN_MINUTE = MILLIS * 60;
+
+  /** The number of milliseconds in an hour */
+  private static final long MILLIS_IN_HOUR = MILLIS_IN_MINUTE * 60;
+
+  /** The bit used to encode the localFlag */
+  private static final byte LOCAL_BIT = 0x02;
+
+  /** The bit used to encode the midnightFlag */
+  private static final byte MIDNIGHT_BIT = 0x01;
+
+  /** The mask for the timezone bits */
+  private static final byte TZ_MASK = (byte)0xFC;
+
+  /** The offset of the timezone data in an encoded buffer */
+  private static final int TZ_OFFSET = SIZEOF_LONG;
+
+  /** The offset of the fractional seconds decimal places in an encoded buffer */
+  private static final int PLACES_OFFSET = TZ_OFFSET + 1;
+
+  /** The milliseconds since the epoch */
+  private final long millis;
+
+  /** The hours offset for the time */
+  private final int tzHours;
+
+  /** The minutes offset for the timezone. A multiple of 15. */
+  private final int tzMinutes;
+
+  /** Indicates that the time was supplied as 24:00:00. */
+  private final boolean midnight;
+
+  /** The number of decimal places used to represent the milliseconds. No greater than 3. */
+  private final byte milliPlaces;
+
+  /** Indicates no supplied timezone. This defaults to the local timezone. */
+  private final boolean localFlag;
+
+  /** Indicates ZULU time, which is equivalent to +00:00. */
+  private final boolean zuluFlag;
+
+  /** A DateTime corresponding to this object. Only created if needed. */
+  private DateTime cachedDateTime = null;
+
+  /**
+   * This constructor is used to set each field explicitly, when all such information is available.
+   * No checking is performed on the consistency of the millisecond value, though some minimal testing is done on flags.
+   * Whether tested or not, the following should hold:
+   * <ul>
+   * <li>if <code>isMidnight</code> is set, then <code>millis</code> must be a multiple of 24 hours.</li>
+   * <li>if <code>isLocalTz</code> is set, then <code>tzHours</code> and <code>tzMinutes</code> should be 0,
+   *     and <code>isZulu</code> must be false.</li>
+   * <li>if <code>isZulu</code> is set, then <code>tzHours</code> and <code>tzMinutes</code> must be 0.</li>
+   * <li><code>millis</code> % 10^(6 - milliPlaces) == 0</li>
+   * </ul>
+   * @param millis The milliseconds since the epoch.
+   * @param tzHours The hour offset for the timezone.
+   * @param tzMinutes The minute offset for the timezone.
+   * @param isMidnight If the non-canonical form for midnight is used. "24:00:00"
+   * @param milliPlaces The number of decimal places used for representing millisecds as fractions of a second.
+   * @param isLocalTz Indicates no timezone information, so use the local default.
+   * @param isZulu Indicates that the timezone is "Zulu". This is equivalent to 00:00 and is represented as "Z".
+   * @throws IllegalArgumentException if the <code>isZulu</code> flag conflicts with the timezone values or the offsets.
+   */
+  public LexicalDateTime(long millis, int tzHours, int tzMinutes, boolean isMidnight, byte milliPlaces, boolean isLocalTz, boolean isZulu) {
+    this.millis = millis;
+    this.tzHours = tzHours;
+    this.tzMinutes = tzMinutes;
+    this.midnight = isMidnight;
+    this.milliPlaces = milliPlaces;
+    this.localFlag = isLocalTz;
+    this.zuluFlag = isZulu;
+    testTimezoneConsistency();
+  }
+
+  /**
+   * Internal constructor used with a dateTime object, and parsed fields.
+   * No checking is performed on the consistency of the millisecond value, though some minimal testing is done on flags.
+   * Whether tested or not, the following should hold:
+   * <ul>
+   * <li>if <code>isMidnight</code> is set, then <code>millis</code> plus the timezone offset must be a multiple
+   *     of 24 hours.</li>
+   * <li>if <code>isLocalTz</code> is set, then <code>tzHours</code> and <code>tzMinutes</code> should be 0,
+   *     and <code>isZulu</code> must be false.</li>
+   * <li>if <code>isZulu</code> is set, then <code>tzHours</code> and <code>tzMinutes</code> must be 0.</li>
+   * <li><code>millis</code> % 10^(3 - milliPlaces) == 0</li>
+   * <li>The <code>tzHours</code> and <code>tzMinutes</code> values should correspond to the values in the
+   *     <code>dateTime</code> field.</li>
+   * </ul>
+   * @param dateTime The dateTime object representing the time.
+   * @param tzHours The hour offset for the timezone.
+   * @param tzMinutes The minute offset for the timezone.
+   * @param isMidnight If the non-canonical form for midnight is used. "24:00:00"
+   * @param milliPlaces The number of decimal places used for representing millisecds as fractions of a second.
+   * @param isLocalTz Indicates no timezone information, so use the local default.
+   * @param isZulu Indicates that the timezone is "Zulu". This is equivalent to 00:00 and is represented as "Z".
+   * @throws IllegalArgumentException if the <code>isZulu</code> flag conflicts with the timezone values or the offsets.
+   */
+  private LexicalDateTime(DateTime dateTime, int tzHours, int tzMinutes, boolean isMidnight, byte milliPlaces, boolean isLocalTz, boolean isZulu) {
+    this.millis = dateTime.getMillis();
+    this.tzHours = tzHours;
+    this.tzMinutes = tzMinutes;
+    this.midnight = isMidnight;
+    this.cachedDateTime = dateTime;
+    this.milliPlaces = milliPlaces;
+    this.localFlag = isLocalTz;
+    this.zuluFlag = isZulu;
+    testTimezoneConsistency();
+  }
+
+  /**
+   * Convenience constructor which allows easy construction of a LexicalDateTime using the milliseconds since the epoch.
+   * @param millis Milliseconds since the epoch.
+   */
+  public LexicalDateTime(long millis) {
+    this.millis = millis;
+    long offset = DateTimeZone.getDefault().getOffset(0);
+    tzHours = (int)(offset / MILLIS_IN_HOUR);
+    tzMinutes = (int)(offset % MILLIS_IN_HOUR) / MILLIS_IN_MINUTE;
+    midnight = false;
+    cachedDateTime = null;
+    localFlag = true;
+    zuluFlag = false;
+    milliPlaces = minimumPlaces(millis);
+  }
+
+  /** Gets the number of milliseconds since the epoch. */
+  public long getMillis() {
+    return millis;
+  }
+
+  /** The the hour part of the offset for the timezone. */
+  public int getTZHour() {
+    return tzHours;
+  }
+
+  /** The the minute part of the offset for the timezone. */
+  public long getTZMinute() {
+    return tzMinutes;
+  }
+
+  /** Gets the flag that indicates that this time is a non-canonical form of midnight. */
+  public boolean isMidnight() {
+    return midnight;
+  }
+
+  /** Gets the flag that indicates no timezone is present, and the local default should be used. */
+  public boolean isLocal() {
+    return localFlag;
+  }
+
+  /** Gets the flag that indicates the Zulu timezone (UTC) and representation. */
+  public boolean isZulu() {
+    return zuluFlag;
+  }
+
+  /** Gets the number of decimal places to represent the fraction of a second. */
+  public byte getDecimalPlaces() {
+    return milliPlaces;
+  }
+
+  /** Get the size of buffer in bytes required to store this object */
+  public static int requiredBufferSize() {
+    return PLACES_OFFSET + 1;
+  }
+
+  /**
+   * Fills in a ByteBuffer with the data required to encode this object.
+   * @param bb The {@link java.nio.ByteBuffer} to populate.
+   * @return The populated ByteBuffer.
+   */
+  public ByteBuffer encode(ByteBuffer bb) {
+    assert bb.limit() > PLACES_OFFSET;
+    bb.putLong(0, millis);
+    bb.put(TZ_OFFSET, encodeTimezoneState());
+    bb.put(PLACES_OFFSET, milliPlaces);
+    return bb;
+  }
+
+  /**
+   * Creates a byte code for the timezone and flags of this dateTime.
+   * <table>
+   * <tr><td>bits 7-2</td><td>timezone code</td></tr>
+   * <tr><td >bit 1</td><td>local flag</td></tr>
+   * <tr><td>bit 0</td><td>midnight flag</td></tr>
+   * </table>
+   * @return a byte containing the timezone data.
+   */
+  public byte encodeTimezoneState() {
+    byte result = 0;
+    if (zuluFlag) result = Timezone.getZuluCode();
+    else result = new Timezone(tzHours, tzMinutes).getCode();
+    if (localFlag) result |= LOCAL_BIT;
+    if (midnight) result |= MIDNIGHT_BIT;
+    return result;
+  }
+
+  /**
+   * Decodes a {@link ByteBuffer} into a LexicalDateTime.
+   * @param bb The ByteBuffer to decode.
+   * @return a new LexicalDateTime structure.
+   */
+  public static LexicalDateTime decode(ByteBuffer bb) {
+    assert bb.limit() > PLACES_OFFSET;
+    return decode(bb.getLong(0), bb.get(TZ_OFFSET), bb.get(PLACES_OFFSET));
+  }
+
+  /**
+   * Decodes a millisecond value and an encoded byte into a timezone and flags.
+   * @param millis The milliseconds since the epoch.
+   * @param timezoneState The encoded data representing the timezone.
+   * @param places The number of decimal places for the seconds representation.
+   * @return a new LexicalDateTime structure.
+   */
+  public static LexicalDateTime decode(long millis, byte timezoneState, byte places) {
+    boolean local = (timezoneState & LOCAL_BIT) != 0;
+    boolean midnight = (timezoneState & MIDNIGHT_BIT) != 0;
+    byte tzCode = (byte)(timezoneState & TZ_MASK);
+    boolean zulu = (tzCode == Timezone.getZuluCode());
+    Timezone tz = new Timezone(tzCode);
+    return new LexicalDateTime(millis, tz.getHour(), tz.getMinute(), midnight, places, local, zulu);
+  }
+
+  /** Return a lexical representation of this dateTime. */
+  public String toString() {
+    if (cachedDateTime == null) {
+      DateTimeZone dtz;
+      dtz = (localFlag) ? null : DateTimeZone.forOffsetHoursMinutes(tzHours, tzMinutes);
+      cachedDateTime = new DateTime(millis, dtz);
+    }
+    StringBuilder result;
+    if (!midnight) {
+      result = new StringBuilder(MAIN_FORMATTER.print(cachedDateTime));
+      if (milliPlaces > 0) {
+        result.append(MILLI_SEPARATOR_STR);
+        int place = MILLIS;
+        long fraction = millis;
+        if (fraction < 0) fraction = fraction % place + place;
+        for (int m = 0; m < milliPlaces; m++) {
+          fraction = fraction % place;
+          place /= 10;
+          result.append(fraction / place);
+        }
+      }
+    } else {
+      result = new StringBuilder(DATE_FORMATTER.print(cachedDateTime.plusDays(-1)));
+      result.append(MIDNIGHT_STR);
+      if (milliPlaces > 0) {
+        result.append(MILLI_SEPARATOR_STR);
+        for (int i = 0; i < milliPlaces; i++) result.append("0");
+      }
+    }
+    if (!localFlag) {
+      if (zuluFlag) result.append(ZULU_STR);
+      else result.append(String.format("%+03d:%02d", tzHours, tzMinutes));
+    }
+    return result.toString();
+  }
+
+  /**
+   * Parse a dateTime string. It <strong>must</strong> be of the form:
+   * ('-')? yyyy '-' MM '-' dd 'T' hh ':' mm ':' ss ( '.' s+ )? ( ( ('+'|'-')? hh ':' mm ) | 'Z' )?
+   * @param dt The dateTime string to parse.
+   * @return a new LexcalDateTime value.
+   * @throws ParseException If a character that doesn't match the above pattern is discovered.
+   */
+  public static LexicalDateTime parseDateTime(String dt) throws ParseException {
+    int pos = 0;
+    try {
+      boolean negative = dt.charAt(pos) == '-';
+      if (negative) pos++;
+      int year = d(dt, pos++) * 1000 + d(dt, pos++) * 100 + d(dt, pos++) * 10 + d(dt, pos++);
+      while (dt.charAt(pos) != DATE_SEPARATOR) year = year * 10 + d(dt, pos++);
+      if (negative) year = -year;
+      if (dt.charAt(pos++) != DATE_SEPARATOR) throw new ParseException(BAD_FORMAT + "date: " + dt, pos - 1);
+      int month = d(dt, pos++) * 10 + d(dt, pos++);
+      if (dt.charAt(pos++) != DATE_SEPARATOR) throw new ParseException(BAD_FORMAT + "date: " + dt, pos - 1);
+      int day = d(dt, pos++) * 10 + d(dt, pos++);
+  
+      if (dt.charAt(pos++) != DATE_TIME_SEPARATOR) throw new ParseException(BAD_FORMAT + "date/time: " + dt, pos - 1);
+  
+      int hour = d(dt, pos++) * 10 + d(dt, pos++);
+      if (dt.charAt(pos++) != TIME_SEPARATOR) throw new ParseException(BAD_FORMAT + "time: " + dt, pos - 1);
+      int minute = d(dt, pos++) * 10 + d(dt, pos++);
+      if (dt.charAt(pos++) != TIME_SEPARATOR) throw new ParseException(BAD_FORMAT + "time: " + dt, pos - 1);
+      int second = d(dt, pos++) * 10 + d(dt, pos++);
+  
+      int millisecs = 0;
+      byte milliPlaces = 0;
+      int lastPos = dt.length() - 1;
+      if (pos < lastPos) {
+        if (dt.charAt(pos) == MILLI_SEPARATOR) {
+          int place = MILLIS / 10;
+          int digit;
+          while (isDecimal((digit = dt.charAt(++pos) - '0'))) {
+            millisecs += digit * place;
+            if (milliPlaces++ > 3) throw new ParseException(BAD_FORMAT + "milliseconds: " + dt, pos);
+            place /= 10;
+            if (pos == lastPos) {
+              pos++;
+              break;
+            }
+          }
+        }
+      }
+  
+      boolean midnightFlag = false;
+      if (hour == MIDNIGHT) {
+        midnightFlag = true;
+        hour = 0;
+      }
+      if (midnightFlag && (minute > 0 || second > 0 || millisecs > 0)) throw new ParseException(BAD_FORMAT + "time: " + dt, pos);
+  
+      boolean local = false;
+      int tzHour = 0;
+      int tzMinute = 0;
+      boolean zuluFlag = false;
+      DateTimeZone timezone = null;
+      if (pos <= lastPos) {
+        char tz = dt.charAt(pos++);
+        if (tz == ZULU) {
+          if (pos != lastPos + 1) throw new ParseException(BAD_FORMAT + "timezone: " + dt, pos);
+          timezone = UTC;
+          zuluFlag = true;
+        } else {
+          if (pos != lastPos - 4 || (tz != NEG_TZ && tz != POS_TZ)) throw new ParseException(BAD_FORMAT + "timezone: " + dt, pos);
+          tzHour = d(dt, pos++) * 10 + d(dt, pos++);
+          if (dt.charAt(pos++) != TIME_SEPARATOR) throw new ParseException(BAD_FORMAT + "timezone: " + dt, pos - 1);
+          tzMinute = d(dt, pos++) * 10 + d(dt, pos++);
+          if (tz == NEG_TZ) tzHour = -tzHour;
+          timezone = DateTimeZone.forOffsetHoursMinutes(tzHour, tzMinute);
+        }
+      } else {
+        local = true;
+      }
+  
+      DateTime dateTime = new DateTime(year, month, day, hour, minute, second, millisecs, timezone);
+      if (midnightFlag) dateTime = dateTime.plusDays(1);
+      return new LexicalDateTime(dateTime, tzHour, tzMinute, midnightFlag, milliPlaces, local, zuluFlag);
+    } catch (StringIndexOutOfBoundsException e) {
+      throw new IllegalArgumentException(BAD_FORMAT + "date: " + dt);
+    }
+  }
+
+  /** {@inheritDoc} */
+  public boolean equals(Object o) {
+    if (!(o instanceof LexicalDateTime)) return false;
+    LexicalDateTime other = (LexicalDateTime)o;
+    return millis == other.millis && tzHours == other.tzHours && tzMinutes == other.tzMinutes
+        && milliPlaces == other.milliPlaces && localFlag == other.localFlag
+        && zuluFlag == other.zuluFlag && midnight == other.midnight;
+  }
+
+  /** {@inheritDoc} */
+  public int hashCode() {
+    return Long.valueOf(millis).hashCode() + encodeTimezoneState() * 13;
+  }
+
+  /**
+   * Check that the timezone flags are consistent with one another.
+   * @throws IllegalArgumentException if the is an inconsistency in the timezone values.
+   */
+  private void testTimezoneConsistency() {
+    if (zuluFlag) {
+      if (localFlag) throw new IllegalArgumentException("Cannot have Zulu time and a \"default\" timezone");
+      if (tzHours != 0 || tzMinutes != 0) throw new IllegalArgumentException("Cannot have Zulu time and a timezone offset");
+    }
+    assert (millis % (int)Math.pow(10, 3 - milliPlaces)) == 0;
+  }
+
+  /**
+   * Extract a single decimal digit from a string.
+   * @param str The string to get the digit from.
+   * @param i The location in the string to extract the digit from
+   * @return The extracted digit.
+   * @throws ParseException If the character to be extracted is not a decimal digit.
+   */
+  private static int d(String str, int i) throws ParseException {
+    int d = str.charAt(i) - '0';
+    if (d >= 10 || d < 0) throw new ParseException("Unexpected character: " + Character.toString(str.charAt(i)) + ". Expected numeric digit.", i);
+    return d;
+  }
+
+  /**
+   * Tests if a number represents a single decimal digit.
+   * @param i The number to test.
+   * @return <code>true</code> if the number represents a single decimal digit.
+   */
+  private static boolean isDecimal(int i) {
+    return i < 10 && i >= 0;
+  }
+
+  /**
+   * Determine the minimum number of decimal places required to represent
+   * a millisecond value in seconds.
+   * @param mSec The number of milliseconds to represent.
+   * @return The minimum number of decimal places needed when representing mSec in seconds.
+   *         This result is always in the range 0-3.
+   */
+  private static byte minimumPlaces(long mSec) {
+    byte p = 3;
+    int precision = 1;
+    for (; p > 0; p--) {
+      precision *= 10;
+      if (mSec % precision != 0) break;
+    }
+    return p;
+  }
+}

Copied: branches/mgr-121-lockrecovery/src/jar/util/java/org/mulgara/util/LexicalDateTimeUnitTest.java (from rev 1002, trunk/src/jar/util/java/org/mulgara/util/LexicalDateTimeUnitTest.java)
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/util/java/org/mulgara/util/LexicalDateTimeUnitTest.java	                        (rev 0)
+++ branches/mgr-121-lockrecovery/src/jar/util/java/org/mulgara/util/LexicalDateTimeUnitTest.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -0,0 +1,163 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.util;
+
+import java.nio.ByteBuffer;
+import java.text.ParseException;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Test cases for LexicalDateTime
+ *
+ * @created Jun 5, 2008
+ * @author Paul Gearon
+ * @copyright &copy; 2008 <a href="http://www.topazproject.org/">The Topaz Project</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class LexicalDateTimeUnitTest extends TestCase {
+
+  String[] dtStrings = new String[] {
+      "2005-01-19T20:40:17.001",
+      "2002-10-10T12:00:12.34-05:00",
+      "2002-10-10T12:00:12.34+05:00",
+      "2002-10-10T12:00:12.34+00:00",
+      "2002-10-10T00:00:12.34+00:00",
+      "2002-10-10T24:00:00.00+00:00",
+      "2002-10-10T12:00:12.34+10:00",
+      "2002-10-10T12:00:12.34Z",
+      "2002-10-10T00:00:12.34Z",
+      "2002-10-10T24:00:00.00Z",
+      "2002-10-10T12:00:12.345-05:00",
+      "2002-10-10T12:00:12.345+05:00",
+      "2002-10-10T12:00:12.345+00:00",
+      "2002-10-10T00:00:12.345+00:00",
+      "2002-10-10T24:00:00.000+00:00",
+      "2002-10-10T12:00:12.345+10:00",
+      "2002-10-10T12:00:12.345Z",
+      "2002-10-10T00:00:12.345Z",
+      "2002-10-10T24:00:00.000Z"
+  };
+  
+  String[] negStrings = new String[] {
+      "-0002-10-10T12:00:12.34-05:00",
+      "-0002-10-10T12:00:12.34+05:00",
+      "-0002-10-10T12:00:12.34+00:00",
+      "-0002-10-10T00:00:12.34+00:00",
+      "-0002-10-10T24:00:00.00+00:00",
+      "-0002-10-10T12:00:12.34+10:00",
+      "-0002-10-10T12:00:12.34Z",
+      "-0002-10-10T00:00:12.34Z",
+      "-0002-10-10T24:00:00.00Z",
+      "-0002-10-10T12:00:12.345-05:00",
+      "-0002-10-10T12:00:12.345+05:00",
+      "-0002-10-10T12:00:12.345+00:00",
+      "-0002-10-10T00:00:12.345+00:00",
+      "-0002-10-10T24:00:00.000+00:00",
+      "-0002-10-10T12:00:12.345+10:00",
+      "-0002-10-10T12:00:12.345Z",
+      "-0002-10-10T00:00:12.345Z",
+      "-0002-10-10T24:00:00.000Z"
+  };
+
+  String[] largeStrings = new String[] {
+      "12002-10-10T12:00:12.34-05:00",
+      "120002-10-10T12:00:12.34-05:00",
+      "-12002-10-10T12:00:12.34-05:00",
+      "-120002-10-10T12:00:12.34-05:00"
+  };
+
+  public LexicalDateTimeUnitTest(String name) {
+    super(name);
+  }
+
+  /**
+   * Hook for test runner to obtain a test suite from.
+   * @return The test suite to run.
+   */
+  public static Test suite() {
+    TestSuite suite = new TestSuite();
+    suite.addTest(new LexicalDateTimeUnitTest("testParseDateTime"));
+    suite.addTest(new LexicalDateTimeUnitTest("testEncode"));
+    suite.addTest(new LexicalDateTimeUnitTest("testEncodeTimezoneState"));
+    return suite;
+  }
+
+  /**
+   * Default test runner.
+   *
+   * @param args The command line arguments
+   */
+  public static void main(String[] args) {
+    junit.textui.TestRunner.run(suite());
+  }
+
+  /**
+   * Test method for {@link org.mulgara.util.LexicalDateTime#parseDateTime(java.lang.String)}.
+   */
+  public void testParseDateTime() throws ParseException {
+    parseDateTimeHelper(dtStrings);
+    parseDateTimeHelper(negStrings);
+    parseDateTimeHelper(largeStrings);
+  }
+
+  void parseDateTimeHelper(String[] strings) throws ParseException {
+    for (String l: strings) {
+      LexicalDateTime dt = LexicalDateTime.parseDateTime(l);
+      assertEquals(l, dt.toString());
+    }
+  }
+
+  /**
+   * Test method for {@link org.mulgara.util.LexicalDateTime#encode(java.nio.ByteBuffer)}.
+   */
+  public void testEncode() throws ParseException {
+    encodeHelper(dtStrings);
+    encodeHelper(negStrings);
+    encodeHelper(largeStrings);
+  }
+
+  void encodeHelper(String[] strings) throws ParseException {
+    for (String l: strings) {
+      LexicalDateTime dt = LexicalDateTime.parseDateTime(l);
+
+      ByteBuffer bb = ByteBuffer.allocate(16);
+      LexicalDateTime newDt = LexicalDateTime.decode(dt.encode(bb));
+
+      assertEquals(l, newDt.toString());
+    }
+  }
+
+  /**
+   * Test method for {@link org.mulgara.util.LexicalDateTime#encodeTimezoneState()}.
+   */
+  public void testEncodeTimezoneState() throws ParseException {
+    encodeTimezoneStateHelper(dtStrings);
+    encodeTimezoneStateHelper(negStrings);
+    encodeTimezoneStateHelper(largeStrings);
+  }
+
+  void encodeTimezoneStateHelper(String[] strings) throws ParseException {
+    for (String l: strings) {
+      LexicalDateTime dt = LexicalDateTime.parseDateTime(l);
+      long millis = dt.getMillis();
+      byte tzstate = dt.encodeTimezoneState();
+      byte dec = dt.getDecimalPlaces();
+
+      LexicalDateTime newDt = LexicalDateTime.decode(millis, tzstate, dec);
+      assertEquals(l, newDt.toString());
+    }
+  }
+}

Copied: branches/mgr-121-lockrecovery/src/jar/util/java/org/mulgara/util/Timezone.java (from rev 1002, trunk/src/jar/util/java/org/mulgara/util/Timezone.java)
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/util/java/org/mulgara/util/Timezone.java	                        (rev 0)
+++ branches/mgr-121-lockrecovery/src/jar/util/java/org/mulgara/util/Timezone.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -0,0 +1,145 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.util;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Maps from a known hour:minute offset for a timezone into a 6 bit code, and back.
+ *
+ * @created Jun 5, 2008
+ * @author Paul Gearon
+ * @copyright &copy; 2008 <a href="http://www.topazproject.org/">The Topaz Project</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class Timezone {
+
+  /** A mask for restricting bit patterns to a byte (removing sign extension) */
+  private static final int BYTE_MASK = 0xFF;
+
+  /** The construct that holds the offset details */
+  private HourMinute hm;
+
+  /** The internal code for the timezone offset. */
+  private byte internalCode;
+
+  /**
+   * Constructs a Timezone using a code.
+   * @param code The code for a known timezone.
+   * @throws IllegalArgumentException The code does not correspond to a timezone in the database.
+   */
+  public Timezone(byte code) {
+    if ((code & 3) != 0) throw new IllegalArgumentException("Invalid bit pattern in the timezone code");
+    internalCode = (byte)((code & BYTE_MASK) >> 2);
+    if (internalCode > timezoneList.length || internalCode < 0) throw new IllegalArgumentException("Unknown timezone code: " + code);
+    hm = (code == ZULU_CODE) ? ZULU : timezoneList[internalCode];
+  }
+
+  /**
+   * Constructs a Timezone using an hour:minute offset.
+   * @param hour The hour offset of the timezone. This cannot encode ZULU time.
+   * @param minute The minute offset of the timezone.
+   * @throws IllegalArgumentException The timezone is not in the database of known timezones.
+   */
+  public Timezone(int hour, int minute) {
+    hm = new HourMinute(hour, minute);
+    Byte c = tzCodes.get(hm);
+    if (c == null) throw new IllegalArgumentException("Timezone is not in official database: " + hm);
+    internalCode = c;
+  }
+
+  /** Gets the hour for this timezone. */
+  public int getHour() {
+    return hm.hour;
+  }
+
+  /** Gets the minute for this timezone. */
+  public int getMinute() {
+    return hm.minute;
+  }
+
+  /** Gets the code for this timezone. This is guaranteed to use the top 5 bits, and set the bottom 2 to 0.*/
+  public byte getCode() {
+    return (byte)(internalCode << 2);
+  }
+
+  /** Gets the code for the ZULU timezone. */
+  public static byte getZuluCode() {
+    return ZULU_CODE;
+  }
+
+  /** The ZULU timezone */
+  private static final HourMinute ZULU = new HourMinute(0, 0);
+
+  /** The database of known timezones. @see http://en.wikipedia.org/wiki/List_of_zoneinfo_timezones */
+  private static final HourMinute[] timezoneList = new HourMinute[] {
+    new HourMinute(-12, 0), new HourMinute(-11, 0), new HourMinute(-10, 0), new HourMinute(-9, 30),
+    new HourMinute(-9, 0), new HourMinute(-8, 0), new HourMinute(-7, 0), new HourMinute(-6, 0),
+    new HourMinute(-5, 0), new HourMinute(-4, 30), new HourMinute(-4, 0), new HourMinute(-3, 30),
+    new HourMinute(-3, 0), new HourMinute(-2, 0), new HourMinute(-1, 0), ZULU,
+    new HourMinute(1, 0), new HourMinute(2, 0), new HourMinute(3, 0), new HourMinute(3, 30),
+    new HourMinute(4, 0), new HourMinute(4, 30), new HourMinute(5, 0), new HourMinute(5, 30),
+    new HourMinute(5, 45), new HourMinute(6, 0), new HourMinute(6, 30), new HourMinute(7, 0),
+    new HourMinute(8, 0), new HourMinute(8, 45), new HourMinute(9, 0), new HourMinute(9, 30),
+    new HourMinute(10, 0), new HourMinute(10, 30), new HourMinute(11, 0), new HourMinute(11, 30),
+    new HourMinute(12, 0), new HourMinute(12, 45), new HourMinute(13, 0), new HourMinute(14, 0)
+  };
+
+  /** A map of timezones to their code. */
+  private static final Map<HourMinute,Byte> tzCodes;
+
+  /** A special code for ZULU, to distinguish it from 00:00. This is an external code, so the lowest 2 bits must be 0. */
+  public static final byte ZULU_CODE = (byte)(timezoneList.length << 2);
+
+  // populates the tzCodes with the timezoneList
+  static {
+    Map<HourMinute,Byte> writeMap = new HashMap<HourMinute,Byte>();
+    for (byte t = 0; t < timezoneList.length; t++) writeMap.put(timezoneList[t], t);
+    tzCodes = Collections.unmodifiableMap(writeMap);
+  }
+
+  /**
+   * A private structure for associating an hour and minute together.
+   */
+  private static class HourMinute {
+    /** The hour value. */
+    public final int hour;
+    /** The minute value. */
+    public final int minute;
+
+    /** Constructs an hour and minute tuple */
+    public HourMinute(int h, int m) {
+      hour = h;
+      minute = m;
+    }
+
+    /** @inheritDoc */
+    public int hashCode() {
+      return (hour * 4) + (minute / 15);
+    }
+
+    /** @inheritDoc */
+    public boolean equals(Object o) {
+      return (o instanceof HourMinute) && ((HourMinute)o).hour == hour && ((HourMinute)o).minute == minute;
+    }
+
+    /** @inheritDoc */
+    public String toString() {
+      if (hour == 0 && minute == 0) return "00:00";
+      return String.format("%02d:%02d", hour, minute);
+    }
+  }
+
+}

Modified: branches/mgr-121-lockrecovery/tools/src/org/mulgara/tools/Sparql.java
===================================================================
--- branches/mgr-121-lockrecovery/tools/src/org/mulgara/tools/Sparql.java	2008-06-16 10:43:49 UTC (rev 1004)
+++ branches/mgr-121-lockrecovery/tools/src/org/mulgara/tools/Sparql.java	2008-06-19 03:35:29 UTC (rev 1005)
@@ -75,7 +75,7 @@
     }
 
     // clean up the server connection
-    conn.close();
+    conn.dispose();
   }
 
   /**




More information about the Mulgara-svn mailing list