From: <vga...@us...> - 2010-02-09 20:52:16
|
Revision: 487 http://treebase.svn.sourceforge.net/treebase/?rev=487&view=rev Author: vgapeyev Date: 2010-02-09 20:51:58 +0000 (Tue, 09 Feb 2010) Log Message: ----------- Split nexusService bean into 2: one for the webapp (init via JNDI) and another for the standalone tools (init from jdbc.properties) Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/service/nexus/NexusServiceMesquite.java 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/applicationContext-service.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-08 17:07:55 UTC (rev 486) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/service/nexus/NexusServiceMesquite.java 2010-02-09 20:51:58 UTC (rev 487) @@ -40,6 +40,9 @@ private MatrixDataTypeHome mMatrixDataTypeHome; private ItemDefinitionHome mItemDefinitionHome; + private String mExplicitMesquiteFolder = null; + private String mJndiMesquiteFolder = null; + /** * Constructor. */ @@ -104,24 +107,47 @@ return null; // do not need persistence service. } - /** Looks up where Mesquite is installed on the host system and informs MesquiteModule of the location. + + /** Explicitly set Mesquite folder location that will be passed to mesquite.lib.MesquiteModule. + * Only for use in tests and stand-alone tools (the webapp looks up the location in afterPropertiesSet()). + * + * @param pMesquiteFolderDir + */ + public void setMesquiteFolderDir(String pMesquiteFolderDir) { + mExplicitMesquiteFolder = pMesquiteFolderDir; + LOGGER.info("Mesquite folder location set explicitly to " + mExplicitMesquiteFolder); + //-- + //System.setProperty(MESQUITE_FOLDER_DIR_KEY, pMesquiteFolderDir); + //MesquiteModule.mesquiteDirectory = new File(pMesquiteFolderDir); + //MesquiteModule.mesquiteDirectoryPath = pMesquiteFolderDir; + } + + + /** Looks up where Mesquite is installed on the host system and passes the location to mesquite.lib.MesquiteModule. (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"); + InitialContext ic = new InitialContext(); + mJndiMesquiteFolder = (String) ic.lookup("java:comp/env/tb2/MesquiteFolder"); } catch (NamingException e) { - LOGGER.fatal("Error looking up tb/MesquiteFolder via JNDI"); + LOGGER.info("Failure 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; + String mesquiteFolder; + if (mExplicitMesquiteFolder == null) + if (mJndiMesquiteFolder == null) { mesquiteFolder = null; LOGGER.fatal("Failed to determine Mesquite folder location"); } + else { mesquiteFolder = mJndiMesquiteFolder; LOGGER.info("Setting mesquite folder location from JNDI: " + mJndiMesquiteFolder); } + else + if (mJndiMesquiteFolder == null) { mesquiteFolder = mExplicitMesquiteFolder; LOGGER.info("Using explicitly set Mesquite folder: " + mExplicitMesquiteFolder);} + else { mesquiteFolder = mJndiMesquiteFolder; LOGGER.warn("Explicitly set Mesquite folder (" + mExplicitMesquiteFolder + + ") is overwritten by the one from JNDI: " + mJndiMesquiteFolder); } + + mesquiteFolder = mesquiteFolder + "/foo"; //since the last path element is somehow dropped subsequently... VG 2010-02-07 + System.setProperty(MESQUITE_FOLDER_DIR_KEY, mesquiteFolder); + MesquiteModule.mesquiteDirectory = new File(mesquiteFolder); + MesquiteModule.mesquiteDirectoryPath = mesquiteFolder; } Modified: trunk/treebase-core/src/main/resources/applicationContext-db-standalone.xml =================================================================== --- trunk/treebase-core/src/main/resources/applicationContext-db-standalone.xml 2010-02-08 17:07:55 UTC (rev 486) +++ trunk/treebase-core/src/main/resources/applicationContext-db-standalone.xml 2010-02-09 20:51:58 UTC (rev 487) @@ -28,6 +28,12 @@ <property name="numHelperThreads" value="5" /> </bean> + <bean id="nexusService" class = "org.cipres.treebase.service.nexus.NexusServiceMesquite"> + <property name="matrixDataTypeHome" ref="matrixDataTypeHome"/> + <property name="taxonLabelHome" ref="taxonLabelHome"/> + <property name="itemDefinitionHome" ref="itemDefinitionHome"/> + <property name="mesquiteFolderDir" value="${mesquite.folder_dir}"/> + </bean> </beans> Modified: trunk/treebase-core/src/main/resources/applicationContext-db-webapp.xml =================================================================== --- trunk/treebase-core/src/main/resources/applicationContext-db-webapp.xml 2010-02-08 17:07:55 UTC (rev 486) +++ trunk/treebase-core/src/main/resources/applicationContext-db-webapp.xml 2010-02-09 20:51:58 UTC (rev 487) @@ -13,4 +13,10 @@ <property name="jndiName" value="java:comp/env/jdbc/TreebaseDB"/> </bean> + <bean id="nexusService" class = "org.cipres.treebase.service.nexus.NexusServiceMesquite"> + <property name="matrixDataTypeHome" ref="matrixDataTypeHome"/> + <property name="taxonLabelHome" ref="taxonLabelHome"/> + <property name="itemDefinitionHome" ref="itemDefinitionHome"/> + </bean> + </beans> \ No newline at end of file Modified: trunk/treebase-core/src/main/resources/applicationContext-service.xml =================================================================== --- trunk/treebase-core/src/main/resources/applicationContext-service.xml 2010-02-08 17:07:55 UTC (rev 486) +++ trunk/treebase-core/src/main/resources/applicationContext-service.xml 2010-02-09 20:51:58 UTC (rev 487) @@ -137,13 +137,14 @@ <property name="matrixDataTypeHome" ref="matrixDataTypeHome"/> <property name="taxonLabelHome" ref="taxonLabelHome"/> </bean--> - + +<!-- VG 2010-02-09 nexusService bean is now set in applicationContext-db-webappp.xml and in applicationContext-db-standalone.xml <bean id="nexusService" class = "org.cipres.treebase.service.nexus.NexusServiceMesquite"> <property name="matrixDataTypeHome" ref="matrixDataTypeHome"/> <property name="taxonLabelHome" ref="taxonLabelHome"/> <property name="itemDefinitionHome" ref="itemDefinitionHome"/> </bean> - +--> <bean id="nexmlService" class = "org.cipres.treebase.service.nexus.NexusServiceNexml"> <!-- property name="domainHome" ref="domainHome"/ --> <property name="taxonLabelHome" ref="taxonLabelHome"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |