|
From: <vga...@us...> - 2010-02-07 21:38:11
|
Revision: 484
http://treebase.svn.sourceforge.net/treebase/?rev=484&view=rev
Author: vgapeyev
Date: 2010-02-07 21:38:04 +0000 (Sun, 07 Feb 2010)
Log Message:
-----------
Installation location for Mesquite is now looked up via JNDI.
Modified Paths:
--------------
trunk/treebase-core/src/main/java/org/cipres/treebase/service/nexus/NexusServiceMesquite.java
trunk/treebase-core/src/main/resources/applicationContext-service.xml
trunk/treebase-core/src/main/resources/jdbc.properties.example
trunk/treebase-web/src/main/webapp/META-INF/context.xml.example
trunk/treebase-web/src/main/webapp/WEB-INF/web.xml
Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/service/nexus/NexusServiceMesquite.java
===================================================================
--- trunk/treebase-core/src/main/java/org/cipres/treebase/service/nexus/NexusServiceMesquite.java 2010-02-04 17:46:20 UTC (rev 483)
+++ trunk/treebase-core/src/main/java/org/cipres/treebase/service/nexus/NexusServiceMesquite.java 2010-02-07 21:38:04 UTC (rev 484)
@@ -5,6 +5,9 @@
import java.util.Collection;
import java.util.Properties;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
import mesquite.lib.MesquiteModule;
import org.apache.log4j.Logger;
@@ -19,6 +22,7 @@
import org.cipres.treebase.domain.taxon.TaxonLabelHome;
import org.cipres.treebase.event.ProgressionListener;
import org.cipres.treebase.service.AbstractServiceImpl;
+import org.springframework.beans.factory.InitializingBean;
/**
* NexusServiceMesquite.java
@@ -28,7 +32,7 @@
* @author Jin Ruan
*
*/
-public class NexusServiceMesquite extends AbstractServiceImpl implements NexusService {
+public class NexusServiceMesquite extends AbstractServiceImpl implements NexusService, InitializingBean {
private static final Logger LOGGER = Logger.getLogger(NexusServiceMesquite.class);
private static final String MESQUITE_FOLDER_DIR_KEY = "mesquite.folder_dir";
@@ -99,7 +103,28 @@
protected DomainHome getDomainHome() {
return null; // do not need persistence service.
}
+
+ /** Looks up where Mesquite is installed on the host system and informs MesquiteModule of the location.
+ (This is an implementation of a standard Spring bean initialization method,
+ which is invoked after all properties are set.)
+ */
+ public void afterPropertiesSet() throws Exception {
+ String mesquiteFolderDir = null;
+ InitialContext ic;
+ try {
+ ic = new InitialContext();
+ mesquiteFolderDir = (String) ic.lookup("java:comp/env/tb2/MesquiteFolder");
+ } catch (NamingException e) {
+ LOGGER.fatal("Error looking up tb/MesquiteFolder via JNDI");
+ }
+ mesquiteFolderDir = mesquiteFolderDir + "/foo"; //since the last path element is somehow dropped subsequently... VG 2010-02-07
+ System.setProperty(MESQUITE_FOLDER_DIR_KEY, mesquiteFolderDir);
+ MesquiteModule.mesquiteDirectory = new File(mesquiteFolderDir);
+ MesquiteModule.mesquiteDirectoryPath = mesquiteFolderDir;
+ }
+
+
/**
*
* @see org.cipres.treebase.domain.nexus.NexusService#parseNexus(org.cipres.treebase.domain.study.Study, java.io.File)
@@ -185,18 +210,7 @@
return data;
}
-
- /**
- * Set the mesquite folder dirtory to be used inside mesquite file "MesquiteModule.java".
- *
- * @param pMesquiteFolderDir
- */
- public void setMesquiteFolderDir(String pMesquiteFolderDir) {
- System.setProperty(MESQUITE_FOLDER_DIR_KEY, pMesquiteFolderDir);
- MesquiteModule.mesquiteDirectory = new File(pMesquiteFolderDir);
- MesquiteModule.mesquiteDirectoryPath = pMesquiteFolderDir;
- }
-
+
@Override
public Class defaultResultClass() {
return null;
Modified: trunk/treebase-core/src/main/resources/applicationContext-service.xml
===================================================================
--- trunk/treebase-core/src/main/resources/applicationContext-service.xml 2010-02-04 17:46:20 UTC (rev 483)
+++ trunk/treebase-core/src/main/resources/applicationContext-service.xml 2010-02-07 21:38:04 UTC (rev 484)
@@ -142,8 +142,7 @@
<property name="matrixDataTypeHome" ref="matrixDataTypeHome"/>
<property name="taxonLabelHome" ref="taxonLabelHome"/>
<property name="itemDefinitionHome" ref="itemDefinitionHome"/>
- <property name="mesquiteFolderDir" value="${mesquite.folder_dir}"/>
- </bean>
+ </bean>
<bean id="nexmlService" class = "org.cipres.treebase.service.nexus.NexusServiceNexml">
<!-- property name="domainHome" ref="domainHome"/ -->
Modified: trunk/treebase-core/src/main/resources/jdbc.properties.example
===================================================================
--- trunk/treebase-core/src/main/resources/jdbc.properties.example 2010-02-04 17:46:20 UTC (rev 483)
+++ trunk/treebase-core/src/main/resources/jdbc.properties.example 2010-02-07 21:38:04 UTC (rev 484)
@@ -1,16 +1,3 @@
-#### 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
@@ -23,5 +10,19 @@
# options are: validate | update | create | create-drop
hibernate.hbm2ddl.auto=
+
+#### VG 2010-02-07 Properties below are not read by the webapp anymore.
+#### Instead, equivalent resources are looked up through JNDI -- see /treebase-web/src/main/webapp/META-INF/context.xml
+#### These properties are only read 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
+
# Mesquite installation directory
-mesquite.folder_dir=/home/rvosa/applications/mesquiteHeadless/Mesquite_Folder/
+mesquite.folder_dir=/PATH/TO/YOUR/mesquite-2.01.tb
Modified: trunk/treebase-web/src/main/webapp/META-INF/context.xml.example
===================================================================
--- trunk/treebase-web/src/main/webapp/META-INF/context.xml.example 2010-02-04 17:46:20 UTC (rev 483)
+++ trunk/treebase-web/src/main/webapp/META-INF/context.xml.example 2010-02-07 21:38:04 UTC (rev 484)
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- An example of META-INF/context.xml - a Tomcat-specific shorthand to specify JNDI resources during development.
+<!-- This is 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.)
+<!-- Copy this file (context.xml.example) to context.xml and replace YOUR-XXX strings with suitable values.
+ (Note that context.xml is set to be ignored by SVN, so placing 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,
@@ -16,13 +16,19 @@
<Context reloadable="true">
- <Resource name="jdbc/TreebaseDB" auth="Container"
- type="javax.sql.DataSource" driverClassName="org.postgresql.Driver"
+ <Resource name="jdbc/TreebaseDB" auth="Container"
+ type="javax.sql.DataSource"
+ description="The JNDI DataSource for the Treebase postgres instance."
+ driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://YOUR-URL"
username="YOUR-NAME" password="YOUR-PASS"
maxActive="20" maxIdle="10" maxWait="-1"
/>
-
+
+ <Environment name="tb2/MesquiteFolder" value="/PATH/TO/YOUR/mesquite-2.01.tb"
+ type="java.lang.String" override="false"
+ description="Absolute path to the directory where headless Mesquite is unpacked on the host system."/>
+
</Context>
Modified: trunk/treebase-web/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/treebase-web/src/main/webapp/WEB-INF/web.xml 2010-02-04 17:46:20 UTC (rev 483)
+++ trunk/treebase-web/src/main/webapp/WEB-INF/web.xml 2010-02-07 21:38:04 UTC (rev 484)
@@ -48,6 +48,12 @@
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
+
+ <env-entry>
+ <description>Absolute path to the directory where headless Mesquite is unpacked on the host system.</description>
+ <env-entry-name>tb2/MesquiteFolder</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ </env-entry>
<!-- ========================================================== -->
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|