[Commits] (bcm) extract hibernate dialect setting from hibernate.cfg.xml and configure it in a

commits at osafoundation.org commits at osafoundation.org
Tue Apr 12 16:59:21 PDT 2005


Commit by: bcm
Modified files:
server/build.xml 1.32 1.33
server/bin/cosmoctl 1.1 1.2
server/core/build.xml 1.17 1.18
server/core/etc/applicationContext-datasource.xml None 1.1
server/core/etc/applicationContext-hibernate.xml 1.2 1.3
server/core/etc/hibernate.cfg.xml 1.2 1.3
server/core/test/etc/applicationContext-datasource.xml None 1.1
server/core/test/etc/hibernate.cfg.xml 1.1 None
server/docs/TODO.txt 1.50 1.51
server/etc/hibernate.properties None 1.1
server/web/web/WEB-INF/web.xml 1.4 1.5

Log message:
extract hibernate dialect setting from hibernate.cfg.xml and configure it in a
hibernate.properties file installed into $CATALINA_HOME/common/lib. this gives
the cosmo admin a simple way to change the dialect if he's using a database
other than mysql.

pull the datasource configuration out of hibernate.cfg.xml and set it up in a
separate applicationContext-datasource.xml. this allows us to provide a
different version of that file for tests that doesn't depend on a running j2ee
container, and it vastly simplifies our hibernate config.


ViewCVS links:
http://cvs.osafoundation.org/index.cgi/server/build.xml.diff?r1=text&tr1=1.32&r2=text&tr2=1.33
http://cvs.osafoundation.org/index.cgi/server/bin/cosmoctl.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
http://cvs.osafoundation.org/index.cgi/server/core/build.xml.diff?r1=text&tr1=1.17&r2=text&tr2=1.18
http://cvs.osafoundation.org/index.cgi/server/core/etc/applicationContext-datasource.xml?rev=1.1&content-type=text/vnd.viewcvs-markup
http://cvs.osafoundation.org/index.cgi/server/core/etc/applicationContext-hibernate.xml.diff?r1=text&tr1=1.2&r2=text&tr2=1.3
http://cvs.osafoundation.org/index.cgi/server/core/etc/hibernate.cfg.xml.diff?r1=text&tr1=1.2&r2=text&tr2=1.3
http://cvs.osafoundation.org/index.cgi/server/core/test/etc/applicationContext-datasource.xml?rev=1.1&content-type=text/vnd.viewcvs-markup
http://cvs.osafoundation.org/index.cgi/server/core/test/etc/hibernate.cfg.xml.diff?r1=text&tr1=1.1&r2=text&tr2=None
http://cvs.osafoundation.org/index.cgi/server/docs/TODO.txt.diff?r1=text&tr1=1.50&r2=text&tr2=1.51
http://cvs.osafoundation.org/index.cgi/server/etc/hibernate.properties?rev=1.1&content-type=text/vnd.viewcvs-markup
http://cvs.osafoundation.org/index.cgi/server/web/web/WEB-INF/web.xml.diff?r1=text&tr1=1.4&r2=text&tr2=1.5

Index: server/docs/TODO.txt
diff -u server/docs/TODO.txt:1.50 server/docs/TODO.txt:1.51
--- server/docs/TODO.txt:1.50	Tue Apr 12 15:57:37 2005
+++ server/docs/TODO.txt	Tue Apr 12 16:59:19 2005
@@ -4,8 +4,6 @@
 
 core:
 
- * don't pack hibernate config file in jar and place it somewhere a
-   cosmo admin can find it to tweak the dialect
  * make pk of user and role tables a long id rather than name (but
    keep that col indexed)
 

Index: server/bin/cosmoctl
diff -u server/bin/cosmoctl:1.1 server/bin/cosmoctl:1.2
--- server/bin/cosmoctl:1.1	Fri Apr  8 16:53:16 2005
+++ server/bin/cosmoctl	Tue Apr 12 16:59:17 2005
@@ -28,12 +28,12 @@
   exit 1
 fi
 
-# move into the chsrv homedir so the slide store files are created there
+# move into the cosmo homedir so that paths relative to the current
+# working directory resolve correctly
 cd $PRGDIR/../..
 
 export COSMO_HOME=`pwd`
 export CATALINA_HOME=$COSMO_HOME/tomcat
