diff options
author | Omair Majid <[email protected]> | 2010-11-03 11:33:41 -0400 |
---|---|---|
committer | Omair Majid <[email protected]> | 2010-11-03 11:33:41 -0400 |
commit | 906dabe74dac87a2495fdede424a40035bfaba66 (patch) | |
tree | 4643ac6261493fe8aa33d0a2873835689ec5d9c3 /netx/net/sourceforge/jnlp/runtime | |
parent | 5fc98068846ee4772b93d49a44b0f13b37f0baf1 (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/runtime')
-rw-r--r-- | netx/net/sourceforge/jnlp/runtime/DeploymentConfiguration.java | 36 | ||||
-rw-r--r-- | netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java | 19 |
2 files changed, 30 insertions, 25 deletions
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"); |