aboutsummaryrefslogtreecommitdiffstats
path: root/netx
diff options
context:
space:
mode:
authorJiri Vanek <[email protected]>2013-12-18 15:41:28 +0100
committerJiri Vanek <[email protected]>2013-12-18 15:41:28 +0100
commitc3b3c491051c08e035593a25850e537168bb1db9 (patch)
tree589d008ee200fd0c7e73d4bdd29789324ad66c27 /netx
parentd91bf9ee53eebc7028f4143e03881ee350e4ebef (diff)
JNLPRuntime.config changed to proper singleton.
Diffstat (limited to 'netx')
-rw-r--r--netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java10
-rw-r--r--netx/net/sourceforge/jnlp/resources/Messages.properties2
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java40
-rw-r--r--netx/net/sourceforge/jnlp/util/logging/LogConfig.java20
4 files changed, 35 insertions, 37 deletions
diff --git a/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java b/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java
index a4adfd0..1412296 100644
--- a/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java
+++ b/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java
@@ -206,6 +206,16 @@ public final class DeploymentConfiguration {
*/
public static final String KEY_PLUGIN_JVM_ARGUMENTS= "deployment.plugin.jvm.arguments";
public static final String KEY_JRE_DIR= "deployment.jre.dir";
+ private ConfigurationException loadingException = null;
+
+ public void setLoadingException(ConfigurationException ex) {
+ loadingException = ex;
+ }
+
+ public ConfigurationException getLoadingException() {
+ return loadingException;
+ }
+
public enum ConfigType {
System, User
diff --git a/netx/net/sourceforge/jnlp/resources/Messages.properties b/netx/net/sourceforge/jnlp/resources/Messages.properties
index cd6fd74..be28762 100644
--- a/netx/net/sourceforge/jnlp/resources/Messages.properties
+++ b/netx/net/sourceforge/jnlp/resources/Messages.properties
@@ -172,7 +172,7 @@ RExitNoApp=Can not exit the JVM because the current application cannot be determ
RNoLockDir=Unable to create locks directory ({0})
RNestedJarExtration=Unable to extract nested jar.
RUnexpected=Unexpected {0} at {1}
-RConfigurationError=Fatal error while reading the configuration
+RConfigurationError=Fatal error while reading the configuration, continuing with empty. Please fix
RConfigurationFatal=ERROR: a fatal error has occurred while loading configuration. Perhaps a global configuration was required but could not be found
RPRoxyPacNotSupported=Using Proxy Auto Config (PAC) files is not supported.
RProxyFirefoxNotFound=Unable to use Firefox's proxy settings. Using "DIRECT" as proxy type.
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
index 866c7b1..3ec3f91 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
@@ -90,7 +90,7 @@ public class JNLPRuntime {
/** the localized resource strings */
private static ResourceBundle resources;
- private static final DeploymentConfiguration config = new DeploymentConfiguration();
+ private static DeploymentConfiguration config;
/** the security manager */
private static JNLPSecurityManager security;
@@ -185,21 +185,14 @@ public class JNLPRuntime {
public static void initialize(boolean isApplication) throws IllegalStateException {
checkInitialized();
- try {
- config.load();
- config.copyTo(System.getProperties());
- if (JavaConsole.canShowOnStartup(isApplication)) {
- JavaConsole.getConsole().showConsoleLater();
- }
- } catch (ConfigurationException e) {
- /* exit if there is a fatal exception loading the configuration */
- if (isApplication) {
- OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, getMessage("RConfigurationError"));
- JNLPRuntime.exit(1);
- }
+ if (JavaConsole.canShowOnStartup(isApplication)) {
+ JavaConsole.getConsole().showConsoleLater();
}
-
- KeyStores.setConfiguration(config);
+ /* exit if there is a fatal exception loading the configuration */
+ if (isApplication && getConfiguration().getLoadingException() != null) {
+ OutputController.getLogger().log(OutputController.Level.WARNING_ALL, getMessage("RConfigurationError")+": "+getConfiguration().getLoadingException().getMessage());
+ }
+ KeyStores.setConfiguration(getConfiguration());
isWebstartApplication = isApplication;
@@ -261,7 +254,7 @@ public class JNLPRuntime {
// plug in a custom authenticator and proxy selector
Authenticator.setDefault(new JNLPAuthenticator());
- BrowserAwareProxySelector proxySelector = new BrowserAwareProxySelector(config);
+ BrowserAwareProxySelector proxySelector = new BrowserAwareProxySelector(getConfiguration());
proxySelector.initialize();
ProxySelector.setDefault(proxySelector);
@@ -362,7 +355,20 @@ public class JNLPRuntime {
* @return a {@link DeploymentConfiguration} object that can be queried to
* find relevant configuration settings
*/
- public static DeploymentConfiguration getConfiguration() {
+ public synchronized static DeploymentConfiguration getConfiguration() {
+ if (config == null){
+ config = new DeploymentConfiguration();
+ try{
+ config.load();
+ config.copyTo(System.getProperties());
+ }catch(ConfigurationException ex){
+ OutputController.getLogger().log(ex);
+ //mark first occurence of exception so we can react later
+ if (config.getLoadingException() == null){
+ config.setLoadingException(ex);
+ }
+ }
+ }
return config;
}
diff --git a/netx/net/sourceforge/jnlp/util/logging/LogConfig.java b/netx/net/sourceforge/jnlp/util/logging/LogConfig.java
index 72941f3..c02043c 100644
--- a/netx/net/sourceforge/jnlp/util/logging/LogConfig.java
+++ b/netx/net/sourceforge/jnlp/util/logging/LogConfig.java
@@ -55,19 +55,11 @@ public class LogConfig {
private boolean logToFile;
private boolean logToStreams;
private boolean logToSysLog;
- private DeploymentConfiguration config;
private static LogConfig logConfig;
public LogConfig() {
- try {
- config = JNLPRuntime.getConfiguration();
- if (config.getRaw().isEmpty()){
- config = new DeploymentConfiguration();//JNLPRuntime.getConfiguration() cannotbe loaded time
- config.load(); //read one prior
- //todo fix JNLPRuntime.getConfiguration(); to be correct singleton - not easy task!
- }
-
+ DeploymentConfiguration config = JNLPRuntime.getConfiguration();
// Check whether logging and tracing is enabled.
enableLogging = Boolean.parseBoolean(config.getProperty(DeploymentConfiguration.KEY_ENABLE_LOGGING));
//enagle disable headers
@@ -87,9 +79,6 @@ public class LogConfig {
enableLogging = false;
}
}
- } catch (ConfigurationException e) {
- throw new RuntimeException(e);
- }
}
public static LogConfig getLogConfig() {
@@ -162,11 +151,4 @@ public class LogConfig {
return JavaConsole.isEnabled();
}
- /*
- * logging stuff may be interested in used config
- */
- public DeploymentConfiguration getConfig() {
- return config;
- }
-
}