|
From: <vga...@us...> - 2010-01-13 17:04:12
|
Revision: 423
http://treebase.svn.sourceforge.net/treebase/?rev=423&view=rev
Author: vgapeyev
Date: 2010-01-13 17:04:03 +0000 (Wed, 13 Jan 2010)
Log Message:
-----------
Switching to use JNDI for the DataSource in the web app.
The standalone apps still get their db credentials from jdbc.properties.
Description of the new setup is at https://sourceforge.net/apps/mediawiki/treebase/index.php?title=Databases
Modified Paths:
--------------
trunk/treebase-core/src/main/java/org/cipres/treebase/core/CoreServiceLauncher.java
trunk/treebase-core/src/main/resources/applicationContext-dao.xml
trunk/treebase-web/src/main/webapp/WEB-INF/web.xml
Added Paths:
-----------
trunk/treebase-core/src/main/resources/applicationContext-db-standalone.xml
trunk/treebase-core/src/main/resources/applicationContext-db-webapp.xml
trunk/treebase-core/src/main/resources/jdbc.properties.example
trunk/treebase-web/src/main/webapp/META-INF/context.xml.example
Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/core/CoreServiceLauncher.java
===================================================================
--- trunk/treebase-core/src/main/java/org/cipres/treebase/core/CoreServiceLauncher.java 2010-01-12 18:28:42 UTC (rev 422)
+++ trunk/treebase-core/src/main/java/org/cipres/treebase/core/CoreServiceLauncher.java 2010-01-13 17:04:03 UTC (rev 423)
@@ -18,6 +18,7 @@
private static final Logger LOGGER = Logger.getLogger(CoreServiceLauncher.class);
private static final String[] SPRING_CONFIG_FILES = new String[] {// "applicationContext.xml",
+ "applicationContext-db-standalone.xml", // 2010-01-12 VG
"applicationContext-dao.xml",
"applicationContext-service.xml",
"applicationContext-standalone.xml" // 20090222 MJD
Modified: trunk/treebase-core/src/main/resources/applicationContext-dao.xml
===================================================================
--- trunk/treebase-core/src/main/resources/applicationContext-dao.xml 2010-01-12 18:28:42 UTC (rev 422)
+++ trunk/treebase-core/src/main/resources/applicationContext-dao.xml 2010-01-13 17:04:03 UTC (rev 423)
@@ -22,24 +22,31 @@
</property>
</bean>
+
+<!-- VG 2010-01-11 instead, see applicationContext-db-webapp.xml and applicationContext-db-standalone.xml
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${jdbc.driverClassName}" />
<property name="jdbcUrl" value="${jdbc.url}" />
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="minPoolSize" value="5" />
+-->
<!-- reduce to expose connection leak problem, if any
property name="maxPoolSize" value="100" /-->
+<!--
<property name="maxPoolSize" value="10" />
<property name="initialPoolSize" value="6" />
<property name="maxIdleTime" value="3600" />
+-->
<!--property name="maxIdleTime" value="9000" /-->
+<!--
<property name="maxConnectionAge" value="18000" />
<property name="idleConnectionTestPeriod" value="300" />
<property name="maxIdleTimeExcessConnections" value="300" />
<property name="maxStatementsPerConnection" value="100" />
<property name="numHelperThreads" value="5" />
</bean>
+-->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
Added: trunk/treebase-core/src/main/resources/applicationContext-db-standalone.xml
===================================================================
--- trunk/treebase-core/src/main/resources/applicationContext-db-standalone.xml (rev 0)
+++ trunk/treebase-core/src/main/resources/applicationContext-db-standalone.xml 2010-01-13 17:04:03 UTC (rev 423)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://www.directwebremoting.org/schema/spring-dwr
+ http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd"
+ default-autowire="no">
+
+ <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
+ <property name="driverClass" value="${jdbc.driverClassName}" />
+ <property name="jdbcUrl" value="${jdbc.url}" />
+ <property name="user" value="${jdbc.username}" />
+ <property name="password" value="${jdbc.password}" />
+ <property name="minPoolSize" value="5" />
+ <!-- reduce to expose connection leak problem, if any
+ property name="maxPoolSize" value="100" /-->
+ <property name="maxPoolSize" value="10" />
+ <property name="initialPoolSize" value="6" />
+ <property name="maxIdleTime" value="3600" />
+ <!--property name="maxIdleTime" value="9000" /-->
+ <property name="maxConnectionAge" value="18000" />
+ <property name="idleConnectionTestPeriod" value="300" />
+ <property name="maxIdleTimeExcessConnections" value="300" />
+ <property name="maxStatementsPerConnection" value="100" />
+ <property name="numHelperThreads" value="5" />
+ </bean>
+
+
+
+</beans>
+
\ No newline at end of file
Added: trunk/treebase-core/src/main/resources/applicationContext-db-webapp.xml
===================================================================
--- trunk/treebase-core/src/main/resources/applicationContext-db-webapp.xml (rev 0)
+++ trunk/treebase-core/src/main/resources/applicationContext-db-webapp.xml 2010-01-13 17:04:03 UTC (rev 423)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://www.directwebremoting.org/schema/spring-dwr
+ http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd"
+ default-autowire="no">
+
+ <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
+ <property name="jndiName" value="java:comp/env/jdbc/TreebaseDB"/>
+ </bean>
+
+</beans>
\ No newline at end of file
Added: trunk/treebase-core/src/main/resources/jdbc.properties.example
===================================================================
--- trunk/treebase-core/src/main/resources/jdbc.properties.example (rev 0)
+++ trunk/treebase-core/src/main/resources/jdbc.properties.example 2010-01-13 17:04:03 UTC (rev 423)
@@ -0,0 +1,27 @@
+#### VG 2010-01-12 DB credentials that are used by the web application are now in JNDI -- see /treebase-web/src/main/webapp/META-INF/context.xml
+#### The credentials below are only used by tests and, possibly, by data importing classes in cipres.teebase.util
+#### (see treebase-core/src/main/java/org/cipres/treebase/core/CoreServiceLauncher.java)
+
+jdbc.driverClassName=org.postgresql.Driver
+
+# Login credentials, obtain the actual values from
+# other developers (or create your own on a fresh install).
+jdbc.url=jdbc:postgresql://YOUR.SERVER.ORG/YOUR-DB
+jdbc.username=YOUR_USERNAME
+jdbc.password=YOUT_PASSWORD
+
+
+# This tells our object-relational mapping libraries
+# to use postgres-specific SQL dialect
+hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
+
+# for development only:
+hibernate.show_sql=false
+hibernate.format_sql=true
+hibernate.generate_statistics=false
+
+# options are: validate | update | create | create-drop
+hibernate.hbm2ddl.auto=
+
+# Mesquite installation directory
+mesquite.folder_dir=/home/rvosa/applications/mesquiteHeadless/Mesquite_Folder/
Added: trunk/treebase-web/src/main/webapp/META-INF/context.xml.example
===================================================================
--- trunk/treebase-web/src/main/webapp/META-INF/context.xml.example (rev 0)
+++ trunk/treebase-web/src/main/webapp/META-INF/context.xml.example 2010-01-13 17:04:03 UTC (rev 423)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- An example of META-INF/context.xml - a Tomcat-specific shorthand to specify JNDI resources during development.
+ See http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
+ -->
+
+<!-- Copy this file (context.xml.example) to context.xml and replace YOUR-XXX strings with suitable credentials.
+ (Note that context.xml is set to be ignored by SVN, so storing passwords there is safe.)
+ Make sure that $CATALINA_HOME/common/lib contains a postgres JDBC driver jar.
+ Now, dropping treebase-web.war to $CATALINA_HOME/webapps of a vanilla Tomcat should automatically create
+ config file $CATALINA_HOME/conf/Catalina/localhost/treebase-web.xml,
+ which instructs Tomcat to provide a JNDI DataSource.
+ FYI: If this config is created or modified by hand, it is not affected by WAR (re-)deployments.
+ (I.e., server-side configuration supercedes WAR-side.)
+-->
+
+<Context reloadable="true">
+
+ <Resource name="jdbc/TreebaseDB" auth="Container"
+ type="javax.sql.DataSource" driverClassName="org.postgresql.Driver"
+ url="jdbc:postgresql://YOUR-URL"
+ username="YOUR-NAME" password="YOUR-PASS"
+ maxActive="20" maxIdle="10" maxWait="-1"
+ />
+
+</Context>
+
+
Modified: trunk/treebase-web/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/treebase-web/src/main/webapp/WEB-INF/web.xml 2010-01-12 18:28:42 UTC (rev 422)
+++ trunk/treebase-web/src/main/webapp/WEB-INF/web.xml 2010-01-13 17:04:03 UTC (rev 423)
@@ -18,6 +18,7 @@
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
+ classpath*:applicationContext-db-webapp.xml,
classpath*:applicationContext-dao.xml,
classpath*:applicationContext-service.xml,
/WEB-INF/applicationContext.xml,
@@ -37,6 +38,16 @@
<param-value>en</param-value>
</context-param>
+
+ <!-- =================================================================== -->
+ <!-- Declarations of JNDI Resources expected from the Tomcat container -->
+ <!-- =================================================================== -->
+ <resource-ref>
+ <description>The JNDI DataSource of the Treebase postgres instance that should be supplied by Tomcat.</description>
+ <res-ref-name>jdbc/TreebaseDB</res-ref-name>
+ <res-type>javax.sql.DataSource</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
<!-- ========================================================== -->
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|