aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net
diff options
context:
space:
mode:
Diffstat (limited to 'netx/net')
-rw-r--r--netx/net/sourceforge/jnlp/Launcher.java10
-rw-r--r--netx/net/sourceforge/jnlp/cache/CacheUtil.java32
-rw-r--r--netx/net/sourceforge/jnlp/runtime/DeploymentConfiguration.java36
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java19
-rw-r--r--netx/net/sourceforge/jnlp/services/SingleInstanceLock.java4
-rw-r--r--netx/net/sourceforge/jnlp/services/XPersistenceService.java4
-rw-r--r--netx/net/sourceforge/jnlp/util/XDesktopEntry.java13
7 files changed, 73 insertions, 45 deletions
diff --git a/netx/net/sourceforge/jnlp/Launcher.java b/netx/net/sourceforge/jnlp/Launcher.java
index db562a0..a69400c 100644
--- a/netx/net/sourceforge/jnlp/Launcher.java
+++ b/netx/net/sourceforge/jnlp/Launcher.java
@@ -43,6 +43,7 @@ import net.sourceforge.jnlp.cache.UpdatePolicy;
import net.sourceforge.jnlp.runtime.AppThreadGroup;
import net.sourceforge.jnlp.runtime.AppletInstance;
import net.sourceforge.jnlp.runtime.ApplicationInstance;
+import net.sourceforge.jnlp.runtime.DeploymentConfiguration;
import net.sourceforge.jnlp.runtime.JNLPClassLoader;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
import net.sourceforge.jnlp.services.InstanceExistsException;
@@ -724,7 +725,8 @@ public class Launcher {
try {
String message = "This file is used to check if netx is running";
- File netxRunningFile = new File(JNLPRuntime.NETX_RUNNING_FILE);
+ File netxRunningFile = new File(JNLPRuntime.getConfiguration()
+ .getProperty(DeploymentConfiguration.KEY_USER_NETX_RUNNING_FILE));
netxRunningFile.getParentFile().mkdirs();
if (netxRunningFile.createNewFile()) {
FileOutputStream fos = new FileOutputStream(netxRunningFile);
@@ -749,7 +751,7 @@ public class Launcher {
if (fileLock != null && fileLock.isShared()) {
if (JNLPRuntime.isDebug()) {
System.out.println("Acquired shared lock on " +
- JNLPRuntime.NETX_RUNNING_FILE + " to indicate javaws is running");
+ netxRunningFile.toString() + " to indicate javaws is running");
}
} else {
fileLock = null;
@@ -773,7 +775,9 @@ public class Launcher {
fileLock.channel().close();
fileLock = null;
if (JNLPRuntime.isDebug()) {
- System.out.println("Release shared lock on " + JNLPRuntime.NETX_RUNNING_FILE);
+ String file = JNLPRuntime.getConfiguration()
+ .getProperty(DeploymentConfiguration.KEY_USER_NETX_RUNNING_FILE);
+ System.out.println("Release shared lock on " + file);
}
} catch (IOException e) {
e.printStackTrace();
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()));
}
diff --git a/netx/net/sourceforge/jnlp/runtime/DeploymentConfiguration.java b/netx/net/sourceforge/jnlp/runtime/DeploymentConfiguration.java
index bc4ea7b..2ad3619 100644
--- a/netx/net/sourceforge/jnlp/runtime/DeploymentConfiguration.java
+++ b/netx/net/sourceforge/jnlp/runtime/DeploymentConfiguration.java
@@ -28,6 +28,7 @@ import java.io.PrintStream;
import java.io.Reader;
import java.net.MalformedURLException;
import java.net.URL;
+import java.nio.channels.FileLock;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
@@ -98,7 +99,7 @@ public final class DeploymentConfiguration {
}
}
- public static final String DEPLOYMENT_DIR = ".netx";
+ public static final String DEPLOYMENT_DIR = ".icedtea";
public static final String DEPLOYMENT_CONFIG = "deployment.config";
public static final String DEPLOYMENT_PROPERTIES = "deployment.properties";
@@ -125,6 +126,22 @@ public final class DeploymentConfiguration {
public static final int PROXY_TYPE_AUTO = 2;
public static final int PROXY_TYPE_BROWSER = 3;
+ public static final String KEY_USER_CACHE_DIR = "deployment.user.cachedir";
+ public static final String KEY_USER_PERSISTENCE_CACHE_DIR = "deployment.user.pcachedir";
+ public static final String KEY_SYSTEM_CACHE_DIR = "deployment.system.cachedir";
+ public static final String KEY_USER_LOG_DIR = "deployment.user.logdir";
+ public static final String KEY_USER_TMP_DIR = "deployment.user.tmp";
+ /** the directory containing locks for single instance applications */
+ public static final String KEY_USER_LOCKS_DIR = "deployment.user.locksdir";
+ /**
+ * The netx_running file is used to indicate if any instances of netx are
+ * running (this file may exist even if no instances are running). All netx
+ * instances acquire a shared lock on this file. If this file can be locked
+ * (using a {@link FileLock}) in exclusive mode, then other netx instances
+ * are not running
+ */
+ public static final String KEY_USER_NETX_RUNNING_FILE = "deployment.user.runningfile";
+
public enum ConfigType {
System, User
}
@@ -156,7 +173,7 @@ public final class DeploymentConfiguration {
*/
public void load() throws ConfigurationException {
// make sure no state leaks if security check fails later on
- File userFile = new File(System.getProperty("user.home") + File.separator + ".netx"
+ File userFile = new File(System.getProperty("user.home") + File.separator + DEPLOYMENT_DIR
+ File.separator + DEPLOYMENT_PROPERTIES);
SecurityManager sm = System.getSecurityManager();
@@ -277,6 +294,10 @@ public final class DeploymentConfiguration {
final String USER_HOME = System.getProperty("user.home") + File.separator + DEPLOYMENT_DIR;
final String USER_SECURITY = USER_HOME + File.separator + "security";
+ final String LOCKS_DIR = System.getProperty("java.io.tmpdir") + File.separator
+ + System.getProperty("user.name") + File.separator + "netx" + File.separator
+ + "locks";
+
/*
* This is more or less a straight copy from the deployment
* configuration page, with occasional replacements of "" or no-defaults
@@ -285,10 +306,13 @@ public final class DeploymentConfiguration {
String[][] defaults = new String[][] {
/* infrastructure */
- { "deployment.user.cachedir", USER_HOME + File.separator + "cache" },
- { "deployment.system.cachedir", null },
- { "deployment.user.logdir", USER_HOME + File.separator + "log" },
- { "deployment.user.tmp", USER_HOME + File.separator + "tmp" },
+ { KEY_USER_CACHE_DIR, USER_HOME + File.separator + "cache" },
+ { KEY_USER_PERSISTENCE_CACHE_DIR, USER_HOME + File.separator + "pcache" },
+ { KEY_SYSTEM_CACHE_DIR, null },
+ { KEY_USER_LOG_DIR, USER_HOME + File.separator + "log" },
+ { KEY_USER_TMP_DIR, USER_HOME + File.separator + "tmp" },
+ { KEY_USER_LOCKS_DIR, LOCKS_DIR },
+ { KEY_USER_NETX_RUNNING_FILE, LOCKS_DIR + File.separator + "netx_running" },
/* certificates and policy files */
{ "deployment.user.security.policy", "file://" + USER_SECURITY + File.separator + "java.policy" },
{ "deployment.user.security.trusted.cacerts", USER_SECURITY + File.separator + "trusted.cacerts" },
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
index c993833..4b1e4d3 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
@@ -132,25 +132,6 @@ public class JNLPRuntime {
/** the ~/.netx/security/trusted.certs file containing trusted certificates */
public static final String CERTIFICATES_FILE = SECURITY_DIR + File.separator + "trusted.certs";
- /** the /tmp/ directory used for temporary files */
- public static final String TMP_DIR = System.getProperty("java.io.tmpdir");
-
- /**
- * the /tmp/$USER/netx/locks/ directory containing locks for single instance
- * applications
- */
- public static final String LOCKS_DIR = TMP_DIR + File.separator + USER + File.separator
- + "netx" + File.separator + "locks";
-
- /**
- * The /tmp/$USER/netx/locks/netx_running file is used to indicate if any
- * instances of netx are running (this file may exist even if no instances
- * are running). All netx instances acquire a shared lock on this file. If
- * this file can be locked (using a {@link FileLock}) in exclusive mode, then
- * other netx instances are not running
- */
- public static final String NETX_RUNNING_FILE = LOCKS_DIR + File.separator + "netx_running";
-
/** the java.home directory */
public static final String JAVA_HOME_DIR = System.getProperty("java.home");
diff --git a/netx/net/sourceforge/jnlp/services/SingleInstanceLock.java b/netx/net/sourceforge/jnlp/services/SingleInstanceLock.java
index 811b80d..3e6b3d6 100644
--- a/netx/net/sourceforge/jnlp/services/SingleInstanceLock.java
+++ b/netx/net/sourceforge/jnlp/services/SingleInstanceLock.java
@@ -28,6 +28,7 @@ import java.net.BindException;
import java.net.ServerSocket;
import net.sourceforge.jnlp.JNLPFile;
+import net.sourceforge.jnlp.runtime.DeploymentConfiguration;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
import net.sourceforge.jnlp.util.FileUtils;
@@ -128,7 +129,8 @@ class SingleInstanceLock {
* may or may not exist.
*/
private File getLockFile() {
- File baseDir = new File(JNLPRuntime.LOCKS_DIR);
+ File baseDir = new File(JNLPRuntime.getConfiguration()
+ .getProperty(DeploymentConfiguration.KEY_USER_LOCKS_DIR));
if (!baseDir.isDirectory() && !baseDir.mkdirs()) {
throw new RuntimeException(R("RNoLockDir", baseDir));
diff --git a/netx/net/sourceforge/jnlp/services/XPersistenceService.java b/netx/net/sourceforge/jnlp/services/XPersistenceService.java
index d8f47ab..bbef251 100644
--- a/netx/net/sourceforge/jnlp/services/XPersistenceService.java
+++ b/netx/net/sourceforge/jnlp/services/XPersistenceService.java
@@ -80,7 +80,9 @@ class XPersistenceService implements PersistenceService {
* @return the file
*/
protected File toCacheFile(URL location) throws MalformedURLException {
- return CacheUtil.urlToPath(location, "pcache");
+ String pcache = JNLPRuntime.getConfiguration()
+ .getProperty(DeploymentConfiguration.KEY_USER_PERSISTENCE_CACHE_DIR);
+ return CacheUtil.urlToPath(location, pcache);
}
/**
diff --git a/netx/net/sourceforge/jnlp/util/XDesktopEntry.java b/netx/net/sourceforge/jnlp/util/XDesktopEntry.java
index 8527fed..5bed221 100644
--- a/netx/net/sourceforge/jnlp/util/XDesktopEntry.java
+++ b/netx/net/sourceforge/jnlp/util/XDesktopEntry.java
@@ -32,6 +32,7 @@ import net.sourceforge.jnlp.JNLPFile;
import net.sourceforge.jnlp.StreamEater;
import net.sourceforge.jnlp.cache.CacheUtil;
import net.sourceforge.jnlp.cache.UpdatePolicy;
+import net.sourceforge.jnlp.runtime.DeploymentConfiguration;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
/**
@@ -73,7 +74,9 @@ public class XDesktopEntry {
String pathToJavaws = System.getProperty("java.home") + File.separator + "bin"
+ File.separator + "javaws";
- File cacheFile = CacheUtil.urlToPath(file.getSourceLocation(), "cache");
+ String cacheDir = JNLPRuntime.getConfiguration()
+ .getProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR);
+ File cacheFile = CacheUtil.urlToPath(file.getSourceLocation(), cacheDir);
String fileContents = "[Desktop Entry]\n";
fileContents += "Version=1.0\n";
@@ -131,10 +134,14 @@ public class XDesktopEntry {
* Install this XDesktopEntry into the user's desktop as a launcher
*/
private void installDesktopLauncher() {
- File shortcutFile = new File(JNLPRuntime.TMP_DIR + File.separator
- + FileUtils.sanitizeFileName(file.getTitle()) + ".desktop");
+ File shortcutFile = new File(JNLPRuntime.getConfiguration()
+ .getProperty(DeploymentConfiguration.KEY_USER_TMP_DIR)
+ + File.separator + FileUtils.sanitizeFileName(file.getTitle()) + ".desktop");
try {
+ if (!shortcutFile.getParentFile().isDirectory() && !shortcutFile.getParentFile().mkdirs()) {
+ throw new IOException(shortcutFile.getParentFile().toString());
+ }
/*
* Write out a Java String (UTF-16) as a UTF-8 file
*/