-export CATALINA_OPTS="$CATALINA_OPTS -Djava.security.auth.login.config==etc/jaas.config"
 
 echo "Using COSMO_HOME:      $COSMO_HOME"
 

Index: server/build.xml
diff -u server/build.xml:1.32 server/build.xml:1.33
--- server/build.xml:1.32	Tue Apr 12 16:27:28 2005
+++ server/build.xml	Tue Apr 12 16:59:17 2005
@@ -50,20 +50,6 @@
 
   <!-- TEST TARGETS -->
 
-  <target name="test-gen"
-          description="">
-    <copy todir="${cosmo.test}"
-          file="${core.test}/etc/hibernate.cfg.xml">
-      <filterset>
-        <filter token="DB_USERNAME" value="${cosmo.test.userdb.username}"/>
-        <filter token="DB_PASSWORD" value="${cosmo.test.userdb.password}"/>
-        <filter token="DB_DRIVER" value="${cosmo.test.userdb.driver}"/>
-        <filter token="DB_URL" value="${cosmo.test.userdb.url}"/>
-        <filter token="DIALECT" value="${cosmo.test.userdb.dialect}"/>
-      </filterset>
-    </copy>
-  </target>
-
   <target name="test-dbsetup"
           description="set up the test user database">
     <echo>Setting up test db ${cosmo.test.userdb.url}</echo>
@@ -80,9 +66,6 @@
     </sql>
   </target>
 
-  <target name="test-init" depends="test-gen,test-dbsetup"
-          description="initialize test environment... only needed once"/>
-
   <target name="test" depends="test-core,test-web"
           description="run all tests"/>
 
@@ -155,7 +138,7 @@
   </target>
 
   <target name="dist-server"
-          description="install server scripts and config into Tomcat">
+          description="install server scripts and configuration">
     <mkdir dir="${cosmo.dist.version}/logs"/>
     <copy todir="${cosmo.dist.version}/bin"
           file="${cosmo.bin}/cosmoctl"/>
@@ -181,6 +164,12 @@
         <include name="repository.xml"/>
       </fileset>
     </copy>
+    <copy todir="${cosmo.dist.tomcat}/common/classes"
+          file="${cosmo.etc}/hibernate.properties">
+      <filterset>
+        <filter token="DIALECT" value="${cosmo.dist.userdb.dialect}"/>
+      </filterset>
+    </copy>
     <!-- needed for tomcat's own logging -->
     <copy todir="${cosmo.dist.tomcat}/common/classes"
           file="${cosmo.etc}/log4j.xml"/>

Index: server/web/web/WEB-INF/web.xml
diff -u server/web/web/WEB-INF/web.xml:1.4 server/web/web/WEB-INF/web.xml:1.5
--- server/web/web/WEB-INF/web.xml:1.4	Mon Apr 11 13:59:46 2005
+++ server/web/web/WEB-INF/web.xml	Tue Apr 12 16:59:19 2005
@@ -8,6 +8,7 @@
     <param-name>contextConfigLocation</param-name>
     <param-value>
       classpath:applicationContext-base.xml
+      classpath:applicationContext-datasource.xml
       classpath:applicationContext-hibernate.xml
       classpath:applicationContext-jcr-client.xml
       classpath:applicationContext-manager.xml

Index: server/core/etc/applicationContext-hibernate.xml
diff -u server/core/etc/applicationContext-hibernate.xml:1.2 server/core/etc/applicationContext-hibernate.xml:1.3
--- server/core/etc/applicationContext-hibernate.xml:1.2	Fri Apr  8 16:53:16 2005
+++ server/core/etc/applicationContext-hibernate.xml	Tue Apr 12 16:59:18 2005
@@ -12,6 +12,12 @@
     <property name="configLocation">
       <value>classpath:hibernate.cfg.xml</value>
     </property>
+    <property name="hibernateProperties">
+      <value>classpath:hibernate.properties</value>
+    </property>
+    <property name="dataSource">
+      <ref bean="dataSource"/>
+    </property>
   </bean>
 
   <bean id="transactionManager"

Index: server/core/build.xml
diff -u server/core/build.xml:1.17 server/core/build.xml:1.18
--- server/core/build.xml:1.17	Tue Apr 12 16:27:29 2005
+++ server/core/build.xml	Tue Apr 12 16:59:18 2005
@@ -41,19 +41,9 @@
   </target>
 
   <target name="pack-jar" description="pack the jar">
-    <copy todir="${core.build}/classes"
-          file="${core.etc}/hibernate.cfg.xml">
-      <filterset>
-        <filter token="DATASOURCE"
-                value="${cosmo.dist.userdb.dataSource}"/>
-        <filter token="DIALECT"
-                value="${cosmo.dist.userdb.dialect}"/>
-      </filterset>
-    </copy>
     <jar destfile="${core.build}/cosmo-core.jar"
          basedir="${core.build}/classes">
       <fileset dir="${core.etc}">
-        <exclude name="hibernate.cfg.xml"/>
         <include name="*.xml"/>
       </fileset>
     </jar>
@@ -74,12 +64,7 @@
     <mkdir dir="${core.test}/data"/>
   </target>
 
-  <target name="test-gen" depends="test-prepare"
-          description="generate test Hibernate config file">
-    <ant dir="${cosmo.home}" target="test-gen" inheritAll="false"/>
-  </target>
-
-  <target name="test-compile" depends="test-prepare,test-gen"
+  <target name="test-compile" depends="test-prepare"
           description="build the test source">
     <javac srcdir="${core.test}"
            destdir="${core.build}/testclasses"
@@ -97,30 +82,31 @@
   <target name="test" depends="all,test-compile"
           description="run JUnit tests">
     <copy todir="${core.build}/testclasses">
+      <fileset dir="${core.etc}">
+        <include name="hibernate.properties"/>
+      </fileset>
       <fileset dir="${core.test}/etc">
         <include name="applicationContext-jcr-client.xml"/>
+        <include name="applicationContext-datasource.xml"/>
+        <include name="log4j.xml"/>
       </fileset>
       <filterset>
         <filter token="CONFIGFILEPATH"
                 value="${cosmo.etc}/repository.xml"/>
         <filter token="REPOSITORYHOMEDIRPATH"
                 value="${core.test}/repository"/>
+        <filter token="DIALECT"
+                value="${cosmo.test.userdb.dialect}/"/>
+        <filter token="DRIVER"
+                value="${cosmo.test.userdb.driver}/"/>
+        <filter token="DB_URL"
+                value="${cosmo.test.userdb.url}/"/>
+        <filter token="DB_USERNAME"
+                value="${cosmo.test.userdb.username}/"/>
+        <filter token="DB_PASSWORD"
+                value="${cosmo.test.userdb.password}/"/>
       </filterset>
     </copy>
-    <copy todir="${core.build}/testclasses">
-      <fileset dir="${core.test}/etc">
-        <include name="log4j.xml"/>
-      </fileset>
-      <fileset dir="${core.etc}">
-        <include name="applicationContext-base.xml"/>
-        <include name="applicationContext-hibernate.xml"/>
-        <include name="applicationContext-manager.xml"/>
-        <include name="ehcache.xml"/>
-      </fileset>
-      <fileset dir="${cosmo.test}">
-        <include name="hibernate.cfg.xml"/>
-      </fileset>
-    </copy>
     <junit printsummary="no" fork="true"
            errorProperty="test.failed" failureProperty="test.failed">
       <classpath>

Index: server/core/etc/hibernate.cfg.xml
diff -u server/core/etc/hibernate.cfg.xml:1.2 server/core/etc/hibernate.cfg.xml:1.3
--- server/core/etc/hibernate.cfg.xml:1.2	Tue Apr 12 16:27:29 2005
+++ server/core/etc/hibernate.cfg.xml	Tue Apr 12 16:59:18 2005
@@ -5,8 +5,6 @@
 
 <hibernate-configuration>
   <session-factory>
-    <property name="connection.datasource">@DATASOURCE@</property>
-    <property name="dialect">@DIALECT@</property>
     <property name="show_sql">false</property>
     <property name="use_outer_join">false</property>
     <mapping resource="Role.hbm.xml"/>



More information about the Commits mailing list