Omaha #3356 fix apps_dir setting detection in viz/cave

Change-Id: If78a4ec84f6237450a6494c06b5a5271c66f10a3

Former-commit-id: e163ae0e5b [formerly e163ae0e5b [formerly ca8195c7835b9d96158d048fdd548cc744ba96bc]]
Former-commit-id: e637963736
Former-commit-id: 9c316ec38c
This commit is contained in:
Nate Jensen 2014-09-22 13:00:04 -05:00
parent 8ea5d99bf4
commit 6ff3a4435d
2 changed files with 38 additions and 3 deletions

View file

@ -0,0 +1,15 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<!-- this needs to be injected so AppsDefaults can properly initialize the apps_dir property in viz -->
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetClass" value="com.raytheon.uf.common.ohd.AppsDefaults" />
<property name="targetMethod" value="setDataDirClass" />
<property name="arguments">
<value type="java.lang.Class">com.raytheon.uf.viz.core.VizApp</value>
</property>
</bean>
</beans>

View file

@ -66,6 +66,8 @@ import com.raytheon.uf.common.util.FileUtil;
* Sep 22, 2008 randerso Initial creation
* Apr 1, 2009 jelkins added getTokens
* Oct 19, 2012 bgonzale App Context variable setup and token access.
* Sep 22, 2014 3356 njensen Fix constructor usage in viz finding VizApp class
*
* </pre>
*
* @author randerso
@ -95,6 +97,8 @@ public class AppsDefaults {
private static AppsDefaults instance;
private static Class<?> dataDirClass;
private final Properties _envProperties;
private LocalizationFile _appsDefaultsUserFile;
@ -130,11 +134,16 @@ public class AppsDefaults {
_envProperties = new Properties();
_envProperties.putAll(System.getenv());
/*
* TODO this is nearly unmaintainable, figure out a better way to do it
* that works in both CAVE and EDEX, perhaps through a combination of a
* properties file and Spring. It's not even clear if apps_dir should be
* coming from the data dir in CAVE or somewhere else, and it's not
* clear how much it's used in CAVE.
*/
if (_envProperties.get("EDEX_HOME") == null) {
try {
Class<?> vizapp = Class
.forName("com.raytheon.uf.viz.core.VizApp");
Method getDataDir = vizapp.getMethod("getDataDir");
Method getDataDir = dataDirClass.getMethod("getDataDir");
String shareDir = (String) getDataDir.invoke(null);
_envProperties.put("apps_dir",
FileUtil.join(shareDir, "hydroapps"));
@ -990,4 +999,15 @@ public class AppsDefaults {
}
}
/**
* Sets the class used to determine the data dir, if necessary. See
* AppsDefaults's private constructor. At present only intended for use by
* CAVE since edex receives a corresponding environment variable.
*
* @param dataDirClass
*/
public static void setDataDirClass(Class<?> dataDirClass) {
AppsDefaults.dataDirClass = dataDirClass;
}
} // end class AppsDefaults