aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge/jnlp/cache
diff options
context:
space:
mode:
authorOmair Majid <[email protected]>2010-11-03 11:33:41 -0400
committerOmair Majid <[email protected]>2010-11-03 11:33:41 -0400
commit906dabe74dac87a2495fdede424a40035bfaba66 (patch)
tree4643ac6261493fe8aa33d0a2873835689ec5d9c3 /netx/net/sourceforge/jnlp/cache
parent5fc98068846ee4772b93d49a44b0f13b37f0baf1 (diff)
use deployment.properties file for infrastructure related configuration
2010-11-03 Omair Majid <[email protected]> * netx/net/sourceforge/jnlp/Launcher.java (markNetxRunning): Get file name from configuration. (markNetxStopped): Likewise. * netx/net/sourceforge/jnlp/cache/CacheUtil.java (clearCache): Get cache directory from configuration. (okToClearCache): Get netx_running file from configuration. (getCacheFile): Get cache directory from configuration. (urlToPath): Change semantics to take in the full path of the directory instead of a directory under runtime. * netx/net/sourceforge/jnlp/runtime/DeploymentConfiguration.java: Change DEPLOYMENT_DIR to ".icedtea". Add constants KEY_USER_CACHE_DIR, KEY_USER_PERSISTENCE_CACHE_DIR, KEY_SYSTEM_CACHE_DIR, KEY_USER_LOG_DIR, KEY_USER_TMP_DIR, KEY_USER_LOCKS_DIR, and KEY_USER_NETX_RUNNING_FILE. (load): Use DEPLOYMENT_DIR instead of hardcoded string. (loadDefaultProperties): Add LOCKS_DIR. Replace strings with constants. Add new default values for persistence cache directory, single instance locks directory and the netx_running file. * netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java: Remove unneeded TMP_DIR, LOCKS_DIR and NETX_RUNNING_FILE * netx/net/sourceforge/jnlp/services/SingleInstanceLock.java (getLockFile): Get locks directory from configuration. * netx/net/sourceforge/jnlp/services/XPersistenceService.java (toCacheFile): Get persistence cache directory from configuration. * netx/net/sourceforge/jnlp/util/XDesktopEntry.java (getContentsAsReader): Get cache directory from configuration. (installDesktopLauncher): Get temporary directory from configuration. Make parent directories if required. * plugin/icedteanp/java/sun/applet/JavaConsole.java (initialize): Get log directory from configuration and create the error and output files under it. * plugin/icedteanp/java/sun/applet/PluginMain.java: PLUGIN_STDERR_FILE and PLUGIN_STDOUT_FILE are now just filesnames. (PluginMain): Use configuration for finding the log directory. Initialize JNLPRuntime before creating the stderr and stdout logs.
Diffstat (limited to 'netx/net/sourceforge/jnlp/cache')
-rw-r--r--netx/net/sourceforge/jnlp/cache/CacheUtil.java32
1 files changed, 20 insertions, 12 deletions
diff --git a/netx/net/sourceforge/jnlp/cache/CacheUtil.java b/netx/net/sourceforge/jnlp/cache/CacheUtil.java
index 3edc31e..ad90977 100644
--- a/netx/net/sourceforge/jnlp/cache/CacheUtil.java
+++ b/netx/net/sourceforge/jnlp/cache/CacheUtil.java
@@ -141,7 +141,8 @@ public class CacheUtil {
return;
}
- File cacheDir = new File(JNLPRuntime.getBaseDir() + File.separator + "cache");
+ File cacheDir = new File(JNLPRuntime.getConfiguration()
+ .getProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR));
if (!(cacheDir.isDirectory())) {
return;
}
@@ -150,7 +151,8 @@ public class CacheUtil {
System.err.println("Clearing cache directory: " + cacheDir);
}
try {
- FileUtils.recursiveDelete(cacheDir, JNLPRuntime.getBaseDir());
+ cacheDir = cacheDir.getCanonicalFile();
+ FileUtils.recursiveDelete(cacheDir, cacheDir);
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -161,7 +163,8 @@ public class CacheUtil {
* @return true if the cache can be cleared at this time without problems
*/
private static boolean okToClearCache() {
- File otherJavawsRunning = new File(JNLPRuntime.NETX_RUNNING_FILE);
+ File otherJavawsRunning = new File(JNLPRuntime.getConfiguration()
+ .getProperty(DeploymentConfiguration.KEY_USER_NETX_RUNNING_FILE));
try {
if (otherJavawsRunning.isFile()) {
FileOutputStream fis = new FileOutputStream(otherJavawsRunning);
@@ -289,7 +292,9 @@ public class CacheUtil {
throw new IllegalArgumentException(R("CNotCacheable", source));
try {
- File localFile = urlToPath(source, "cache");
+ String cacheDir = JNLPRuntime.getConfiguration()
+ .getProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR);
+ File localFile = urlToPath(source, cacheDir);
localFile.getParentFile().mkdirs();
return localFile;
@@ -345,20 +350,23 @@ public class CacheUtil {
}
/**
- * Converts a URL into a local path string within the runtime's
- * base directory.
+ * Converts a URL into a local path string within the given directory. For
+ * example a url with subdirectory /tmp/ will
+ * result in a File that is located somewhere within /tmp/
*
* @param location the url
- * @param subdir subdirectory under the base directory
+ * @param subdir the subdirectory
* @return the file
*/
public static File urlToPath(URL location, String subdir) {
+ if (subdir == null) {
+ throw new NullPointerException();
+ }
+
StringBuffer path = new StringBuffer();
- if (subdir != null) {
- path.append(subdir);
- path.append(File.separatorChar);
- }
+ path.append(subdir);
+ path.append(File.separatorChar);
path.append(location.getProtocol());
path.append(File.separatorChar);
@@ -366,7 +374,7 @@ public class CacheUtil {
path.append(File.separatorChar);
path.append(location.getPath().replace('/', File.separatorChar));
- return new File(JNLPRuntime.getBaseDir(), FileUtils.sanitizePath(path.toString()));
+ return new File(FileUtils.sanitizePath(path.toString()));
}