aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net
diff options
context:
space:
mode:
Diffstat (limited to 'netx/net')
-rw-r--r--netx/net/sourceforge/jnlp/AbstractLaunchHandler.java16
-rw-r--r--netx/net/sourceforge/jnlp/AppletLog.java92
-rw-r--r--netx/net/sourceforge/jnlp/DefaultLaunchHandler.java4
-rw-r--r--netx/net/sourceforge/jnlp/ExtensionDesc.java4
-rw-r--r--netx/net/sourceforge/jnlp/GuiLaunchHandler.java8
-rw-r--r--netx/net/sourceforge/jnlp/JNLPFile.java11
-rw-r--r--netx/net/sourceforge/jnlp/JNLPMatcher.java5
-rw-r--r--netx/net/sourceforge/jnlp/JNLPSplashScreen.java13
-rw-r--r--netx/net/sourceforge/jnlp/Launcher.java31
-rw-r--r--netx/net/sourceforge/jnlp/Log.java79
-rw-r--r--netx/net/sourceforge/jnlp/MalformedXMLParser.java5
-rw-r--r--netx/net/sourceforge/jnlp/NetxPanel.java11
-rw-r--r--netx/net/sourceforge/jnlp/Parser.java17
-rw-r--r--netx/net/sourceforge/jnlp/PluginBridge.java9
-rw-r--r--netx/net/sourceforge/jnlp/SecurityDesc.java3
-rw-r--r--netx/net/sourceforge/jnlp/StreamEater.java17
-rw-r--r--netx/net/sourceforge/jnlp/XmlParser.java3
-rw-r--r--netx/net/sourceforge/jnlp/about/HTMLPanel.java3
-rw-r--r--netx/net/sourceforge/jnlp/browser/BrowserAwareProxySelector.java19
-rw-r--r--netx/net/sourceforge/jnlp/browser/FirefoxPreferencesFinder.java10
-rw-r--r--netx/net/sourceforge/jnlp/browser/FirefoxPreferencesParser.java7
-rw-r--r--netx/net/sourceforge/jnlp/cache/CacheDirectory.java6
-rw-r--r--netx/net/sourceforge/jnlp/cache/CacheEntry.java7
-rw-r--r--netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java15
-rw-r--r--netx/net/sourceforge/jnlp/cache/CacheUtil.java44
-rw-r--r--netx/net/sourceforge/jnlp/cache/NativeLibraryStorage.java12
-rw-r--r--netx/net/sourceforge/jnlp/cache/Resource.java18
-rw-r--r--netx/net/sourceforge/jnlp/cache/ResourceTracker.java55
-rw-r--r--netx/net/sourceforge/jnlp/config/Defaults.java20
-rw-r--r--netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java135
-rw-r--r--netx/net/sourceforge/jnlp/controlpanel/CachePane.java5
-rw-r--r--netx/net/sourceforge/jnlp/controlpanel/CommandLine.java90
-rw-r--r--netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java9
-rw-r--r--netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java84
-rw-r--r--netx/net/sourceforge/jnlp/controlpanel/DocumentAdapter.java4
-rw-r--r--netx/net/sourceforge/jnlp/controlpanel/JVMPanel.java7
-rw-r--r--netx/net/sourceforge/jnlp/controlpanel/UnsignedAppletsTrustingListPanel.java15
-rw-r--r--netx/net/sourceforge/jnlp/resources/Messages.properties11
-rw-r--r--netx/net/sourceforge/jnlp/resources/Messages_cs.properties1
-rw-r--r--netx/net/sourceforge/jnlp/resources/Messages_de.properties1
-rw-r--r--netx/net/sourceforge/jnlp/resources/Messages_pl.properties1
-rw-r--r--netx/net/sourceforge/jnlp/runtime/AppletAudioClip.java4
-rw-r--r--netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java11
-rw-r--r--netx/net/sourceforge/jnlp/runtime/AppletInstance.java9
-rw-r--r--netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java23
-rw-r--r--netx/net/sourceforge/jnlp/runtime/Boot.java46
-rw-r--r--netx/net/sourceforge/jnlp/runtime/CachedJarFileCallback.java6
-rw-r--r--netx/net/sourceforge/jnlp/runtime/FakePacEvaluator.java5
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java121
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPPolicy.java7
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPProxySelector.java27
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java120
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java22
-rw-r--r--netx/net/sourceforge/jnlp/runtime/PacEvaluatorFactory.java19
-rw-r--r--netx/net/sourceforge/jnlp/runtime/RhinoBasedPacEvaluator.java17
-rw-r--r--netx/net/sourceforge/jnlp/security/CertWarningPane.java7
-rw-r--r--netx/net/sourceforge/jnlp/security/CertificateUtils.java18
-rw-r--r--netx/net/sourceforge/jnlp/security/HttpsCertVerifier.java7
-rw-r--r--netx/net/sourceforge/jnlp/security/KeyStores.java3
-rw-r--r--netx/net/sourceforge/jnlp/security/SecurityDialog.java11
-rw-r--r--netx/net/sourceforge/jnlp/security/SecurityDialogMessageHandler.java7
-rw-r--r--netx/net/sourceforge/jnlp/security/SecurityUtil.java3
-rw-r--r--netx/net/sourceforge/jnlp/security/VariableX509TrustManager.java9
-rw-r--r--netx/net/sourceforge/jnlp/security/appletextendedsecurity/ExtendedAppletSecurityHelp.java3
-rw-r--r--netx/net/sourceforge/jnlp/security/appletextendedsecurity/UnsignedAppletTrustConfirmation.java16
-rw-r--r--netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java13
-rw-r--r--netx/net/sourceforge/jnlp/services/ServiceUtil.java11
-rw-r--r--netx/net/sourceforge/jnlp/services/XBasicService.java16
-rw-r--r--netx/net/sourceforge/jnlp/services/XPersistenceService.java7
-rw-r--r--netx/net/sourceforge/jnlp/services/XPrintService.java9
-rw-r--r--netx/net/sourceforge/jnlp/services/XSingleInstanceService.java19
-rw-r--r--netx/net/sourceforge/jnlp/splashscreen/SplashUtils.java7
-rw-r--r--netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java7
-rw-r--r--netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/ErrorPainter.java3
-rw-r--r--netx/net/sourceforge/jnlp/splashscreen/parts/InformationElement.java3
-rw-r--r--netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java15
-rw-r--r--netx/net/sourceforge/jnlp/tools/CertInformation.java4
-rw-r--r--netx/net/sourceforge/jnlp/tools/JarCertVerifier.java23
-rw-r--r--netx/net/sourceforge/jnlp/util/BasicExceptionDialog.java11
-rw-r--r--netx/net/sourceforge/jnlp/util/FileUtils.java23
-rw-r--r--netx/net/sourceforge/jnlp/util/HttpUtils.java3
-rw-r--r--netx/net/sourceforge/jnlp/util/ImageResources.java3
-rw-r--r--netx/net/sourceforge/jnlp/util/PropertiesFile.java5
-rw-r--r--netx/net/sourceforge/jnlp/util/Reflect.java5
-rw-r--r--netx/net/sourceforge/jnlp/util/StreamUtils.java14
-rw-r--r--netx/net/sourceforge/jnlp/util/TimedHashMap.java9
-rw-r--r--netx/net/sourceforge/jnlp/util/UrlUtils.java13
-rw-r--r--netx/net/sourceforge/jnlp/util/XDesktopEntry.java19
-rw-r--r--netx/net/sourceforge/jnlp/util/logging/FileLog.java107
-rw-r--r--netx/net/sourceforge/jnlp/util/logging/LogConfig.java156
-rw-r--r--netx/net/sourceforge/jnlp/util/logging/OutputController.java398
-rw-r--r--netx/net/sourceforge/jnlp/util/logging/PrintStreamLogger.java68
-rw-r--r--netx/net/sourceforge/jnlp/util/logging/SingleStreamLogger.java46
-rw-r--r--netx/net/sourceforge/jnlp/util/logging/UnixSystemLog.java57
-rw-r--r--netx/net/sourceforge/jnlp/util/logging/WinSystemLog.java57
-rw-r--r--netx/net/sourceforge/nanoxml/XMLElement.java25
96 files changed, 1583 insertions, 1001 deletions
diff --git a/netx/net/sourceforge/jnlp/AbstractLaunchHandler.java b/netx/net/sourceforge/jnlp/AbstractLaunchHandler.java
index c9d5d70..aeff92e 100644
--- a/netx/net/sourceforge/jnlp/AbstractLaunchHandler.java
+++ b/netx/net/sourceforge/jnlp/AbstractLaunchHandler.java
@@ -37,16 +37,15 @@ exception statement from your version. */
package net.sourceforge.jnlp;
-import java.io.PrintStream;
-import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import net.sourceforge.jnlp.util.logging.OutputController;
public abstract class AbstractLaunchHandler implements LaunchHandler {
- protected final PrintStream outputStream;
+ protected final OutputController logger;
- public AbstractLaunchHandler(PrintStream outputStream) {
- this.outputStream = outputStream;
+ public AbstractLaunchHandler(OutputController logger) {
+ this.logger = logger;
}
/**
@@ -63,11 +62,10 @@ public abstract class AbstractLaunchHandler implements LaunchHandler {
if (ex.getCause() != null) {
result.append(recursiveDescription(ex.getCause()));
}
- outputStream.println(result);
+ logger.log(OutputController.Level.MESSAGE_ALL, result.toString());
- if (JNLPRuntime.isDebug()) {
- ex.printStackTrace(outputStream);
- }
+ logger.log(ex);
+
}
private String recursiveDescription(Throwable throwable) {
diff --git a/netx/net/sourceforge/jnlp/AppletLog.java b/netx/net/sourceforge/jnlp/AppletLog.java
deleted file mode 100644
index 3523da8..0000000
--- a/netx/net/sourceforge/jnlp/AppletLog.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/* AppletLog.java
- Copyright (C) 2011 Red Hat, Inc.
-
-This file is part of IcedTea.
-
-IcedTea is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-IcedTea is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with IcedTea; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package net.sourceforge.jnlp;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.PrintStream;
-import java.util.logging.FileHandler;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.logging.XMLFormatter;
-
-import net.sourceforge.jnlp.util.FileUtils;
-
-/**
- * This class writes log information to file.
- *
- * @author Andrew Su ([email protected], [email protected])
- *
- */
-class AppletLog extends Log {
- private static Logger logger;
- static {
- try {
- // If logging is enabled, we create logger.
- if (enableLogging) {
- String fn = icedteaLogDir + "plugin" + java.lang.System.currentTimeMillis() + ".log";
- FileUtils.createRestrictedFile(new File(fn), true);
- FileHandler fh = new FileHandler(fn, false);
- fh.setFormatter(new XMLFormatter());
- String logClassName = AppletLog.class.getName();
- logger = Logger.getLogger(logClassName);
- logger.setLevel(Level.ALL);
- logger.addHandler(fh);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private AppletLog() {
- }
-
- /**
- * Log the exception to file.
- *
- * @param e Exception that was thrown.
- */
- public synchronized static void log(Throwable e) {
- if (enableLogging && logger != null) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- e.printStackTrace(ps);
- logger.log(Level.FINE, baos.toString());
- }
- }
-}
diff --git a/netx/net/sourceforge/jnlp/DefaultLaunchHandler.java b/netx/net/sourceforge/jnlp/DefaultLaunchHandler.java
index 98e98de..b16f825 100644
--- a/netx/net/sourceforge/jnlp/DefaultLaunchHandler.java
+++ b/netx/net/sourceforge/jnlp/DefaultLaunchHandler.java
@@ -16,9 +16,9 @@
package net.sourceforge.jnlp;
-import java.io.PrintStream;
import net.sourceforge.jnlp.runtime.*;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* This default implementation shows prints the exception to
@@ -30,7 +30,7 @@ import net.sourceforge.jnlp.runtime.*;
*/
public class DefaultLaunchHandler extends AbstractLaunchHandler {
- public DefaultLaunchHandler(PrintStream out) {
+ public DefaultLaunchHandler(OutputController out) {
super(out);
}
diff --git a/netx/net/sourceforge/jnlp/ExtensionDesc.java b/netx/net/sourceforge/jnlp/ExtensionDesc.java
index 4e4283f..3d32c77 100644
--- a/netx/net/sourceforge/jnlp/ExtensionDesc.java
+++ b/netx/net/sourceforge/jnlp/ExtensionDesc.java
@@ -23,6 +23,7 @@ import java.net.*;
import java.util.*;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* The extension element.
@@ -122,8 +123,7 @@ public class ExtensionDesc {
if (file == null) {
file = new JNLPFile(location);
- if (JNLPRuntime.isDebug())
- System.out.println("Resolve: " + file.getInformation().getTitle());
+ OutputController.getLogger().log("Resolve: " + file.getInformation().getTitle());
// check for it being an extension descriptor
if (!file.isComponent() && !file.isInstaller())
diff --git a/netx/net/sourceforge/jnlp/GuiLaunchHandler.java b/netx/net/sourceforge/jnlp/GuiLaunchHandler.java
index 74960f0..5f1180b 100644
--- a/netx/net/sourceforge/jnlp/GuiLaunchHandler.java
+++ b/netx/net/sourceforge/jnlp/GuiLaunchHandler.java
@@ -37,7 +37,6 @@ exception statement from your version. */
package net.sourceforge.jnlp;
-import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
@@ -47,6 +46,7 @@ import net.sourceforge.jnlp.cache.ResourceTracker;
import net.sourceforge.jnlp.cache.UpdatePolicy;
import net.sourceforge.jnlp.runtime.ApplicationInstance;
import net.sourceforge.jnlp.util.BasicExceptionDialog;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* A {@link LaunchHandler} that gives feedback to the user using GUI elements
@@ -58,7 +58,7 @@ public class GuiLaunchHandler extends AbstractLaunchHandler {
private final Object mutex = new Object();
private UpdatePolicy policy = UpdatePolicy.ALWAYS;
- public GuiLaunchHandler(PrintStream outputStream) {
+ public GuiLaunchHandler(OutputController outputStream) {
super(outputStream);
}
@@ -127,7 +127,7 @@ public class GuiLaunchHandler extends AbstractLaunchHandler {
// Wait till splash screen is created
while (splashScreen == null);
} catch (InvocationTargetException ite) {
- ite.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ite);
}
try {
SwingUtilities.invokeAndWait(new Runnable() {
@@ -141,7 +141,7 @@ public class GuiLaunchHandler extends AbstractLaunchHandler {
// Wait till splash screen is created
while (!splashScreen.isSplashImageLoaded());
} catch (InvocationTargetException ite) {
- ite.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ite);
}
diff --git a/netx/net/sourceforge/jnlp/JNLPFile.java b/netx/net/sourceforge/jnlp/JNLPFile.java
index 3577482..9f38d4b 100644
--- a/netx/net/sourceforge/jnlp/JNLPFile.java
+++ b/netx/net/sourceforge/jnlp/JNLPFile.java
@@ -31,6 +31,7 @@ import java.util.Locale;
import net.sourceforge.jnlp.cache.ResourceTracker;
import net.sourceforge.jnlp.cache.UpdatePolicy;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* Provides methods to access the information in a Java Network
@@ -223,8 +224,7 @@ public class JNLPFile {
((int)(Math.random()*Integer.MAX_VALUE)) + "-" +
location;
- if (JNLPRuntime.isDebug())
- System.err.println("UNIQUEKEY=" + this.uniqueKey);
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "UNIQUEKEY=" + this.uniqueKey);
}
/**
@@ -243,8 +243,7 @@ public class JNLPFile {
this(location, version, settings, policy);
this.uniqueKey = uniqueKey;
- if (JNLPRuntime.isDebug())
- System.err.println("UNIQUEKEY (override) =" + this.uniqueKey);
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "UNIQUEKEY (override) =" + this.uniqueKey);
}
/**
@@ -714,9 +713,7 @@ public class JNLPFile {
} catch (ParseException ex) {
throw ex;
} catch (Exception ex) {
- if (JNLPRuntime.isDebug())
- ex.printStackTrace();
-
+ OutputController.getLogger().log(ex);
throw new RuntimeException(ex.toString());
}
}
diff --git a/netx/net/sourceforge/jnlp/JNLPMatcher.java b/netx/net/sourceforge/jnlp/JNLPMatcher.java
index 0f3a443..479cf7e 100644
--- a/netx/net/sourceforge/jnlp/JNLPMatcher.java
+++ b/netx/net/sourceforge/jnlp/JNLPMatcher.java
@@ -47,6 +47,7 @@ import java.io.StringReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
+import net.sourceforge.jnlp.util.logging.OutputController;
import net.sourceforge.nanoxml.XMLElement;
/**
@@ -261,7 +262,7 @@ public final class JNLPMatcher {
try {
stream.close();
} catch (Exception e) {
- e.printStackTrace(System.err);
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
}
@@ -276,7 +277,7 @@ public final class JNLPMatcher {
try {
stream.close();
} catch (Exception e) {
- e.printStackTrace(System.err);
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
}
}
diff --git a/netx/net/sourceforge/jnlp/JNLPSplashScreen.java b/netx/net/sourceforge/jnlp/JNLPSplashScreen.java
index 6a8a221..3bd8ba2 100644
--- a/netx/net/sourceforge/jnlp/JNLPSplashScreen.java
+++ b/netx/net/sourceforge/jnlp/JNLPSplashScreen.java
@@ -54,6 +54,7 @@ import net.sourceforge.jnlp.splashscreen.SplashPanel;
import net.sourceforge.jnlp.splashscreen.SplashUtils;
import net.sourceforge.jnlp.splashscreen.parts.InformationElement;
import net.sourceforge.jnlp.util.ImageResources;
+import net.sourceforge.jnlp.util.logging.OutputController;
import net.sourceforge.jnlp.util.ScreenFinder;
public class JNLPSplashScreen extends JDialog {
@@ -91,19 +92,13 @@ public class JNLPSplashScreen extends JDialog {
try {
splashImage = ImageIO.read(resourceTracker.getCacheFile(splashImageUrl));
if (splashImage == null) {
- if (JNLPRuntime.isDebug()) {
- System.err.println("Error loading splash image: " + url);
- }
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Error loading splash image: " + url);
}
} catch (IOException e) {
- if (JNLPRuntime.isDebug()) {
- System.err.println("Error loading splash image: " + url);
- }
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Error loading splash image: " + url);
splashImage = null;
} catch (IllegalArgumentException argumentException) {
- if (JNLPRuntime.isDebug()) {
- System.err.println("Error loading splash image: " + url);
- }
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Error loading splash image: " + url);
splashImage = null;
}
}
diff --git a/netx/net/sourceforge/jnlp/Launcher.java b/netx/net/sourceforge/jnlp/Launcher.java
index 8190945..fc4eefc 100644
--- a/netx/net/sourceforge/jnlp/Launcher.java
+++ b/netx/net/sourceforge/jnlp/Launcher.java
@@ -46,6 +46,7 @@ import javax.swing.SwingUtilities;
import javax.swing.text.html.parser.ParserDelegator;
import net.sourceforge.jnlp.runtime.AppletEnvironment;
import net.sourceforge.jnlp.splashscreen.SplashUtils;
+import net.sourceforge.jnlp.util.logging.OutputController;
import sun.awt.SunToolkit;
@@ -77,7 +78,7 @@ public class Launcher {
/** whether to create an AppContext (if possible) */
private boolean context = true;
- /** If the application should call System.exit on fatal errors */
+ /** If the application should call JNLPRuntime.exit on fatal errors */
private boolean exitOnFailure = true;
private ParserSettings parserSettings = new ParserSettings();
@@ -229,10 +230,10 @@ public class Launcher {
InetAddress.getByName(file.getSourceLocation().getHost());
} catch (UnknownHostException ue) {
- System.err.println("File cannot be launched because offline-allowed tag not specified and system currently offline.");
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "File cannot be launched because offline-allowed tag not specified and system currently offline.");
return null;
} catch (Exception e) {
- System.err.println(e);
+ OutputController.getLogger().log(e);
}
}
@@ -483,9 +484,7 @@ public class Launcher {
try {
ServiceUtil.checkExistingSingleInstance(file);
} catch (InstanceExistsException e) {
- if (JNLPRuntime.isDebug()) {
- System.out.println("Single instance application is already running.");
- }
+ OutputController.getLogger().log("Single instance application is already running.");
return null;
}
@@ -544,9 +543,7 @@ public class Launcher {
main.setAccessible(true);
- if (JNLPRuntime.isDebug()) {
- System.out.println("Invoking main() with args: " + Arrays.toString(args));
- }
+ OutputController.getLogger().log("Invoking main() with args: " + Arrays.toString(args));
main.invoke(null, new Object[] { args });
return app;
@@ -580,9 +577,7 @@ public class Launcher {
for (Thread thread : threads) {
if (thread != null) {
- if (JNLPRuntime.isDebug()) {
- System.err.println("Setting " + classLoader + " as the classloader for thread " + thread.getName());
- }
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Setting " + classLoader + " as the classloader for thread " + thread.getName());
thread.setContextClassLoader(classLoader);
}
}
@@ -629,9 +624,7 @@ public class Launcher {
applet.getAppletEnvironment().startApplet(); // this should be a direct call to applet instance
return applet;
} catch (InstanceExistsException ieex) {
- if (JNLPRuntime.isDebug()) {
- System.out.println("Single instance applet is already running.");
- }
+ OutputController.getLogger().log("Single instance applet is already running.");
throw launchError(new LaunchException(file, ieex, R("LSFatal"), R("LCLaunching"), R("LCouldNotLaunch"), R("LSingleInstanceExists")), applet);
} catch (LaunchException lex) {
throw launchError(lex, applet);
@@ -659,9 +652,7 @@ public class Launcher {
return applet;
} catch (InstanceExistsException ieex) {
- if (JNLPRuntime.isDebug()) {
- System.out.println("Single instance applet is already running.");
- }
+ OutputController.getLogger().log("Single instance applet is already running.");
throw launchError(new LaunchException(file, ieex, R("LSFatal"), R("LCLaunching"), R("LCouldNotLaunch"), R("LSingleInstanceExists")), applet);
} catch (LaunchException lex) {
throw launchError(lex, applet);
@@ -898,11 +889,11 @@ public class Launcher {
R("LNotLaunchableInfo")));
}
} catch (LaunchException ex) {
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
exception = ex;
// Exit if we can't launch the application.
if (exitOnFailure)
- System.exit(1);
+ JNLPRuntime.exit(1);
}
}
diff --git a/netx/net/sourceforge/jnlp/Log.java b/netx/net/sourceforge/jnlp/Log.java
deleted file mode 100644
index 93c287b..0000000
--- a/netx/net/sourceforge/jnlp/Log.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/* Log.java
- Copyright (C) 2011 Red Hat, Inc.
-
-This file is part of IcedTea.
-
-IcedTea is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License as published by
-the Free Software Foundation, version 2.
-
-IcedTea is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with IcedTea; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version.
- */
-
-package net.sourceforge.jnlp;
-
-import java.io.File;
-
-import net.sourceforge.jnlp.config.DeploymentConfiguration;
-import net.sourceforge.jnlp.runtime.JNLPRuntime;
-
-/**
- * This file provides the information required to do logging.
- *
- * @author Andrew Su ([email protected], [email protected])
- *
- */
-abstract class Log {
-
- // Directory where the logs are stored.
- protected static String icedteaLogDir;
-
- protected static boolean enableLogging = false;
- protected static boolean enableTracing = false;
-
- // Prepare for logging.
- static {
- DeploymentConfiguration config = JNLPRuntime.getConfiguration();
-
- // Check whether logging and tracing is enabled.
- enableLogging = Boolean.parseBoolean(config.getProperty(DeploymentConfiguration.KEY_ENABLE_LOGGING));
- enableTracing = Boolean.parseBoolean(config.getProperty(DeploymentConfiguration.KEY_ENABLE_TRACING));
-
- // Get log directory, create it if it doesn't exist. If unable to create and doesn't exist, don't log.
- icedteaLogDir = config.getProperty(DeploymentConfiguration.KEY_USER_LOG_DIR);
- if (icedteaLogDir != null) {
- File f = new File(icedteaLogDir);
- if (f.isDirectory() || f.mkdirs())
- icedteaLogDir += File.separator;
- else {
- enableLogging = false;
- enableTracing = false;
- }
- }
- }
-}
diff --git a/netx/net/sourceforge/jnlp/MalformedXMLParser.java b/netx/net/sourceforge/jnlp/MalformedXMLParser.java
index 04cfe19..27e4218 100644
--- a/netx/net/sourceforge/jnlp/MalformedXMLParser.java
+++ b/netx/net/sourceforge/jnlp/MalformedXMLParser.java
@@ -46,6 +46,7 @@ import java.io.OutputStreamWriter;
import java.io.Writer;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import net.sourceforge.jnlp.util.logging.OutputController;
import org.ccil.cowan.tagsoup.HTMLSchema;
import org.ccil.cowan.tagsoup.Parser;
@@ -73,9 +74,7 @@ public class MalformedXMLParser extends XMLParser {
*/
@Override
public Node getRootNode(InputStream input) throws ParseException {
- if (JNLPRuntime.isDebug()) {
- System.out.println("Using MalformedXMLParser");
- }
+ OutputController.getLogger().log("Using MalformedXMLParser");
InputStream xmlInput = xmlizeInputStream(input);
return super.getRootNode(xmlInput);
}
diff --git a/netx/net/sourceforge/jnlp/NetxPanel.java b/netx/net/sourceforge/jnlp/NetxPanel.java
index da15d0f..847adff 100644
--- a/netx/net/sourceforge/jnlp/NetxPanel.java
+++ b/netx/net/sourceforge/jnlp/NetxPanel.java
@@ -33,6 +33,7 @@ import java.util.concurrent.ConcurrentMap;
import net.sourceforge.jnlp.splashscreen.SplashController;
import net.sourceforge.jnlp.splashscreen.SplashPanel;
import net.sourceforge.jnlp.splashscreen.SplashUtils;
+import net.sourceforge.jnlp.util.logging.OutputController;
import sun.applet.AppletViewerPanel;
import sun.awt.SunToolkit;
@@ -87,7 +88,7 @@ public class NetxPanel extends AppletViewerPanel implements SplashController {
* Log any exceptions thrown while loading, initializing, starting,
* and stopping the applet.
*/
- AppletLog.log(t);
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, t); //new logger
super.showAppletException(t);
}
@@ -125,7 +126,7 @@ public class NetxPanel extends AppletViewerPanel implements SplashController {
}
} catch (Exception e) {
status = APPLET_ERROR;
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
replaceSplash(SplashUtils.getErrorSplashScreen(getWidth(), getHeight(), e));
} finally {
// PR1157: This needs to occur even in the case of an exception
@@ -148,13 +149,11 @@ public class NetxPanel extends AppletViewerPanel implements SplashController {
synchronized (JNLPRuntime.initMutex) {
//The custom NetX Policy and SecurityManager are set here.
if (!JNLPRuntime.isInitialized()) {
- if (JNLPRuntime.isDebug())
- System.out.println("initializing JNLPRuntime...");
+ OutputController.getLogger().log("initializing JNLPRuntime...");
JNLPRuntime.initialize(false);
} else {
- if (JNLPRuntime.isDebug())
- System.out.println("JNLPRuntime already initialized");
+ OutputController.getLogger().log("JNLPRuntime already initialized");
}
}
diff --git a/netx/net/sourceforge/jnlp/Parser.java b/netx/net/sourceforge/jnlp/Parser.java
index 37e3c0f..310b306 100644
--- a/netx/net/sourceforge/jnlp/Parser.java
+++ b/netx/net/sourceforge/jnlp/Parser.java
@@ -28,6 +28,7 @@ import java.util.*;
import net.sourceforge.jnlp.UpdateDesc.Check;
import net.sourceforge.jnlp.UpdateDesc.Policy;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* Contains methods to parse an XML document into a JNLPFile.
@@ -58,8 +59,8 @@ class Parser {
//throw exception;
}
public void warning(SAXParseException exception) {
- System.err.println("XML parse warning:");
- exception.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.WARNING_ALL, "XML parse warning:");
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, exception);
}
};
*/
@@ -438,23 +439,19 @@ class Parser {
* @throws RequiredElementException
*/
void checkForInformation() throws RequiredElementException {
- if (JNLPRuntime.isDebug()) {
- System.out.println("Homepage: " + file.getInformation().getHomepage());
- System.out.println("Description: " + file.getInformation().getDescription());
- }
+ OutputController.getLogger().log("Homepage: " + file.getInformation().getHomepage());
+ OutputController.getLogger().log("Description: " + file.getInformation().getDescription());
String title = file.getTitle();
String vendor = file.getVendor();
if (title == null || title.trim().isEmpty())
throw new MissingTitleException();
- else if (JNLPRuntime.isDebug())
- System.out.println("Acceptable title tag found, contains: " + title);
+ else OutputController.getLogger().log("Acceptable title tag found, contains: " + title);
if (vendor == null || vendor.trim().isEmpty())
throw new MissingVendorException();
- else if (JNLPRuntime.isDebug())
- System.out.println("Acceptable vendor tag found, contains: " + vendor);
+ else OutputController.getLogger().log("Acceptable vendor tag found, contains: " + vendor);
}
/**
diff --git a/netx/net/sourceforge/jnlp/PluginBridge.java b/netx/net/sourceforge/jnlp/PluginBridge.java
index 51c22a1..3b1cf37 100644
--- a/netx/net/sourceforge/jnlp/PluginBridge.java
+++ b/netx/net/sourceforge/jnlp/PluginBridge.java
@@ -37,6 +37,7 @@ import java.util.Map;
import java.util.Set;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import net.sourceforge.jnlp.util.logging.OutputController;
import sun.misc.BASE64Decoder;
/**
@@ -130,7 +131,7 @@ public class PluginBridge extends JNLPFile {
} catch (MalformedURLException e) {
// Don't fail because we cannot get the jnlp file. Parameters are optional not required.
// it is the site developer who should ensure that file exist.
- System.err.println("Unable to get JNLP file at: " + params.getJNLPHref()
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Unable to get JNLP file at: " + params.getJNLPHref()
+ " with context of URL as: " + codeBase.toExternalForm());
}
} else {
@@ -174,10 +175,8 @@ public class PluginBridge extends JNLPFile {
addArchiveEntries(archives);
- if (JNLPRuntime.isDebug()) {
- System.err.println("Jar string: " + archive);
- System.err.println("jars length: " + archives.length);
- }
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Jar string: " + archive);
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "jars length: " + archives.length);
}
if (main.endsWith(".class"))
diff --git a/netx/net/sourceforge/jnlp/SecurityDesc.java b/netx/net/sourceforge/jnlp/SecurityDesc.java
index 51b58bb..b0e22c6 100644
--- a/netx/net/sourceforge/jnlp/SecurityDesc.java
+++ b/netx/net/sourceforge/jnlp/SecurityDesc.java
@@ -24,6 +24,7 @@ import java.awt.AWTPermission;
import net.sourceforge.jnlp.config.DeploymentConfiguration;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* The security element.
@@ -180,7 +181,7 @@ public class SecurityDesc {
URI policyUri = new URI("file://" + policyLocation);
policy = Policy.getInstance("JavaPolicy", new URIParameter(policyUri));
} catch (Exception e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
}
// return the appropriate policy, or null
diff --git a/netx/net/sourceforge/jnlp/StreamEater.java b/netx/net/sourceforge/jnlp/StreamEater.java
index 4cd3485..88fbfbc 100644
--- a/netx/net/sourceforge/jnlp/StreamEater.java
+++ b/netx/net/sourceforge/jnlp/StreamEater.java
@@ -19,6 +19,7 @@ package net.sourceforge.jnlp;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* This class reads the output from a launched process and writes it to stdout.
@@ -32,12 +33,22 @@ public class StreamEater extends Thread {
public void run() {
try {
+ StringBuilder s = new StringBuilder();
while (true) {
int c = stream.read();
- if (c == -1)
+ if (c == -1){
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, s.toString());
break;
-
- System.out.write(c);
+ } else {
+ char ch = (char) c;
+ if (ch == '\n'){
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, s.toString());
+ s = new StringBuilder();
+ }else {
+ s.append((char) c);
+ }
+ }
+
}
} catch (IOException ex) {
}
diff --git a/netx/net/sourceforge/jnlp/XmlParser.java b/netx/net/sourceforge/jnlp/XmlParser.java
index 05080ea..4ed7a67 100644
--- a/netx/net/sourceforge/jnlp/XmlParser.java
+++ b/netx/net/sourceforge/jnlp/XmlParser.java
@@ -45,6 +45,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
+import net.sourceforge.jnlp.util.logging.OutputController;
import net.sourceforge.nanoxml.XMLElement;
@@ -105,7 +106,7 @@ class XMLParser {
try {
pout.close();
} catch (IOException ioe) {
- ioe.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ioe);
}
}
}).start();
diff --git a/netx/net/sourceforge/jnlp/about/HTMLPanel.java b/netx/net/sourceforge/jnlp/about/HTMLPanel.java
index 8587a3e..c18bbcc 100644
--- a/netx/net/sourceforge/jnlp/about/HTMLPanel.java
+++ b/netx/net/sourceforge/jnlp/about/HTMLPanel.java
@@ -48,6 +48,7 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
+import net.sourceforge.jnlp.util.logging.OutputController;
public class HTMLPanel extends JPanel {
@@ -61,7 +62,7 @@ public class HTMLPanel extends JPanel {
pane = new JEditorPane(url);
} catch (IOException ex) {
//no need to have invalid url fatal
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
}
pane.setContentType("text/html");
pane.setEditable(false);
diff --git a/netx/net/sourceforge/jnlp/browser/BrowserAwareProxySelector.java b/netx/net/sourceforge/jnlp/browser/BrowserAwareProxySelector.java
index 835444b..926a591 100644
--- a/netx/net/sourceforge/jnlp/browser/BrowserAwareProxySelector.java
+++ b/netx/net/sourceforge/jnlp/browser/BrowserAwareProxySelector.java
@@ -57,6 +57,7 @@ import net.sourceforge.jnlp.runtime.JNLPProxySelector;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
import net.sourceforge.jnlp.runtime.PacEvaluator;
import net.sourceforge.jnlp.runtime.PacEvaluatorFactory;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* A ProxySelector which can read proxy settings from a browser's
@@ -98,10 +99,8 @@ public class BrowserAwareProxySelector extends JNLPProxySelector {
try {
initFromBrowserConfig();
} catch (IOException e) {
- if (JNLPRuntime.isDebug()) {
- e.printStackTrace();
- }
- System.err.println(R("RProxyFirefoxNotFound"));
+ OutputController.getLogger().log(e);
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, R("RProxyFirefoxNotFound"));
browserProxyType = PROXY_TYPE_NONE;
}
}
@@ -130,7 +129,7 @@ public class BrowserAwareProxySelector extends JNLPProxySelector {
browserAutoConfigUrl = new URL(url);
}
} catch (MalformedURLException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
if (browserProxyType == BROWSER_PROXY_TYPE_PAC) {
@@ -209,15 +208,11 @@ public class BrowserAwareProxySelector extends JNLPProxySelector {
if (optionDescription == null) {
optionDescription = "Unknown";
}
- if (JNLPRuntime.isDebug()) {
- System.err.println(R("RProxyFirefoxOptionNotImplemented", browserProxyType, optionDescription));
- }
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG,R("RProxyFirefoxOptionNotImplemented", browserProxyType, optionDescription));
proxies.add(Proxy.NO_PROXY);
}
- if (JNLPRuntime.isDebug()) {
- System.out.println("Browser selected proxies: " + proxies.toString());
- }
+ OutputController.getLogger().log("Browser selected proxies: " + proxies.toString());
return proxies;
}
@@ -237,7 +232,7 @@ public class BrowserAwareProxySelector extends JNLPProxySelector {
String proxiesString = browserProxyAutoConfig.getProxies(uri.toURL());
proxies.addAll(getProxiesFromPacResult(proxiesString));
} catch (MalformedURLException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
proxies.add(Proxy.NO_PROXY);
}
diff --git a/netx/net/sourceforge/jnlp/browser/FirefoxPreferencesFinder.java b/netx/net/sourceforge/jnlp/browser/FirefoxPreferencesFinder.java
index 99545f3..57f434e 100644
--- a/netx/net/sourceforge/jnlp/browser/FirefoxPreferencesFinder.java
+++ b/netx/net/sourceforge/jnlp/browser/FirefoxPreferencesFinder.java
@@ -46,6 +46,7 @@ import java.util.ArrayList;
import java.util.List;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* Finds the file corresponding to firefox's (default) preferences file
@@ -71,9 +72,8 @@ public class FirefoxPreferencesFinder {
throw new FileNotFoundException(profilesPath);
}
- if (JNLPRuntime.isDebug()) {
- System.out.println("Using firefox's profiles file: " + profilesPath);
- }
+ OutputController.getLogger().log("Using firefox's profiles file: " + profilesPath);
+
BufferedReader reader = new BufferedReader(new FileReader(profilesPath));
List<String> linesInSection = new ArrayList<String>();
@@ -130,9 +130,7 @@ public class FirefoxPreferencesFinder {
throw new FileNotFoundException("preferences file");
} else {
String fullPath = configPath + path + File.separator + "prefs.js";
- if (JNLPRuntime.isDebug()) {
- System.out.println("Found preferences file: " + fullPath);
- }
+ OutputController.getLogger().log("Found preferences file: " + fullPath);
return new File(fullPath);
}
}
diff --git a/netx/net/sourceforge/jnlp/browser/FirefoxPreferencesParser.java b/netx/net/sourceforge/jnlp/browser/FirefoxPreferencesParser.java
index 9555b00..7b849ef 100644
--- a/netx/net/sourceforge/jnlp/browser/FirefoxPreferencesParser.java
+++ b/netx/net/sourceforge/jnlp/browser/FirefoxPreferencesParser.java
@@ -45,6 +45,7 @@ import java.util.HashMap;
import java.util.Map;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* A parser for Firefox's preferences file. It can 'parse' Firefox's
@@ -128,7 +129,7 @@ public final class FirefoxPreferencesParser {
foundValue = true;
if (foundKey && foundValue) {
- // System.out.println("added (\"" + key + "\", \"" + value + "\")");
+ //ItwLogger.getLogger().printOutLn("added (\"" + key + "\", \"" + value + "\")");
prefs.put(key, value);
}
}
@@ -138,9 +139,7 @@ public final class FirefoxPreferencesParser {
} finally {
reader.close();
}
- if (JNLPRuntime.isDebug()) {
- System.out.println("Read " + prefs.size() + " entries from Firefox's preferences");
- }
+ OutputController.getLogger().log("Read " + prefs.size() + " entries from Firefox's preferences");
}
/**
diff --git a/netx/net/sourceforge/jnlp/cache/CacheDirectory.java b/netx/net/sourceforge/jnlp/cache/CacheDirectory.java
index 71e4a01..087f200 100644
--- a/netx/net/sourceforge/jnlp/cache/CacheDirectory.java
+++ b/netx/net/sourceforge/jnlp/cache/CacheDirectory.java
@@ -40,6 +40,7 @@ import java.io.File;
import java.util.ArrayList;
import net.sourceforge.jnlp.util.FileUtils;
+import net.sourceforge.jnlp.util.logging.OutputController;
public final class CacheDirectory {
@@ -93,8 +94,9 @@ public final class CacheDirectory {
else
delete = false;
}
- if (delete)
- System.out.println("Delete -- " + root);
+ if (delete){
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "Delete -- " + root);
+ }
// root.delete();
return true;
}
diff --git a/netx/net/sourceforge/jnlp/cache/CacheEntry.java b/netx/net/sourceforge/jnlp/cache/CacheEntry.java
index 8d70da6..f128a55 100644
--- a/netx/net/sourceforge/jnlp/cache/CacheEntry.java
+++ b/netx/net/sourceforge/jnlp/cache/CacheEntry.java
@@ -16,6 +16,7 @@
package net.sourceforge.jnlp.cache;
+import net.sourceforge.jnlp.util.logging.OutputController;
import static net.sourceforge.jnlp.runtime.Translator.R;
import java.io.*;
@@ -121,8 +122,7 @@ public class CacheEntry {
else
return false;
} catch (Exception ex) {
- if (JNLPRuntime.isDebug())
- ex.printStackTrace();
+ OutputController.getLogger().log(ex);;
return cached; // if can't connect return whether already in cache
}
@@ -148,8 +148,7 @@ public class CacheEntry {
else
return true;
} catch (Exception ex) {
- if (JNLPRuntime.isDebug())
- ex.printStackTrace();
+ OutputController.getLogger().log(ex);
return false; // should throw?
}
diff --git a/netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java b/netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java
index 45c8067..c873c4d 100644
--- a/netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java
+++ b/netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java
@@ -53,6 +53,7 @@ import java.util.Map.Entry;
import net.sourceforge.jnlp.config.DeploymentConfiguration;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
import net.sourceforge.jnlp.util.FileUtils;
+import net.sourceforge.jnlp.util.logging.OutputController;
import net.sourceforge.jnlp.util.PropertiesFile;
/**
@@ -90,7 +91,7 @@ public enum CacheLRUWrapper {
FileUtils.createParentDir(f);
FileUtils.createRestrictedFile(f, true);
} catch (IOException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
}
}
@@ -114,12 +115,10 @@ public enum CacheLRUWrapper {
* clean up possibly corrupted entries
*/
if (loaded && checkData()) {
- if (JNLPRuntime.isDebug()) {
- new LruCacheException().printStackTrace();
- }
- System.out.println(R("CFakeCache"));
+ OutputController.getLogger().log(new LruCacheException());
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, R("CFakeCache"));
store();
- System.out.println(R("CFakedCache"));
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, R("CFakedCache"));
}
}
@@ -246,7 +245,7 @@ public enum CacheLRUWrapper {
fl = FileUtils.getFileLock(cacheOrder.getStoreFile().getPath(), false, true);
} catch (OverlappingFileLockException e) { // if overlap we just increase the count.
} catch (Exception e) { // We didn't get a lock..
- e.printStackTrace();
+ OutputController.getLogger().log(e);
}
if (fl != null) lockCount++;
}
@@ -264,7 +263,7 @@ public enum CacheLRUWrapper {
fl = null;
}
} catch (IOException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(e);
}
}
}
diff --git a/netx/net/sourceforge/jnlp/cache/CacheUtil.java b/netx/net/sourceforge/jnlp/cache/CacheUtil.java
index 5e27b84..f2bf0fa 100644
--- a/netx/net/sourceforge/jnlp/cache/CacheUtil.java
+++ b/netx/net/sourceforge/jnlp/cache/CacheUtil.java
@@ -48,6 +48,7 @@ import net.sourceforge.jnlp.config.DeploymentConfiguration;
import net.sourceforge.jnlp.runtime.ApplicationInstance;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
import net.sourceforge.jnlp.util.FileUtils;
+import net.sourceforge.jnlp.util.logging.OutputController;
import net.sourceforge.jnlp.util.PropertiesFile;
import net.sourceforge.jnlp.util.UrlUtils;
@@ -160,8 +161,7 @@ public class CacheUtil {
return location.openConnection().getPermission();
} catch (java.io.IOException ioe) {
// should try to figure out the permission
- if (JNLPRuntime.isDebug())
- ioe.printStackTrace();
+ OutputController.getLogger().log(ioe);
}
}
@@ -178,7 +178,7 @@ public class CacheUtil {
public static boolean clearCache() {
if (!okToClearCache()) {
- System.err.println(R("CCannotClearCache"));
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, R("CCannotClearCache"));
return false;
}
@@ -187,9 +187,7 @@ public class CacheUtil {
return false;
}
- if (JNLPRuntime.isDebug()) {
- System.err.println("Clearing cache directory: " + cacheDir);
- }
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Clearing cache directory: " + cacheDir);
try {
cacheDir = cacheDir.getCanonicalFile();
FileUtils.recursiveDelete(cacheDir, cacheDir);
@@ -212,21 +210,14 @@ public class CacheUtil {
FileChannel channel = fis.getChannel();
if (channel.tryLock() == null) {
- if (JNLPRuntime.isDebug()) {
- System.out.println("Other instances of netx are running");
- }
+ OutputController.getLogger().log("Other instances of netx are running");
return false;
}
-
- if (JNLPRuntime.isDebug()) {
- System.out.println("No other instances of netx are running");
- }
+ OutputController.getLogger().log("No other instances of netx are running");
return true;
} else {
- if (JNLPRuntime.isDebug()) {
- System.out.println("No instance file found");
- }
+ OutputController.getLogger().log("No instance file found");
return true;
}
} catch (IOException e) {
@@ -259,14 +250,11 @@ public class CacheUtil {
CacheEntry entry = new CacheEntry(source, version); // could pool this
boolean result = entry.isCurrent(connection);
- if (JNLPRuntime.isDebug())
- System.out.println("isCurrent: " + source + " = " + result);
+ OutputController.getLogger().log("isCurrent: " + source + " = " + result);
return result;
} catch (Exception ex) {
- if (JNLPRuntime.isDebug())
- ex.printStackTrace();
-
+ OutputController.getLogger().log(ex);
return isCached(source, version); // if can't connect return whether already in cache
}
}
@@ -287,8 +275,7 @@ public class CacheUtil {
CacheEntry entry = new CacheEntry(source, version); // could pool this
boolean result = entry.isCached();
- if (JNLPRuntime.isDebug())
- System.out.println("isCached: " + source + " = " + result);
+ OutputController.getLogger().log("isCached: " + source + " = " + result);
return result;
}
@@ -425,7 +412,7 @@ public class CacheUtil {
FileUtils.createRestrictedFile(pf, true); // Create the info file for marking later.
lruHandler.addEntry(lruHandler.generateKey(cacheFile.getPath()), cacheFile.getPath());
} catch (IOException ioe) {
- ioe.printStackTrace();
+ OutputController.getLogger().log(ioe);
}
break;
@@ -568,8 +555,7 @@ public class CacheUtil {
100);
}
} catch (InterruptedException ex) {
- if (JNLPRuntime.isDebug())
- ex.printStackTrace();
+ OutputController.getLogger().log(ex);
} finally {
if (listener != null)
indicator.disposeListener(listener);
@@ -644,7 +630,7 @@ public class CacheUtil {
try {
FileUtils.recursiveDelete(f, f);
} catch (IOException e1) {
- e1.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e1);
}
}
@@ -685,7 +671,7 @@ public class CacheUtil {
propertiesLockPool.put(storeFilePath, FileUtils.getFileLock(storeFilePath, false, true));
} catch (OverlappingFileLockException e) {
} catch (FileNotFoundException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
}
@@ -704,7 +690,7 @@ public class CacheUtil {
fl.channel().close();
propertiesLockPool.remove(storeFile.getPath());
} catch (IOException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
}
}
diff --git a/netx/net/sourceforge/jnlp/cache/NativeLibraryStorage.java b/netx/net/sourceforge/jnlp/cache/NativeLibraryStorage.java
index 7d9eb6e..d65cadb 100644
--- a/netx/net/sourceforge/jnlp/cache/NativeLibraryStorage.java
+++ b/netx/net/sourceforge/jnlp/cache/NativeLibraryStorage.java
@@ -12,6 +12,7 @@ import java.util.jar.JarFile;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
import net.sourceforge.jnlp.util.FileUtils;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* Handles loading and access of native code loading through a JNLP application or applet.
@@ -34,9 +35,7 @@ public class NativeLibraryStorage {
*/
public void cleanupTemporaryFolder() {
if (jarEntryDirectory != null) {
- if (JNLPRuntime.isDebug()) {
- System.out.println("Cleaning up native directory" + jarEntryDirectory.getAbsolutePath());
- }
+ OutputController.getLogger().log("Cleaning up native directory" + jarEntryDirectory.getAbsolutePath());
try {
FileUtils.recursiveDelete(jarEntryDirectory,
new File(System.getProperty("java.io.tmpdir")));
@@ -84,9 +83,7 @@ public class NativeLibraryStorage {
* classloader.
*/
public void addSearchJar(URL jarLocation) {
- if (JNLPRuntime.isDebug())
- System.out.println("Activate native: " + jarLocation);
-
+ OutputController.getLogger().log("Activate native: " + jarLocation);
File localFile = tracker.getCacheFile(jarLocation);
if (localFile == null)
return;
@@ -127,8 +124,7 @@ public class NativeLibraryStorage {
jarFile.close();
} catch (IOException ex) {
- if (JNLPRuntime.isDebug())
- ex.printStackTrace();
+ OutputController.getLogger().log(ex);
}
}
diff --git a/netx/net/sourceforge/jnlp/cache/Resource.java b/netx/net/sourceforge/jnlp/cache/Resource.java
index c4c6bbf..9351191 100644
--- a/netx/net/sourceforge/jnlp/cache/Resource.java
+++ b/netx/net/sourceforge/jnlp/cache/Resource.java
@@ -16,6 +16,7 @@
package net.sourceforge.jnlp.cache;
+import net.sourceforge.jnlp.util.logging.OutputController;
import java.io.*;
import java.net.*;
import java.util.*;
@@ -226,15 +227,16 @@ public class Resource {
this.status |= add;
}
- if (JNLPRuntime.isDebug())
- if (status != orig) {
- System.out.print("Status: " + getStatusString(status));
- if ((status & ~orig) != 0)
- System.out.print(" +(" + getStatusString(status & ~orig) + ")");
- if ((~status & orig) != 0)
- System.out.print(" -(" + getStatusString(~status & orig) + ")");
- System.out.println(" @ " + location.getPath());
+ if (status != orig) {
+ OutputController.getLogger().log("Status: " + getStatusString(status));
+ if ((status & ~orig) != 0) {
+ OutputController.getLogger().log(" +(" + getStatusString(status & ~orig) + ")");
}
+ if ((~status & orig) != 0) {
+ OutputController.getLogger().log(" -(" + getStatusString(~status & orig) + ")");
+ }
+ OutputController.getLogger().log(" @ " + location.getPath());
+ }
}
/**
diff --git a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java
index 549a6da..c411f91 100644
--- a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java
+++ b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java
@@ -46,6 +46,7 @@ import net.sourceforge.jnlp.event.DownloadEvent;
import net.sourceforge.jnlp.event.DownloadListener;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
import net.sourceforge.jnlp.util.HttpUtils;
+import net.sourceforge.jnlp.util.logging.OutputController;
import net.sourceforge.jnlp.util.UrlUtils;
import net.sourceforge.jnlp.util.WeakList;
@@ -183,8 +184,8 @@ public class ResourceTracker {
try {
location = UrlUtils.normalizeUrl(location);
} catch (Exception ex) {
- System.err.println("Normalization of " + location.toString() + " have failed");
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Normalization of " + location.toString() + " have failed");
+ OutputController.getLogger().log(ex);
}
Resource resource = Resource.getResource(location, version, updatePolicy);
boolean downloaded = false;
@@ -258,8 +259,7 @@ public class ResourceTracker {
CacheEntry entry = new CacheEntry(resource.location, resource.downloadVersion);
if (entry.isCached() && !updatePolicy.shouldUpdate(entry)) {
- if (JNLPRuntime.isDebug())
- System.out.println("not updating: " + resource.location);
+ OutputController.getLogger().log("not updating: " + resource.location);
synchronized (resource) {
resource.localFile = CacheUtil.getCacheFile(resource.location, resource.downloadVersion);
@@ -356,8 +356,7 @@ public class ResourceTracker {
// TODO: Should be toURI().toURL()
return f.toURL();
} catch (MalformedURLException ex) {
- if (JNLPRuntime.isDebug())
- ex.printStackTrace();
+ OutputController.getLogger().log(ex);
}
return location;
@@ -396,9 +395,7 @@ public class ResourceTracker {
return null;
} catch (InterruptedException ex) {
- if (JNLPRuntime.isDebug())
- ex.printStackTrace();
-
+ OutputController.getLogger().log(ex);
return null; // need an error exception to throw
}
}
@@ -664,12 +661,9 @@ public class ResourceTracker {
String contentEncoding = con.getContentEncoding();
- if (JNLPRuntime.isDebug()) {
- System.err.println("Downloading" + resource.location + " using " +
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Downloading" + resource.location + " using " +
realLocation + " (encoding : " + contentEncoding + ")");
- }
-
boolean packgz = "pack200-gzip".equals(contentEncoding) ||
realLocation.getPath().endsWith(".pack.gz");
boolean gzip = "gzip".equals(contentEncoding);
@@ -759,9 +753,7 @@ public class ResourceTracker {
}
resource.fireDownloadEvent(); // fire DOWNLOADED
} catch (Exception ex) {
- if (JNLPRuntime.isDebug())
- ex.printStackTrace();
-
+ OutputController.getLogger().log(ex);
resource.changeStatus(0, ERROR);
synchronized (lock) {
lock.notifyAll(); // wake up wait's to check for completion
@@ -789,7 +781,7 @@ public class ResourceTracker {
URL finalLocation = findBestUrl(resource);
if (finalLocation == null) {
- System.err.println("Attempted to download " + resource.location + ", but failed to connect!");
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Attempted to download " + resource.location + ", but failed to connect!");
throw new NullPointerException("finalLocation == null"); // Caught below
}
@@ -839,9 +831,7 @@ public class ResourceTracker {
if (connection instanceof HttpURLConnection)
((HttpURLConnection) connection).disconnect();
} catch (Exception ex) {
- if (JNLPRuntime.isDebug())
- ex.printStackTrace();
-
+ OutputController.getLogger().log(ex);
resource.changeStatus(0, ERROR);
synchronized (lock) {
lock.notifyAll(); // wake up wait's to check for completion
@@ -897,11 +887,9 @@ public class ResourceTracker {
}
List<URL> urls = new ResourceUrlCreator(resource, options).getUrls();
- if (JNLPRuntime.isDebug()) {
- System.err.println("All possible urls for " +
- resource.toString() + " : " + urls);
- }
-
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "All possible urls for "
+ + resource.toString() + " : " + urls);
+
for (String requestMethod : requestMethods) {
for (URL url : urls) {
try {
@@ -911,21 +899,15 @@ public class ResourceTracker {
int responseCode = getUrlResponseCode(url, requestProperties, requestMethod);
if (responseCode < 200 || responseCode >= 300) {
- if (JNLPRuntime.isDebug()) {
- System.err.println("For " + resource.toString() + " the server returned " + responseCode + " code for " + requestMethod + " request for " + url.toExternalForm());
- }
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "For " + resource.toString() + " the server returned " + responseCode + " code for " + requestMethod + " request for " + url.toExternalForm());
} else {
- if (JNLPRuntime.isDebug()) {
- System.err.println("best url for " + resource.toString() + " is " + url.toString() + " by " + requestMethod);
- }
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "best url for " + resource.toString() + " is " + url.toString() + " by " + requestMethod);
return url; /* This is the best URL */
}
} catch (IOException e) {
// continue to next candidate
- if (JNLPRuntime.isDebug()) {
- System.err.println("While processing " + url.toString() + " by " + requestMethod + " for resource " + resource.toString() + " got " + e + ": ");
- e.printStackTrace();
- }
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "While processing " + url.toString() + " by " + requestMethod + " for resource " + resource.toString() + " got " + e + ": ");
+ OutputController.getLogger().log(e);
}
}
}
@@ -1175,8 +1157,7 @@ public class ResourceTracker {
});
} catch (Exception ex) {
- if (JNLPRuntime.isDebug())
- ex.printStackTrace();
+ OutputController.getLogger().log(ex);
}
}
// should have a finally in case some exception is thrown by
diff --git a/netx/net/sourceforge/jnlp/config/Defaults.java b/netx/net/sourceforge/jnlp/config/Defaults.java
index c036c62..c3fdade 100644
--- a/netx/net/sourceforge/jnlp/config/Defaults.java
+++ b/netx/net/sourceforge/jnlp/config/Defaults.java
@@ -341,17 +341,31 @@ public class Defaults {
}),
DeploymentConfiguration.CONSOLE_HIDE
},
- /* tracing and logging */
{
- DeploymentConfiguration.KEY_ENABLE_TRACING,
+ DeploymentConfiguration.KEY_ENABLE_LOGGING,
BasicValueValidators.getBooleanValidator(),
String.valueOf(false)
},
{
- DeploymentConfiguration.KEY_ENABLE_LOGGING,
+ DeploymentConfiguration.KEY_ENABLE_LOGGING_HEADERS,
BasicValueValidators.getBooleanValidator(),
String.valueOf(false)
},
+ {
+ DeploymentConfiguration.KEY_ENABLE_LOGGING_TOFILE,
+ BasicValueValidators.getBooleanValidator(),
+ String.valueOf(false)
+ },
+ {
+ DeploymentConfiguration.KEY_ENABLE_LOGGING_TOSTREAMS,
+ BasicValueValidators.getBooleanValidator(),
+ String.valueOf(true)
+ },
+ {
+ DeploymentConfiguration.KEY_ENABLE_LOGGING_TOSYSTEMLOG,
+ BasicValueValidators.getBooleanValidator(),
+ String.valueOf(true)
+ },
/* JNLP association */
{
DeploymentConfiguration.KEY_JNLP_ASSOCIATIONS,
diff --git a/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java b/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java
index e6f1ff1..3dbcaab 100644
--- a/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java
+++ b/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java
@@ -40,6 +40,7 @@ import javax.naming.ConfigurationException;
import net.sourceforge.jnlp.cache.CacheLRUWrapper;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
import net.sourceforge.jnlp.util.FileUtils;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* Manages the various properties and configuration related to deployment.
@@ -147,10 +148,13 @@ public final class DeploymentConfiguration {
public static final String KEY_PROXY_OVERRIDE_HOSTS = "deployment.proxy.override.hosts";
/*
- * Tracing and Logging
+ * Logging
*/
- public static final String KEY_ENABLE_TRACING = "deployment.trace";
- public static final String KEY_ENABLE_LOGGING = "deployment.log";
+ public static final String KEY_ENABLE_LOGGING = "deployment.log"; //same as verbose or ICEDTEAPLUGIN_DEBUG=true
+ public static final String KEY_ENABLE_LOGGING_HEADERS = "deployment.log.headers"; //will add header OutputContorll.getHeader To all messages
+ public static final String KEY_ENABLE_LOGGING_TOFILE = "deployment.log.file";
+ public static final String KEY_ENABLE_LOGGING_TOSTREAMS = "deployment.log.stdstreams";
+ public static final String KEY_ENABLE_LOGGING_TOSYSTEMLOG = "deployment.log.system";
/*
* Console
@@ -256,9 +260,7 @@ public final class DeploymentConfiguration {
if (systemConfigFile != null) {
if (loadSystemConfiguration(systemConfigFile)) {
- if (JNLPRuntime.isDebug()) {
- System.out.println("System level " + DEPLOYMENT_CONFIG_FILE + " is mandatory: " + systemPropertiesMandatory);
- }
+ OutputController.getLogger().log("System level " + DEPLOYMENT_CONFIG_FILE + " is mandatory: " + systemPropertiesMandatory);
/* Second, read the System level deployment.properties file */
systemProperties = loadProperties(ConfigType.System, systemPropertiesFile,
systemPropertiesMandatory);
@@ -396,9 +398,9 @@ public final class DeploymentConfiguration {
for (String key : initial.keySet()) {
Setting<String> s = initial.get(key);
if (!(s.getName().equals(key))) {
- System.out.println(R("DCInternal", "key " + key + " does not match setting name " + s.getName()));
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, R("DCInternal", "key " + key + " does not match setting name " + s.getName()));
} else if (!defaults.containsKey(key)) {
- System.out.println(R("DCUnknownSettingWithName", key));
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, R("DCUnknownSettingWithName", key));
} else {
ValueValidator checker = defaults.get(key).getValidator();
if (checker == null) {
@@ -408,8 +410,9 @@ public final class DeploymentConfiguration {
try {
checker.validate(s.getValue());
} catch (IllegalArgumentException e) {
- System.out.println(R("DCIncorrectValue", key, s.getValue(), checker.getPossibleValues()));
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, R("DCIncorrectValue", key, s.getValue(), checker.getPossibleValues()));
s.setValue(s.getDefaultValue());
+ OutputController.getLogger().log(e);
}
}
}
@@ -433,9 +436,7 @@ public final class DeploymentConfiguration {
jrePath = jreSetting.getValue();
}
} catch (Exception ex) {
- if (JNLPRuntime.isDebug()){
- ex.printStackTrace();
- }
+ OutputController.getLogger().log(ex);
}
File jreFile;
@@ -459,17 +460,14 @@ public final class DeploymentConfiguration {
*/
private boolean loadSystemConfiguration(File configFile) {
- if (JNLPRuntime.isDebug()) {
- System.out.println("Loading system configuation from: " + configFile);
- }
+ OutputController.getLogger().log("Loading system configuation from: " + configFile);
Map<String, Setting<String>> systemConfiguration = new HashMap<String, Setting<String>>();
try {
systemConfiguration = parsePropertiesFile(configFile);
} catch (IOException e) {
- if (JNLPRuntime.isDebug()) {
- System.out.println("No System level " + DEPLOYMENT_PROPERTIES + " found.");
- }
+ OutputController.getLogger().log("No System level " + DEPLOYMENT_PROPERTIES + " found.");
+ OutputController.getLogger().log(e);
return false;
}
@@ -481,31 +479,24 @@ public final class DeploymentConfiguration {
try {
String urlString = systemConfiguration.get("deployment.system.config").getValue();
if (urlString == null) {
- if (JNLPRuntime.isDebug()) {
- System.out.println("No System level " + DEPLOYMENT_PROPERTIES + " found.");
- }
+ OutputController.getLogger().log("No System level " + DEPLOYMENT_PROPERTIES + " found.");
return false;
}
URL url = new URL(urlString);
if (url.getProtocol().equals("file")) {
systemPropertiesFile = new File(url.getFile());
- if (JNLPRuntime.isDebug()) {
- System.out.println("Using System level" + DEPLOYMENT_PROPERTIES + ": "
+ OutputController.getLogger().log("Using System level" + DEPLOYMENT_PROPERTIES + ": "
+ systemPropertiesFile);
- }
Setting<String> mandatory = systemConfiguration.get("deployment.system.config.mandatory");
systemPropertiesMandatory = Boolean.valueOf(mandatory == null ? null : (String) mandatory.getValue());
return true;
} else {
- if (JNLPRuntime.isDebug()) {
- System.out.println("Remote + " + DEPLOYMENT_PROPERTIES + " not supported");
- }
+ OutputController.getLogger().log("Remote + " + DEPLOYMENT_PROPERTIES + " not supported");
return false;
}
} catch (MalformedURLException e) {
- if (JNLPRuntime.isDebug()) {
- System.out.println("Invalid url for " + DEPLOYMENT_PROPERTIES);
- }
+ OutputController.getLogger().log("Invalid url for " + DEPLOYMENT_PROPERTIES);
+ OutputController.getLogger().log(e);
return false;
}
}
@@ -522,9 +513,7 @@ public final class DeploymentConfiguration {
private Map<String, Setting<String>> loadProperties(ConfigType type, File file, boolean mandatory)
throws ConfigurationException {
if (file == null || !file.isFile()) {
- if (JNLPRuntime.isDebug()) {
- System.out.println("No " + type.toString() + " level " + DEPLOYMENT_PROPERTIES + " found.");
- }
+ OutputController.getLogger().log("No " + type.toString() + " level " + DEPLOYMENT_PROPERTIES + " found.");
if (!mandatory) {
return null;
} else {
@@ -532,14 +521,12 @@ public final class DeploymentConfiguration {
}
}
- if (JNLPRuntime.isDebug()) {
- System.out.println("Loading " + type.toString() + " level properties from: " + file);
- }
+ OutputController.getLogger().log("Loading " + type.toString() + " level properties from: " + file);
try {
return parsePropertiesFile(file);
} catch (IOException e) {
if (JNLPRuntime.isDebug()){
- e.printStackTrace();
+ OutputController.getLogger().log(e);
}
return null;
}
@@ -561,9 +548,7 @@ public final class DeploymentConfiguration {
sm.checkWrite(userPropertiesFile.toString());
}
- if (JNLPRuntime.isDebug()) {
- System.out.println("Saving properties into " + userPropertiesFile.toString());
- }
+ OutputController.getLogger().log("Saving properties into " + userPropertiesFile.toString());
Properties toSave = new Properties();
for (String key : currentConfiguration.keySet()) {
@@ -679,7 +664,7 @@ public final class DeploymentConfiguration {
*/
@SuppressWarnings("unused")
private static void dumpConfiguration(Map<String, Setting<String>> config, PrintStream out) {
- System.out.println("KEY: VALUE [Locked]");
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "KEY: VALUE [Locked]");
for (String key : config.keySet()) {
Setting<String> value = config.get(key);
@@ -692,8 +677,8 @@ public final class DeploymentConfiguration {
try {
move14AndOlderFilesTo15Structure();
} catch (Throwable t) {
- System.err.println("Critical error during converting old files to new. Continuing");
- t.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Critical error during converting old files to new. Continuing");
+ OutputController.getLogger().log(t);
}
}
@@ -704,17 +689,17 @@ public final class DeploymentConfiguration {
String LEGACY_USER_HOME = System.getProperty("user.home") + File.separator + PRE_15_DEPLOYMENT_DIR;
File legacyUserDir = new File(LEGACY_USER_HOME);
if (legacyUserDir.exists()) {
- System.out.println("Legacy configuration and cache found. Those will be now transported to new locations");
- System.out.println(Defaults.USER_CONFIG_HOME + " and " + Defaults.USER_CACHE_HOME);
- System.out.println("You should not see this message next time you run icedtea-web!");
- System.out.println("Your custom dirs will not be touched and will work");
- System.out.println("-----------------------------------------------");
-
- System.out.println("Preparing new directories:");
- System.out.println(" " + Defaults.USER_CONFIG_HOME);
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "Legacy configuration and cache found. Those will be now transported to new locations");
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, Defaults.USER_CONFIG_HOME + " and " + Defaults.USER_CACHE_HOME);
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "You should not see this message next time you run icedtea-web!");
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "Your custom dirs will not be touched and will work");
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "-----------------------------------------------");
+
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "Preparing new directories:");
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " " + Defaults.USER_CONFIG_HOME);
File f1 = new File(Defaults.USER_CONFIG_HOME);
errors += resultToStd(f1.mkdirs());
- System.out.println(" " + Defaults.USER_CACHE_HOME);
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " " + Defaults.USER_CACHE_HOME);
File f2 = new File(Defaults.USER_CACHE_HOME);
errors += resultToStd(f2.mkdirs());
@@ -725,7 +710,7 @@ public final class DeploymentConfiguration {
String legacyCache = LEGACY_USER_HOME + File.separator + "cache";
String currentCache = Defaults.getDefaults().get(DeploymentConfiguration.KEY_USER_CACHE_DIR).getDefaultValue();
errors += moveLegacyToCurrent(legacyCache, currentCache);
- System.out.println("Adapting " + CacheLRUWrapper.CACHE_INDEX_FILE_NAME + " to new destination");
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "Adapting " + CacheLRUWrapper.CACHE_INDEX_FILE_NAME + " to new destination");
//replace all legacyCache by currentCache in new recently_used
try {
File f = new File(currentCache, CacheLRUWrapper.CACHE_INDEX_FILE_NAME);
@@ -733,7 +718,7 @@ public final class DeploymentConfiguration {
s = s.replace(legacyCache, currentCache);
FileUtils.saveFile(s, f);
} catch (IOException ex) {
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, ex);
errors++;
}
@@ -762,46 +747,44 @@ public final class DeploymentConfiguration {
String currentTmp = Defaults.getDefaults().get(DeploymentConfiguration.KEY_USER_TMP_DIR).getDefaultValue();
errors += moveLegacyToCurrent(legacyTmp, currentTmp);
- System.out.println("Removing now empty " + LEGACY_USER_HOME);
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "Removing now empty " + LEGACY_USER_HOME);
errors += resultToStd(legacyUserDir.delete());
if (errors != 0) {
- System.out.println("There occureed " + errors + " errors");
- System.out.println("Please double check content of old data in " + LEGACY_USER_HOME + " with ");
- System.out.println("new " + Defaults.USER_CONFIG_HOME + " and " + Defaults.USER_CACHE_HOME);
- System.out.println("To disable this check again, please remove " + LEGACY_USER_HOME);
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "There occureed " + errors + " errors");
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "Please double check content of old data in " + LEGACY_USER_HOME + " with ");
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "new " + Defaults.USER_CONFIG_HOME + " and " + Defaults.USER_CACHE_HOME);
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "To disable this check again, please remove " + LEGACY_USER_HOME);
}
} else {
- if (JNLPRuntime.isDebug()) {
- System.out.println("System is already following XDG .cache and .config specifications");
- try {
- System.out.println("config: " + Defaults.USER_CONFIG_HOME + " file exists: " + new File(Defaults.USER_CONFIG_HOME).exists());
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- try {
- System.out.println("cache: " + Defaults.USER_CACHE_HOME + " file exists:" + new File(Defaults.USER_CACHE_HOME));
- } catch (Exception ex) {
- ex.printStackTrace();
- }
+ OutputController.getLogger().log("System is already following XDG .cache and .config specifications");
+ try {
+ OutputController.getLogger().log("config: " + Defaults.USER_CONFIG_HOME + " file exists: " + new File(Defaults.USER_CONFIG_HOME).exists());
+ } catch (Exception ex) {
+ OutputController.getLogger().log(ex);
+ }
+ try {
+ OutputController.getLogger().log("cache: " + Defaults.USER_CACHE_HOME + " file exists:" + new File(Defaults.USER_CACHE_HOME));
+ } catch (Exception ex) {
+ OutputController.getLogger().log(ex);
}
}
}
private static int moveLegacyToCurrent(String legacy, String current) {
- System.out.println("Moving " + legacy + " to " + current);
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "Moving " + legacy + " to " + current);
File cf = new File(current);
File old = new File(legacy);
if (cf.exists()) {
- System.out.println("Warning! Destination " + current + " exists!");
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "Warning! Destination " + current + " exists!");
}
if (old.exists()) {
boolean moved = old.renameTo(cf);
return resultToStd(moved);
} else {
- System.out.println("Source " + legacy + " do not exists, nothing to do");
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "Source " + legacy + " do not exists, nothing to do");
return 0;
}
@@ -809,10 +792,10 @@ public final class DeploymentConfiguration {
private static int resultToStd(boolean securityMove) {
if (securityMove) {
- System.out.println("OK");
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "OK");
return 0;
} else {
- System.out.println("ERROR");
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "ERROR");
return 1;
}
}
diff --git a/netx/net/sourceforge/jnlp/controlpanel/CachePane.java b/netx/net/sourceforge/jnlp/controlpanel/CachePane.java
index da3c92e..502cf8a 100644
--- a/netx/net/sourceforge/jnlp/controlpanel/CachePane.java
+++ b/netx/net/sourceforge/jnlp/controlpanel/CachePane.java
@@ -54,6 +54,7 @@ import net.sourceforge.jnlp.cache.DirectoryNode;
import net.sourceforge.jnlp.config.DeploymentConfiguration;
import net.sourceforge.jnlp.runtime.Translator;
import net.sourceforge.jnlp.util.FileUtils;
+import net.sourceforge.jnlp.util.logging.OutputController;
import net.sourceforge.jnlp.util.PropertiesFile;
public class CachePane extends JPanel {
@@ -164,7 +165,7 @@ public class CachePane extends JPanel {
FileUtils.createParentDir(netxRunningFile);
FileUtils.createRestrictedFile(netxRunningFile, true);
} catch (IOException e1) {
- e1.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e1);
}
}
@@ -197,7 +198,7 @@ public class CachePane extends JPanel {
fl.release();
fl.channel().close();
} catch (IOException e1) {
- e1.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e1);
}
}
}
diff --git a/netx/net/sourceforge/jnlp/controlpanel/CommandLine.java b/netx/net/sourceforge/jnlp/controlpanel/CommandLine.java
index 01093ee..958221c 100644
--- a/netx/net/sourceforge/jnlp/controlpanel/CommandLine.java
+++ b/netx/net/sourceforge/jnlp/controlpanel/CommandLine.java
@@ -31,6 +31,8 @@ import javax.naming.ConfigurationException;
import net.sourceforge.jnlp.config.ConfiguratonValidator;
import net.sourceforge.jnlp.config.DeploymentConfiguration;
import net.sourceforge.jnlp.config.Setting;
+import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* Encapsulates a command line interface to the deployment configuration.
@@ -80,7 +82,8 @@ public class CommandLine {
try {
config.load(false);
} catch (ConfigurationException e) {
- System.out.println(R("RConfigurationFatal"));
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, R("RConfigurationFatal"));
+ OutputController.getLogger().log(e);
}
}
@@ -91,10 +94,10 @@ public class CommandLine {
* @return the result of handling the help command. SUCCESS if no errors occurred.
*/
public int handleHelpCommand(List<String> args) {
- System.out.println(R("Usage"));
- System.out.println(" " + PROGRAM_NAME + " "
+ OutputController.getLogger().printOutLn(R("Usage"));
+ OutputController.getLogger().printOutLn(" " + PROGRAM_NAME + " "
+ allCommands.toString().replace(',', '|').replaceAll(" ", "") + " [help]");
- System.out.println(R("CLHelpDescription", PROGRAM_NAME));
+ OutputController.getLogger().printOutLn(R("CLHelpDescription", PROGRAM_NAME));
return SUCCESS;
}
@@ -102,9 +105,9 @@ public class CommandLine {
* Prints help message for the list command
*/
public void printListHelp() {
- System.out.println(R("Usage"));
- System.out.println(" " + PROGRAM_NAME + " list [--details]");
- System.out.println(R("CLListDescription"));
+ OutputController.getLogger().printOutLn(R("Usage"));
+ OutputController.getLogger().printOutLn(" " + PROGRAM_NAME + " list [--details]");
+ OutputController.getLogger().printOutLn(R("CLListDescription"));
}
/**
@@ -134,9 +137,9 @@ public class CommandLine {
Map<String, Setting<String>> all = config.getRaw();
for (String key : all.keySet()) {
Setting<String> value = all.get(key);
- System.out.println(key + ": " + value.getValue());
+ OutputController.getLogger().printOutLn(key + ": " + value.getValue());
if (verbose) {
- System.out.println("\t" + R("CLDescription", value.getDescription()));
+ OutputController.getLogger().printOutLn("\t" + R("CLDescription", value.getDescription()));
}
}
return SUCCESS;
@@ -146,9 +149,9 @@ public class CommandLine {
* Prints help message for the get command
*/
public void printGetHelp() {
- System.out.println(R("Usage"));
- System.out.println(" " + PROGRAM_NAME + " get property-name");
- System.out.println(R("CLGetDescription"));
+ OutputController.getLogger().printOutLn(R("Usage"));
+ OutputController.getLogger().printOutLn(" " + PROGRAM_NAME + " get property-name");
+ OutputController.getLogger().printOutLn(R("CLGetDescription"));
}
/**
@@ -175,10 +178,10 @@ public class CommandLine {
String value = null;
if (all.containsKey(key)) {
value = all.get(key).getValue();
- System.out.println(value);
+ OutputController.getLogger().printOutLn(value);
return SUCCESS;
} else {
- System.out.println(R("CLUnknownProperty", key));
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, R("CLUnknownProperty", key));
return ERROR;
}
}
@@ -187,9 +190,9 @@ public class CommandLine {
* Prints the help message for the 'set' command
*/
public void printSetHelp() {
- System.out.println(R("Usage"));
- System.out.println(" " + PROGRAM_NAME + " set property-name value");
- System.out.println(R("CLSetDescription"));
+ OutputController.getLogger().printOutLn(R("Usage"));
+ OutputController.getLogger().printOutLn(" " + PROGRAM_NAME + " set property-name value");
+ OutputController.getLogger().printOutLn(R("CLSetDescription"));
}
/**
@@ -219,20 +222,21 @@ public class CommandLine {
try {
old.getValidator().validate(value);
} catch (IllegalArgumentException e) {
- System.out.println(R("CLIncorrectValue", old.getName(), value, old.getValidator().getPossibleValues()));
+ OutputController.getLogger().log(OutputController.Level.WARNING_ALL, R("CLIncorrectValue", old.getName(), value, old.getValidator().getPossibleValues()));
+ OutputController.getLogger().log(e);
return ERROR;
}
}
config.setProperty(key, value);
} else {
- System.out.println(R("CLWarningUnknownProperty", key));
+ OutputController.getLogger().printOutLn(R("CLWarningUnknownProperty", key));
config.setProperty(key, value);
}
try {
config.save();
} catch (IOException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
return ERROR;
}
@@ -243,9 +247,9 @@ public class CommandLine {
* Prints a help message for the reset command
*/
public void printResetHelp() {
- System.out.println(R("Usage"));
- System.out.println(" " + PROGRAM_NAME + " reset [all|property-name]");
- System.out.println(R("CLResetDescription"));
+ OutputController.getLogger().printOutLn(R("Usage"));
+ OutputController.getLogger().printOutLn(" " + PROGRAM_NAME + " reset [all|property-name]");
+ OutputController.getLogger().printOutLn(R("CLResetDescription"));
}
/**
@@ -275,7 +279,7 @@ public class CommandLine {
Map<String, Setting<String>> all = config.getRaw();
if (!resetAll && !all.containsKey(key)) {
- System.out.println(R("CLUnknownProperty", key));
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, R("CLUnknownProperty", key));
return ERROR;
}
@@ -292,7 +296,7 @@ public class CommandLine {
try {
config.save();
} catch (IOException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
return ERROR;
}
@@ -303,9 +307,9 @@ public class CommandLine {
* Print a help message for the 'info' command
*/
public void printInfoHelp() {
- System.out.println(R("Usage"));
- System.out.println(" " + PROGRAM_NAME + " info property-name");
- System.out.println(R("CLInfoDescription"));
+ OutputController.getLogger().printOutLn(R("Usage"));
+ OutputController.getLogger().printOutLn(" " + PROGRAM_NAME + " info property-name");
+ OutputController.getLogger().printOutLn(R("CLInfoDescription"));
}
/**
@@ -331,15 +335,15 @@ public class CommandLine {
String key = args.get(0);
Setting<String> value = all.get(key);
if (value == null) {
- System.out.println(R("CLNoInfo"));
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, R("CLNoInfo"));
return ERROR;
} else {
- System.out.println(R("CLDescription", value.getDescription()));
- System.out.println(R("CLValue", value.getValue()));
+ OutputController.getLogger().printOutLn(R("CLDescription", value.getDescription()));
+ OutputController.getLogger().printOutLn(R("CLValue", value.getValue()));
if (value.getValidator() != null) {
- System.out.println("\t" + R("VVPossibleValues", value.getValidator().getPossibleValues()));
+ OutputController.getLogger().printOutLn("\t" + R("VVPossibleValues", value.getValidator().getPossibleValues()));
}
- System.out.println(R("CLValueSource", value.getSource()));
+ OutputController.getLogger().printOutLn(R("CLValueSource", value.getSource()));
return SUCCESS;
}
}
@@ -348,9 +352,9 @@ public class CommandLine {
* Prints a help message for the 'check' command
*/
public void printCheckHelp() {
- System.out.println(R("Usage"));
- System.out.println(" " + PROGRAM_NAME + " check");
- System.out.println(R("CLCheckDescription"));
+ OutputController.getLogger().printOutLn(R("Usage"));
+ OutputController.getLogger().printOutLn(" " + PROGRAM_NAME + " check");
+ OutputController.getLogger().printOutLn(R("CLCheckDescription"));
}
/**
@@ -378,17 +382,17 @@ public class CommandLine {
boolean allValid = true;
for (Setting<String> setting : validator.getIncorrectSetting()) {
- System.out.println(R("CLIncorrectValue", setting.getName(), setting.getValue(), setting.getValidator().getPossibleValues()));
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, R("CLIncorrectValue", setting.getName(), setting.getValue(), setting.getValidator().getPossibleValues()));
allValid = false;
}
for (Setting<String> setting : validator.getUnrecognizedSetting()) {
- System.out.println(R("CLUnknownProperty", setting.getName()));
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, R("CLUnknownProperty", setting.getName()));
allValid = false;
}
if (allValid) {
- System.out.println(R("CLNoIssuesFound"));
+ OutputController.getLogger().printOutLn(R("CLNoIssuesFound"));
return SUCCESS;
} else {
return ERROR;
@@ -437,10 +441,10 @@ public class CommandLine {
} else if (command.equals("check")) {
val = handleCheckCommand(arguments);
} else if (allCommands.contains(command)) {
- System.out.println("INTERNAL ERROR: " + command + " should have been implemented");
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "INTERNAL ERROR: " + command + " should have been implemented");
val = ERROR;
} else {
- System.out.println(R("CLUnknownCommand", command));
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, R("CLUnknownCommand", command));
handleHelpCommand(new ArrayList<String>());
val = ERROR;
}
@@ -460,10 +464,10 @@ public class CommandLine {
CommandLine cli = new CommandLine();
int result = cli.handle(args);
- // instead of returning, use System.exit() so we can pass back
+ // instead of returning, use JNLPRuntime.exit() so we can pass back
// error codes indicating success or failure. Otherwise using
// this program for scripting will become much more challenging
- System.exit(result);
+ JNLPRuntime.exit(result);
}
}
}
diff --git a/netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java b/netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java
index d118301..e3fa2db 100644
--- a/netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java
+++ b/netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java
@@ -58,6 +58,7 @@ import net.sourceforge.jnlp.runtime.Translator;
import net.sourceforge.jnlp.security.KeyStores;
import net.sourceforge.jnlp.security.viewer.CertificatePane;
import net.sourceforge.jnlp.util.ImageResources;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* This is the control panel for Java. It provides a GUI for modifying the
@@ -149,7 +150,7 @@ public class ControlPanel extends JFrame {
URL imgUrl = cl.getResource("net/sourceforge/jnlp/resources/netx-icon.png");
image.setIcon(new ImageIcon(ImageIO.read(imgUrl)));
} catch (IOException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
JPanel topPanel = new JPanel(new BorderLayout());
@@ -381,7 +382,7 @@ public class ControlPanel extends JFrame {
JLabel label = new JLabel("Not Implemented", icon, SwingConstants.CENTER);
notImplementedPanel.add(label);
} catch (IOException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
return notImplementedPanel;
}
@@ -393,7 +394,7 @@ public class ControlPanel extends JFrame {
try {
config.save();
} catch (IOException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
JOptionPane.showMessageDialog(this, e);
}
}
@@ -410,7 +411,7 @@ public class ControlPanel extends JFrame {
// if configuration is not loaded, we will get NullPointerExceptions
// everywhere
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
try {
diff --git a/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java b/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java
index d84ea04..003f486 100644
--- a/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java
+++ b/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java
@@ -25,15 +25,14 @@ import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
-
import javax.swing.Box;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
-
import net.sourceforge.jnlp.config.DeploymentConfiguration;
import net.sourceforge.jnlp.runtime.Translator;
+import net.sourceforge.jnlp.util.logging.LogConfig;
/**
* This displays the options related to debugging.
@@ -43,12 +42,17 @@ import net.sourceforge.jnlp.runtime.Translator;
*/
public class DebuggingPanel extends NamedBorderPanel implements ItemListener {
- /** List of properties used by this panel */
- public static String[] properties = { "deployment.trace", // Debugging
- "deployment.log", // Debugging
- "deployment.console.startup.mode", // Java Console
+ /** List of properties used by checkboxes in this panel */
+ public static String[] properties = {
+ DeploymentConfiguration.KEY_ENABLE_LOGGING,
+ DeploymentConfiguration.KEY_ENABLE_LOGGING_HEADERS,
+ DeploymentConfiguration.KEY_ENABLE_LOGGING_TOFILE,
+ DeploymentConfiguration.KEY_ENABLE_LOGGING_TOSTREAMS,
+ DeploymentConfiguration.KEY_ENABLE_LOGGING_TOSYSTEMLOG
+
};
- private DeploymentConfiguration config;
+
+ private DeploymentConfiguration config;
/**
* Create a new instance of the debugging panel.
@@ -72,8 +76,20 @@ public class DebuggingPanel extends NamedBorderPanel implements ItemListener {
JLabel debuggingDescription = new JLabel("<html>" + Translator.R("CPDebuggingDescription") + "<hr /><br /></html>");
- JCheckBox[] debuggingOptions = { new JCheckBox(Translator.R("DPEnableTracing")),
- new JCheckBox(Translator.R("DPEnableLogging")), };
+ JCheckBox[] debuggingOptions = {
+ new JCheckBox(Translator.R("DPEnableLogging")),
+ new JCheckBox(Translator.R("DPEnableHeaders")),
+ new JCheckBox(Translator.R("DPEnableFile")),
+ new JCheckBox(Translator.R("DPEnableStds")),
+ new JCheckBox(Translator.R("DPEnableSyslog"))
+ };
+ String[] hints = {
+ (Translator.R("DPEnableLoggingHint")),
+ (Translator.R("DPEnableHeadersHint")),
+ (Translator.R("DPEnableFileHint", LogConfig.getLogConfig().getIcedteaLogDir())),
+ (Translator.R("DPEnableStdsHint")),
+ (Translator.R("DPEnableSyslogHint"))
+ };
ComboItem[] javaConsoleItems = { new ComboItem(Translator.R("DPDisable"), "DISABLE"),
new ComboItem(Translator.R("DPHide"), "HIDE"),
@@ -81,7 +97,7 @@ public class DebuggingPanel extends NamedBorderPanel implements ItemListener {
JLabel consoleLabel = new JLabel(Translator.R("DPJavaConsole"));
JComboBox consoleComboBox = new JComboBox();
- consoleComboBox.setActionCommand("deployment.console.startup.mode"); // The property this comboBox affects.
+ consoleComboBox.setActionCommand(DeploymentConfiguration.KEY_CONSOLE_STARTUP_MODE); // The property this comboBox affects.
JPanel consolePanel = new JPanel();
consolePanel.setLayout(new FlowLayout(FlowLayout.LEADING));
@@ -98,33 +114,33 @@ public class DebuggingPanel extends NamedBorderPanel implements ItemListener {
* Add the items to the panel unless we can not get the values for them.
*/
for (int i = 0; i < properties.length; i++) {
- try {
- String s = config.getProperty(properties[i]);
- c.gridy = i + 1;
-
- switch (i) {
- case 0:
- case 1:
- debuggingOptions[i].setSelected(Boolean.parseBoolean(s));
- debuggingOptions[i].setActionCommand(properties[i]);
- debuggingOptions[i].addItemListener(this);
- add(debuggingOptions[i], c);
- break;
- case 2:
- for (int j = 0; j < javaConsoleItems.length; j++) {
- consoleComboBox.addItem(javaConsoleItems[j]);
- if (config.getProperty("deployment.console.startup.mode").equals(javaConsoleItems[j].getValue()))
- consoleComboBox.setSelectedIndex(j);
- }
- consoleComboBox.addItemListener(this);
- add(consolePanel, c);
- }
-
- } catch (Exception e) {
- debuggingOptions[i] = null;
+ String s = config.getProperty(properties[i]);
+ c.gridy++;
+ if (i == 2) {
+ JLabel space = new JLabel("<html>" + Translator.R("CPDebuggingPossibilites") + ":</html>");
+ add(space, c);
+ c.gridy++;
}
+
+ debuggingOptions[i].setSelected(Boolean.parseBoolean(s));
+ debuggingOptions[i].setActionCommand(properties[i]);
+ debuggingOptions[i].setToolTipText(hints[i]);
+ debuggingOptions[i].addItemListener(this);
+ add(debuggingOptions[i], c);
+
+
}
+ for (int j = 0; j < javaConsoleItems.length; j++) {
+ consoleComboBox.addItem(javaConsoleItems[j]);
+ if (config.getProperty(DeploymentConfiguration.KEY_CONSOLE_STARTUP_MODE).equals(javaConsoleItems[j].getValue())) {
+ consoleComboBox.setSelectedIndex(j);
+ }
+ }
+ c.gridy++;
+ consoleComboBox.addItemListener(this);
+ add(consolePanel, c);
+
// pack the bottom so that it doesn't change size if resized.
Component filler = Box.createRigidArea(new Dimension(1, 1));
c.gridy++;
diff --git a/netx/net/sourceforge/jnlp/controlpanel/DocumentAdapter.java b/netx/net/sourceforge/jnlp/controlpanel/DocumentAdapter.java
index 2bcb0c2..7d6cd7c 100644
--- a/netx/net/sourceforge/jnlp/controlpanel/DocumentAdapter.java
+++ b/netx/net/sourceforge/jnlp/controlpanel/DocumentAdapter.java
@@ -23,6 +23,7 @@ import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import net.sourceforge.jnlp.config.DeploymentConfiguration;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* Updates the property as it happens.
@@ -94,8 +95,7 @@ public class DocumentAdapter implements DocumentListener {
config.setProperty(property, value);
}
} catch (BadLocationException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e1);
}
}
diff --git a/netx/net/sourceforge/jnlp/controlpanel/JVMPanel.java b/netx/net/sourceforge/jnlp/controlpanel/JVMPanel.java
index 9f1dd52..9118973 100644
--- a/netx/net/sourceforge/jnlp/controlpanel/JVMPanel.java
+++ b/netx/net/sourceforge/jnlp/controlpanel/JVMPanel.java
@@ -55,6 +55,7 @@ import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
import net.sourceforge.jnlp.config.DeploymentConfiguration;
import net.sourceforge.jnlp.runtime.Translator;
+import net.sourceforge.jnlp.util.logging.OutputController;
import net.sourceforge.jnlp.util.StreamUtils;
@SuppressWarnings("serial")
@@ -254,12 +255,12 @@ public class JVMPanel extends NamedBorderPanel {
processErrorStream = StreamUtils.readStreamAsString(p.getErrorStream());
processStdOutStream = StreamUtils.readStreamAsString(p.getInputStream());
r = p.exitValue();
- System.err.println(processErrorStream);
- System.out.println(processStdOutStream);
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, processErrorStream);
+ OutputController.getLogger().log(processStdOutStream);
processErrorStream = processErrorStream.toLowerCase();
processStdOutStream = processStdOutStream.toLowerCase();
} catch (Exception ex) {;
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
}
if (r == null) {
diff --git a/netx/net/sourceforge/jnlp/controlpanel/UnsignedAppletsTrustingListPanel.java b/netx/net/sourceforge/jnlp/controlpanel/UnsignedAppletsTrustingListPanel.java
index 60a27ee..1cb38af 100644
--- a/netx/net/sourceforge/jnlp/controlpanel/UnsignedAppletsTrustingListPanel.java
+++ b/netx/net/sourceforge/jnlp/controlpanel/UnsignedAppletsTrustingListPanel.java
@@ -81,6 +81,7 @@ import net.sourceforge.jnlp.security.appletextendedsecurity.ExtendedAppletSecuri
import net.sourceforge.jnlp.security.appletextendedsecurity.UnsignedAppletActionEntry;
import net.sourceforge.jnlp.security.appletextendedsecurity.UrlRegEx;
import net.sourceforge.jnlp.security.appletextendedsecurity.impl.UnsignedAppletActionStorageExtendedImpl;
+import net.sourceforge.jnlp.util.logging.OutputController;
import net.sourceforge.jnlp.util.ScreenFinder;
public class UnsignedAppletsTrustingListPanel extends javax.swing.JPanel {
@@ -143,7 +144,7 @@ public class UnsignedAppletsTrustingListPanel extends javax.swing.JPanel {
f.add(new UnsignedAppletsTrustingListPanel(ff2, ff1, cc));
f.setVisible(true);
} catch (Exception ex) {
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
}
}
});
@@ -511,7 +512,7 @@ public class UnsignedAppletsTrustingListPanel extends javax.swing.JPanel {
conf.setProperty(DeploymentConfiguration.KEY_SECURITY_LEVEL, ((AppletSecurityLevel) mainPolicyComboBox.getSelectedItem()).toChars());
conf.save();
} catch (Exception ex) {
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
JOptionPane.showMessageDialog(this, ex);
}
}
@@ -552,7 +553,7 @@ public class UnsignedAppletsTrustingListPanel extends javax.swing.JPanel {
JOptionPane.showMessageDialog(this, Translator.R("APPEXTSECguiPanelMatchingNote") + "\n" + appletItemsToCaption(i, Translator.R("APPEXTSECguiPanelMatched") + ": "));
}
} catch (Exception ex) {
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
JOptionPane.showMessageDialog(this, Translator.R("APPEXTSECguiPanelMatchingError", ex));
}
@@ -569,7 +570,7 @@ public class UnsignedAppletsTrustingListPanel extends javax.swing.JPanel {
try {
f = File.createTempFile("appletTable", "validation");
} catch (Exception ex) {
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
JOptionPane.showMessageDialog(this, Translator.R("APPEXTSECguiPanelCanNOtValidate", ex.toString()));
return;
}
@@ -600,7 +601,7 @@ public class UnsignedAppletsTrustingListPanel extends javax.swing.JPanel {
}
JOptionPane.showMessageDialog(this, Translator.R("APPEXTSECguiPanelTableValid"));
} catch (Exception ex) {
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
JOptionPane.showMessageDialog(this, Translator.R("APPEXTSECguiPanelTableInvalid ", ex.toString()));
} finally {
f.delete();
@@ -645,7 +646,7 @@ public class UnsignedAppletsTrustingListPanel extends javax.swing.JPanel {
break;
}
}
- //System.out.println(+orig+" "+i+" "+nwx+" "+nw+" ");
+ //ItwLogger.getLogger().log(OutputController.Level.ERROR_ALL, orig+" "+i+" "+nwx+" "+nw+" ");
if (nw != orig) {
if (orig >= 1) {
currentTable.getSelectionModel().setSelectionInterval(orig - 1, orig - 1);
@@ -673,7 +674,7 @@ public class UnsignedAppletsTrustingListPanel extends javax.swing.JPanel {
break;
}
}
- // System.out.println(+orig+" "+i+" "+nwx+" "+nw+" ");
+ // OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, orig+" "+i+" "+nwx+" "+nw+" ");
if (nw != orig) {
if (orig < currentModel.getRowCount()) {
currentTable.getSelectionModel().setSelectionInterval(orig + 1, orig + 1);
diff --git a/netx/net/sourceforge/jnlp/resources/Messages.properties b/netx/net/sourceforge/jnlp/resources/Messages.properties
index fbe194f..8f1050a 100644
--- a/netx/net/sourceforge/jnlp/resources/Messages.properties
+++ b/netx/net/sourceforge/jnlp/resources/Messages.properties
@@ -401,8 +401,17 @@ APSExceptionsDescription=Do not use proxy server for addresses beginning with
APSExceptionInstruction=Separate each entry with a semicolon.
# Control Panel - DebugginPanel
-DPEnableTracing=Enable tracing
+CPDebuggingPossibilites=Logging outputs
DPEnableLogging=Enable logging
+DPEnableLoggingHint=When this switch is on, then also debug messages are logged. Same as -verbose or ICEDTEAPLUGIN_DEBUG=true
+DPEnableHeaders=Enable headers
+DPEnableHeadersHint=When this switch is on, each logged message have header with additional information like user, place in code and time
+DPEnableFile=Enable logging to file
+DPEnableFileHint=output messages will be saved to file in your {0} directory
+DPEnableStds=Enable logging to standard outputs
+DPEnableStdsHint=messages will be printed to standard outputs
+DPEnableSyslog=Enable logging to system logs
+DPEnableSyslogHint=output messages will be saved to system logs
DPDisable=Disable
DPHide=Hide on startup
DPShow=Show on startup
diff --git a/netx/net/sourceforge/jnlp/resources/Messages_cs.properties b/netx/net/sourceforge/jnlp/resources/Messages_cs.properties
index 411377e..1881df7 100644
--- a/netx/net/sourceforge/jnlp/resources/Messages_cs.properties
+++ b/netx/net/sourceforge/jnlp/resources/Messages_cs.properties
@@ -388,7 +388,6 @@ APSExceptionsDescription=Nepou\u017e\u00edvat proxy server pro adresy za\u010d\u
APSExceptionInstruction=Odd\u011blte ka\u017edou polo\u017eku st\u0159edn\u00edkem.
# Control Panel - DebugginPanel
-DPEnableTracing=Zapnout trasov\u00e1n\u00ed
DPEnableLogging=Zapnout protokolov\u00e1n\u00ed
DPDisable=Vypnout
DPHide=Skr\u00fdt p\u0159i spou\u0161t\u011bn\u00ed
diff --git a/netx/net/sourceforge/jnlp/resources/Messages_de.properties b/netx/net/sourceforge/jnlp/resources/Messages_de.properties
index ba1f30c..36d1d4f 100644
--- a/netx/net/sourceforge/jnlp/resources/Messages_de.properties
+++ b/netx/net/sourceforge/jnlp/resources/Messages_de.properties
@@ -396,7 +396,6 @@ APSExceptionsDescription=Keinen Proxyserver f\u00fcr Adressen verwenden, die dam
APSExceptionInstruction=Trennen Sie jeden Eintrag mit einem Semikolon (;).
# Control Panel - DebugginPanel
-DPEnableTracing=Ablaufverfolgung aktivieren
DPEnableLogging=Protokollierung aktivieren
DPDisable=Deaktivieren
DPHide=Beim Start verbergen
diff --git a/netx/net/sourceforge/jnlp/resources/Messages_pl.properties b/netx/net/sourceforge/jnlp/resources/Messages_pl.properties
index e54f4a8..ec5be2d 100644
--- a/netx/net/sourceforge/jnlp/resources/Messages_pl.properties
+++ b/netx/net/sourceforge/jnlp/resources/Messages_pl.properties
@@ -396,7 +396,6 @@ APSExceptionsDescription=Nie stosuj serwera proxy dla adres\u00f3w zaczynaj\u010
APSExceptionInstruction=Odgradzaj ka\u017cd\u0105 pozycj\u0119 \u015brednikiem (;).
# Control Panel - DebugginPanel
-DPEnableTracing=W\u0142\u0105cz \u015bledzenie
DPEnableLogging=W\u0142\u0105cz protoko\u0142owanie
DPDisable=Wy\u0142\u0105cz
DPHide=Ukrywaj na starcie
diff --git a/netx/net/sourceforge/jnlp/runtime/AppletAudioClip.java b/netx/net/sourceforge/jnlp/runtime/AppletAudioClip.java
index 4dd1a79..5aec6d2 100644
--- a/netx/net/sourceforge/jnlp/runtime/AppletAudioClip.java
+++ b/netx/net/sourceforge/jnlp/runtime/AppletAudioClip.java
@@ -19,6 +19,7 @@ package net.sourceforge.jnlp.runtime;
import java.net.*;
import java.applet.*;
import javax.sound.sampled.*;
+import net.sourceforge.jnlp.util.logging.OutputController;
// based on Deane Richan's AppletAudioClip
@@ -47,7 +48,8 @@ public class AppletAudioClip implements AudioClip {
clip = (Clip) AudioSystem.getLine(new Line.Info(Clip.class));
clip.open(stream);
} catch (Exception ex) {
- System.err.println("Error loading sound:" + location.toString());
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Error loading sound:" + location.toString());
+ OutputController.getLogger().log(ex);
clip = null;
}
}
diff --git a/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java b/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java
index 8e89530..17e9d14 100644
--- a/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java
+++ b/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java
@@ -16,6 +16,7 @@
package net.sourceforge.jnlp.runtime;
+import net.sourceforge.jnlp.util.logging.OutputController;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
@@ -90,7 +91,7 @@ public class AppletEnvironment implements AppletContext, AppletStub {
WindowListener closer = new WindowAdapter() {
public void windowClosing(WindowEvent event) {
appletInstance.destroy();
- System.exit(0);
+ JNLPRuntime.exit(0);
}
};
frame.addWindowListener(closer);
@@ -194,8 +195,7 @@ public class AppletEnvironment implements AppletContext, AppletStub {
}
} catch (Exception ex) {
- if (JNLPRuntime.isDebug())
- ex.printStackTrace();
+ OutputController.getLogger().log(ex);
// should also kill the applet?
}
@@ -221,10 +221,7 @@ public class AppletEnvironment implements AppletContext, AppletStub {
*/
public void setApplet(Applet applet) {
if (this.applet != null) {
- if (JNLPRuntime.isDebug()) {
- Exception ex = new IllegalStateException("Applet can only be set once.");
- ex.printStackTrace();
- }
+ OutputController.getLogger().log(new IllegalStateException("Applet can only be set once."));
return;
}
this.applet = applet;
diff --git a/netx/net/sourceforge/jnlp/runtime/AppletInstance.java b/netx/net/sourceforge/jnlp/runtime/AppletInstance.java
index 1f08817..757a9f7 100644
--- a/netx/net/sourceforge/jnlp/runtime/AppletInstance.java
+++ b/netx/net/sourceforge/jnlp/runtime/AppletInstance.java
@@ -20,6 +20,7 @@ import java.applet.*;
import java.awt.*;
import net.sourceforge.jnlp.*;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* Represents a launched application instance created from a JNLP
@@ -56,10 +57,7 @@ public class AppletInstance extends ApplicationInstance {
*/
public void setApplet(Applet applet) {
if (this.applet != null) {
- if (JNLPRuntime.isDebug()) {
- Exception ex = new IllegalStateException("Applet can only be set once.");
- ex.printStackTrace();
- }
+ OutputController.getLogger().log(new IllegalStateException("Applet can only be set once."));
return;
}
this.applet = applet;
@@ -129,8 +127,7 @@ public class AppletInstance extends ApplicationInstance {
applet.stop();
applet.destroy();
} catch (Exception ex) {
- if (JNLPRuntime.isDebug())
- ex.printStackTrace();
+ OutputController.getLogger().log(ex);
}
environment.destroy();
diff --git a/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java b/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
index f74cce6..4d38be4 100644
--- a/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
+++ b/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
@@ -38,6 +38,7 @@ import net.sourceforge.jnlp.event.ApplicationEvent;
import net.sourceforge.jnlp.event.ApplicationListener;
import net.sourceforge.jnlp.security.SecurityDialogs;
import net.sourceforge.jnlp.security.SecurityDialogs.AccessType;
+import net.sourceforge.jnlp.util.logging.OutputController;
import net.sourceforge.jnlp.util.WeakList;
import net.sourceforge.jnlp.util.XDesktopEntry;
@@ -149,10 +150,8 @@ public class ApplicationInstance {
ShortcutDesc sd = file.getInformation().getShortcut();
File possibleDesktopFile = entry.getLinuxDesktopIconFile();
if (possibleDesktopFile.exists()) {
- if (JNLPRuntime.isDebug()) {
- System.out.println("ApplicationInstance.addMenuAndDesktopEntries(): file - "
- + possibleDesktopFile.getAbsolutePath() + " already exists. Not proceeding with desktop additions");
- }
+ OutputController.getLogger().log("ApplicationInstance.addMenuAndDesktopEntries(): file - "
+ + possibleDesktopFile.getAbsolutePath() + " already exists. Not proceeding with desktop additions");
return;
}
if (shouldCreateShortcut(sd)) {
@@ -163,10 +162,8 @@ public class ApplicationInstance {
/*
* Sun's WebStart implementation doesnt seem to do anything under GNOME
*/
- if (JNLPRuntime.isDebug()) {
- System.err.println("ApplicationInstance.addMenuAndDesktopEntries():"
- + " Adding menu entries NOT IMPLEMENTED");
- }
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "ApplicationInstance.addMenuAndDesktopEntries():"
+ + " Adding menu entries NOT IMPLEMENTED");
}
}
@@ -218,7 +215,7 @@ public class ApplicationInstance {
* Only collectable if classloader and thread group are
* also collectable so basically is almost never called (an
* application would have to close its windows and exit its
- * threads but not call System.exit).
+ * threads but not call JNLPRuntime.exit).
*/
public void finalize() {
destroy();
@@ -294,9 +291,7 @@ public class ApplicationInstance {
Thread threads[] = new Thread[group.activeCount() * 2];
int nthreads = group.enumerate(threads);
for (int i = 0; i < nthreads; i++) {
- if (JNLPRuntime.isDebug())
- System.out.println("Interrupt thread: " + threads[i]);
-
+ OutputController.getLogger().log("Interrupt thread: " + threads[i]);
threads[i].interrupt();
}
@@ -304,9 +299,7 @@ public class ApplicationInstance {
Thread.currentThread().yield();
nthreads = group.enumerate(threads);
for (int i = 0; i < nthreads; i++) {
- if (JNLPRuntime.isDebug())
- System.out.println("Stop thread: " + threads[i]);
-
+ OutputController.getLogger().log("Stop thread: " + threads[i]);
threads[i].stop();
}
diff --git a/netx/net/sourceforge/jnlp/runtime/Boot.java b/netx/net/sourceforge/jnlp/runtime/Boot.java
index 81d19c1..3f774cf 100644
--- a/netx/net/sourceforge/jnlp/runtime/Boot.java
+++ b/netx/net/sourceforge/jnlp/runtime/Boot.java
@@ -37,6 +37,7 @@ import net.sourceforge.jnlp.cache.UpdatePolicy;
import net.sourceforge.jnlp.config.DeploymentConfiguration;
import net.sourceforge.jnlp.security.viewer.CertificateViewer;
import net.sourceforge.jnlp.services.ServiceUtil;
+import net.sourceforge.jnlp.util.logging.OutputController;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
@@ -133,30 +134,29 @@ public final class Boot implements PrivilegedAction<Void> {
try {
CertificateViewer.main(null);
- System.exit(0);
+ JNLPRuntime.exit(0);
} catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
}
if (null != getOption("-license")) {
- System.out.println(miniLicense);
- System.exit(0);
+ OutputController.getLogger().printOutLn(miniLicense);
+ JNLPRuntime.exit(0);
}
if (null != getOption("-help")) {
- System.out.println(helpMessage);
- System.exit(0);
+ OutputController.getLogger().printOutLn(helpMessage);
+ JNLPRuntime.exit(0);
}
if (null != getOption("-about")) {
- System.out.println(itwInfoMessage);
+ OutputController.getLogger().printOutLn(itwInfoMessage);
if (null != getOption("-headless")) {
- System.exit(0);
+ JNLPRuntime.exit(0);
} else {
- System.out.println(R("BLaunchAbout"));
+ OutputController.getLogger().printOutLn(R("BLaunchAbout"));
AboutDialog.display();
return;
}
@@ -225,9 +225,7 @@ public final class Boot implements PrivilegedAction<Void> {
} catch (LaunchException ex) {
// default handler prints this
} catch (Exception ex) {
- if (JNLPRuntime.isDebug())
- ex.printStackTrace();
-
+ OutputController.getLogger().log(ex);
fatalError(R("RUnexpected", ex.toString(), ex.getStackTrace()[0]));
}
@@ -235,8 +233,8 @@ public final class Boot implements PrivilegedAction<Void> {
}
private static void fatalError(String message) {
- System.err.println("netx: " + message);
- System.exit(1);
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "netx: " + message);
+ JNLPRuntime.exit(1);
}
/**
@@ -248,12 +246,11 @@ public final class Boot implements PrivilegedAction<Void> {
String location = getJNLPFile();
if (location == null) {
- System.out.println(helpMessage);
- System.exit(1);
+ OutputController.getLogger().printOutLn(helpMessage);
+ JNLPRuntime.exit(1);
}
- if (JNLPRuntime.isDebug())
- System.out.println(R("BFileLoc") + ": " + location);
+ OutputController.getLogger().log(R("BFileLoc") + ": " + location);
URL url = null;
@@ -264,9 +261,8 @@ public final class Boot implements PrivilegedAction<Void> {
else
url = new URL(ServiceUtil.getBasicService().getCodeBase(), location);
} catch (Exception e) {
+ OutputController.getLogger().log(e);
fatalError("Invalid jnlp file " + location);
- if (JNLPRuntime.isDebug())
- e.printStackTrace();
}
return url;
@@ -278,8 +274,8 @@ public final class Boot implements PrivilegedAction<Void> {
private static String getJNLPFile() {
if (args.length == 0) {
- System.out.println(helpMessage);
- System.exit(0);
+ OutputController.getLogger().printOutLn(helpMessage);
+ JNLPRuntime.exit(0);
} else if (args.length == 1) {
return args[args.length - 1];
} else {
@@ -289,8 +285,8 @@ public final class Boot implements PrivilegedAction<Void> {
if (doubleArgs.indexOf(secondLastArg) == -1) {
return lastArg;
} else {
- System.out.println(helpMessage);
- System.exit(0);
+ OutputController.getLogger().printOutLn(helpMessage);
+ JNLPRuntime.exit(0);
}
}
return null;
diff --git a/netx/net/sourceforge/jnlp/runtime/CachedJarFileCallback.java b/netx/net/sourceforge/jnlp/runtime/CachedJarFileCallback.java
index 7824881..960d9ca 100644
--- a/netx/net/sourceforge/jnlp/runtime/CachedJarFileCallback.java
+++ b/netx/net/sourceforge/jnlp/runtime/CachedJarFileCallback.java
@@ -49,6 +49,7 @@ import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import net.sourceforge.jnlp.util.logging.OutputController;
import net.sourceforge.jnlp.util.JarFile;
import net.sourceforge.jnlp.util.UrlUtils;
@@ -103,9 +104,8 @@ final class CachedJarFileCallback implements URLJarFileCallBack {
// 2) For the plug-in, we want to cache files from class-path so we do it manually
returnFile.getManifest().getMainAttributes().putValue("Class-Path", "");
- if (JNLPRuntime.isDebug()) {
- System.err.println("Class-Path attribute cleared for " + returnFile.getName());
- }
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Class-Path attribute cleared for " + returnFile.getName());
+
} catch (NullPointerException npe) {
// Discard NPE here. Maybe there was no manifest, maybe there were no attributes, etc.
diff --git a/netx/net/sourceforge/jnlp/runtime/FakePacEvaluator.java b/netx/net/sourceforge/jnlp/runtime/FakePacEvaluator.java
index 98ff9d1..5d79344 100644
--- a/netx/net/sourceforge/jnlp/runtime/FakePacEvaluator.java
+++ b/netx/net/sourceforge/jnlp/runtime/FakePacEvaluator.java
@@ -39,6 +39,7 @@ package net.sourceforge.jnlp.runtime;
import static net.sourceforge.jnlp.runtime.Translator.R;
import java.net.URL;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* A dummy PacEvaluator that always returns "DIRECT"
@@ -46,9 +47,7 @@ import java.net.URL;
public class FakePacEvaluator implements PacEvaluator {
@Override
public String getProxies(URL url) {
- if (JNLPRuntime.isDebug()) {
- System.err.println(R("RPRoxyPacNotSupported"));
- }
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, R("RPRoxyPacNotSupported"));
return "DIRECT";
}
}
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
index 4efa435..c387b35 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
@@ -92,6 +92,7 @@ import net.sourceforge.jnlp.security.PluginAppVerifier;
import net.sourceforge.jnlp.security.SecurityDialogs;
import net.sourceforge.jnlp.tools.JarCertVerifier;
import net.sourceforge.jnlp.util.FileUtils;
+import net.sourceforge.jnlp.util.logging.OutputController;
import net.sourceforge.jnlp.util.StreamUtils;
import sun.misc.JarIndex;
@@ -223,8 +224,7 @@ public class JNLPClassLoader extends URLClassLoader {
protected JNLPClassLoader(JNLPFile file, UpdatePolicy policy, String mainName) throws LaunchException {
super(new URL[0], JNLPClassLoader.class.getClassLoader());
- if (JNLPRuntime.isDebug())
- System.out.println("New classloader: " + file.getFileLocation());
+ OutputController.getLogger().log("New classloader: " + file.getFileLocation());
this.file = file;
this.updatePolicy = policy;
@@ -508,7 +508,7 @@ public class JNLPClassLoader extends URLClassLoader {
JNLPClassLoader loader = getInstance(ext[i].getLocation(), uniqueKey, ext[i].getVersion(), file.getParserSettings(), updatePolicy, mainClass);
loaderList.add(loader);
} catch (Exception ex) {
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
}
}
//}
@@ -527,11 +527,10 @@ public class JNLPClassLoader extends URLClassLoader {
Permission p = CacheUtil.getReadPermission(jars[i].getLocation(),
jars[i].getVersion());
- if (JNLPRuntime.isDebug()) {
- if (p == null)
- System.out.println("Unable to add permission for " + jars[i].getLocation());
- else
- System.out.println("Permission added: " + p.toString());
+ if (p == null) {
+ OutputController.getLogger().log("Unable to add permission for " + jars[i].getLocation());
+ } else {
+ OutputController.getLogger().log("Permission added: " + p.toString());
}
if (p != null)
resourcePermissions.add(p);
@@ -583,8 +582,8 @@ public class JNLPClassLoader extends URLClassLoader {
try {
addToCodeBaseLoader(new URL(file.getCodeBase(), codeBaseFolder));
} catch (MalformedURLException mfe) {
- System.err.println("Problem trying to add folder to code base:");
- System.err.println(mfe.getMessage());
+ OutputController.getLogger().log(OutputController.Level.WARNING_ALL, "Problem trying to add folder to code base:");
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, mfe);
}
}
}
@@ -663,7 +662,7 @@ public class JNLPClassLoader extends URLClassLoader {
//we caught an Exception from the JarCertVerifier class.
//Note: one of these exceptions could be from not being able
//to read the cacerts or trusted.certs files.
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
throw new LaunchException(null, null, R("LSFatal"),
R("LCInit"), R("LFatalVerification"), R("LFatalVerificationInfo") + ": " +e.getMessage());
}
@@ -727,12 +726,12 @@ public class JNLPClassLoader extends URLClassLoader {
cachedFile = tracker.getCacheFile(jarDesc.getLocation());
} catch (IllegalResourceDescriptorException irde){
//Caused by ignored resource being removed due to not being valid
- System.err.println("JAR " + jarDesc.getLocation() + " is not a valid jar file. Continuing.");
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "JAR " + jarDesc.getLocation() + " is not a valid jar file. Continuing.");
continue;
}
if (cachedFile == null) {
- System.err.println("JAR " + jarDesc.getLocation() + " not found. Continuing.");
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "JAR " + jarDesc.getLocation() + " not found. Continuing.");
continue; // JAR not found. Keep going.
}
@@ -765,7 +764,7 @@ public class JNLPClassLoader extends URLClassLoader {
jarLocationSecurityMap.put(jarDesc.getLocation(), jarSecurity);
} catch (MalformedURLException mfe) {
- System.err.println(mfe.getMessage());
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, mfe);
}
}
activateJars(initialJars);
@@ -832,7 +831,7 @@ public class JNLPClassLoader extends URLClassLoader {
.getCacheFile(jars.get(i).getLocation());
if (localFile == null) {
- System.err.println("JAR " + jars.get(i).getLocation() + " not found. Continuing.");
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "JAR " + jars.get(i).getLocation() + " not found. Continuing.");
continue; // JAR not found. Keep going.
}
@@ -942,14 +941,12 @@ public class JNLPClassLoader extends URLClassLoader {
if (jeName.equals(TEMPLATE) || jeName.equals(APPLICATION)) {
- if (JNLPRuntime.isDebug())
- System.err.println("Creating Jar InputStream from JarEntry");
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Creating Jar InputStream from JarEntry");
inStream = jarFile.getInputStream(je);
inputReader = new InputStreamReader(inStream);
- if (JNLPRuntime.isDebug())
- System.err.println("Creating File InputStream from lauching JNLP file");
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Creating File InputStream from lauching JNLP file");
JNLPFile jnlp = this.getJNLPFile();
URL url = jnlp.getFileLocation();
@@ -968,13 +965,11 @@ public class JNLPClassLoader extends URLClassLoader {
JNLPMatcher matcher;
if (jeName.equals(APPLICATION)) { // If signed application was found
- if (JNLPRuntime.isDebug())
- System.err.println("APPLICATION.JNLP has been located within signed JAR. Starting verfication...");
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "APPLICATION.JNLP has been located within signed JAR. Starting verfication...");
matcher = new JNLPMatcher(inputReader, jnlpReader, false);
} else { // Otherwise template was found
- if (JNLPRuntime.isDebug())
- System.err.println("APPLICATION_TEMPLATE.JNLP has been located within signed JAR. Starting verfication...");
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "APPLICATION_TEMPLATE.JNLP has been located within signed JAR. Starting verfication...");
matcher = new JNLPMatcher(inputReader, jnlpReader,
true);
@@ -985,8 +980,7 @@ public class JNLPClassLoader extends URLClassLoader {
throw new JNLPMatcherException("Signed Application did not match launching JNLP File");
this.isSignedJNLP = true;
- if (JNLPRuntime.isDebug())
- System.err.println("Signed Application Verification Successful");
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Signed Application Verification Successful");
break;
}
@@ -1009,8 +1003,7 @@ public class JNLPClassLoader extends URLClassLoader {
} catch (Exception e) {
- if (JNLPRuntime.isDebug())
- e.printStackTrace(System.err);
+ OutputController.getLogger().log(e);
/*
* After this exception is caught, it is escaped. If an exception is
@@ -1028,8 +1021,7 @@ public class JNLPClassLoader extends URLClassLoader {
StreamUtils.closeSilently(jnlpReader);
}
- if (JNLPRuntime.isDebug())
- System.err.println("Ending check for signed JNLP file...");
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Ending check for signed JNLP file...");
}
/**
@@ -1061,10 +1053,7 @@ public class JNLPClassLoader extends URLClassLoader {
*/
public void setApplication(ApplicationInstance app) {
if (this.app != null) {
- if (JNLPRuntime.isDebug()) {
- Exception ex = new IllegalStateException("Application can only be set once");
- ex.printStackTrace();
- }
+ OutputController.getLogger().log(new IllegalStateException("Application can only be set once"));
return;
}
@@ -1118,9 +1107,7 @@ public class JNLPClassLoader extends URLClassLoader {
throw new NullPointerException("Code source security was null");
}
if (getCodeSourceSecurity(cs.getLocation()).getSecurityType() == null) {
- if (JNLPRuntime.isDebug()){
- new NullPointerException("Warning! Code source security type was null").printStackTrace();
- }
+ OutputController.getLogger().log(new NullPointerException("Warning! Code source security type was null"));
}
Object securityType = getCodeSourceSecurity(cs.getLocation()).getSecurityType();
if (SecurityDesc.ALL_PERMISSIONS.equals(securityType)
@@ -1153,9 +1140,7 @@ public class JNLPClassLoader extends URLClassLoader {
return result;
} catch (RuntimeException ex) {
- if (JNLPRuntime.isDebug()) {
- ex.printStackTrace();
- }
+ OutputController.getLogger().log(ex);
throw ex;
}
}
@@ -1287,10 +1272,8 @@ public class JNLPClassLoader extends URLClassLoader {
jarLocationSecurityMap.put(fakeRemote, jarSecurity);
} catch (MalformedURLException mfue) {
- if (JNLPRuntime.isDebug())
- System.err.println("Unable to add extracted nested jar to classpath");
-
- mfue.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.WARNING_DEBUG, "Unable to add extracted nested jar to classpath");
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, mfue);
}
}
@@ -1327,12 +1310,10 @@ public class JNLPClassLoader extends URLClassLoader {
CachedJarFileCallback.getInstance().addMapping(jar.getLocation(), jar.getLocation());
}
- if (JNLPRuntime.isDebug())
- System.err.println("Activate jar: " + location);
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Activate jar: " + location);
}
catch (Exception ex) {
- if (JNLPRuntime.isDebug())
- ex.printStackTrace();
+ OutputController.getLogger().log(ex);
}
// some programs place a native library in any jar
@@ -1471,9 +1452,7 @@ public class JNLPClassLoader extends URLClassLoader {
result = loadClassExt(name);
return result;
} catch (ClassNotFoundException cnfe1) {
- if (JNLPRuntime.isDebug()) {
- cnfe1.printStackTrace();
- }
+ OutputController.getLogger().log(cnfe1);
}
// As a last resort, look in any available indexes
@@ -1497,9 +1476,7 @@ public class JNLPClassLoader extends URLClassLoader {
try {
addNewJar(desc);
} catch (Exception e) {
- if (JNLPRuntime.isDebug()) {
- e.printStackTrace();
- }
+ OutputController.getLogger().log(e);
}
}
@@ -1604,7 +1581,7 @@ public class JNLPClassLoader extends URLClassLoader {
// throw additional exceptions. So instead, just ignore it.
// Exception => jar will not get added to classpath, which will
// result in CNFE from loadClass.
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
}
@@ -1628,7 +1605,7 @@ public class JNLPClassLoader extends URLClassLoader {
}
} catch (ClassNotFoundException ex) {
} catch (ClassFormatError cfe) {
- cfe.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, cfe);
} catch (PrivilegedActionException pae) {
} catch (NullJnlpFileException ex) {
throw new ClassNotFoundException(this.mainClass + " in main classloader ", ex);
@@ -1702,9 +1679,7 @@ public class JNLPClassLoader extends URLClassLoader {
result = e.nextElement();
}
} catch (IOException e) {
- if (JNLPRuntime.isDebug()) {
- e.printStackTrace();
- }
+ OutputController.getLogger().log(e);
}
// If result is still null, look in the codebase loader
@@ -1728,7 +1703,7 @@ public class JNLPClassLoader extends URLClassLoader {
resources = findResourcesBySearching(name);
}
} catch (LaunchException le) {
- le.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, le);
}
return resources;
@@ -1889,22 +1864,18 @@ public class JNLPClassLoader extends URLClassLoader {
if (sec == null && !alreadyTried.contains(source)) {
alreadyTried.add(source);
//try to load the jar which is requesting the permissions, but was NOT downloaded by standard way
- if (JNLPRuntime.isDebug()) {
- System.out.println("Application is trying to get permissions for " + source.toString() + ", which was not added by standard way. Trying to download and verify!");
- }
+ OutputController.getLogger().log("Application is trying to get permissions for " + source.toString() + ", which was not added by standard way. Trying to download and verify!");
try {
JARDesc des = new JARDesc(source, null, null, false, false, false, false);
addNewJar(des);
sec = jarLocationSecurityMap.get(source);
} catch (Throwable t) {
- if (JNLPRuntime.isDebug()) {
- t.printStackTrace();
- }
+ OutputController.getLogger().log(t);
sec = null;
}
}
if (sec == null){
- System.out.println(Translator.R("LNoSecInstance",source.toString()));
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, Translator.R("LNoSecInstance",source.toString()));
}
return sec;
}
@@ -2039,10 +2010,8 @@ public class JNLPClassLoader extends URLClassLoader {
try {
tracker.removeResource(eachJar.getLocation());
} catch (Exception e) {
- if (JNLPRuntime.isDebug()) {
- System.err.println(e.getMessage());
- System.err.println("Failed to remove resource from tracker, continuing..");
- }
+ OutputController.getLogger().log(e);
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Failed to remove resource from tracker, continuing..");
}
File cachedFile = CacheUtil.getCacheFile(eachJar.getLocation(), null);
@@ -2050,13 +2019,11 @@ public class JNLPClassLoader extends URLClassLoader {
File directory = new File(directoryUrl);
- if (JNLPRuntime.isDebug())
- System.out.println("Deleting cached file: " + cachedFile.getAbsolutePath());
+ OutputController.getLogger().log("Deleting cached file: " + cachedFile.getAbsolutePath());
cachedFile.delete();
- if (JNLPRuntime.isDebug())
- System.out.println("Deleting cached directory: " + directory.getAbsolutePath());
+ OutputController.getLogger().log("Deleting cached directory: " + directory.getAbsolutePath());
directory.delete();
}
@@ -2074,8 +2041,7 @@ public class JNLPClassLoader extends URLClassLoader {
JARDesc[] jars = ManageJnlpResources.findJars(this, ref, part, version);
for (JARDesc eachJar : jars) {
- if (JNLPRuntime.isDebug())
- System.out.println("Downloading and initializing jar: " + eachJar.getLocation().toString());
+ OutputController.getLogger().log("Downloading and initializing jar: " + eachJar.getLocation().toString());
this.addNewJar(eachJar, UpdatePolicy.FORCE);
}
@@ -2107,8 +2073,7 @@ public class JNLPClassLoader extends URLClassLoader {
if (action == DownloadAction.DOWNLOAD_TO_CACHE) {
JARDesc jarToCache = new JARDesc(ref, resourceVersion, null, false, true, false, true);
- if (JNLPRuntime.isDebug())
- System.out.println("Downloading and initializing jar: " + ref.toString());
+ OutputController.getLogger().log("Downloading and initializing jar: " + ref.toString());
foundLoader.addNewJar(jarToCache, UpdatePolicy.FORCE);
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPPolicy.java b/netx/net/sourceforge/jnlp/runtime/JNLPPolicy.java
index ba9b53e..59b8c87 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPPolicy.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPPolicy.java
@@ -23,6 +23,7 @@ import java.security.*;
import java.util.Enumeration;
import net.sourceforge.jnlp.config.DeploymentConfiguration;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* Policy for JNLP environment. This class delegates to the
@@ -167,11 +168,11 @@ public class JNLPPolicy extends Policy {
URI policyUri = new URI(policyLocation);
policy = getInstance("JavaPolicy", new URIParameter(policyUri));
} catch (IllegalArgumentException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
} catch (NoSuchAlgorithmException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
} catch (URISyntaxException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
}
return policy;
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPProxySelector.java b/netx/net/sourceforge/jnlp/runtime/JNLPProxySelector.java
index efcf62e..e92b2c9 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPProxySelector.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPProxySelector.java
@@ -33,6 +33,7 @@ import java.util.List;
import java.util.StringTokenizer;
import net.sourceforge.jnlp.config.DeploymentConfiguration;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* A ProxySelector specific to JNLPs. This proxy uses the deployment
@@ -97,7 +98,7 @@ public abstract class JNLPProxySelector extends ProxySelector {
try {
autoConfigUrl = new URL(autoConfigString);
} catch (MalformedURLException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
}
@@ -159,7 +160,7 @@ public abstract class JNLPProxySelector extends ProxySelector {
try {
proxyPort = Integer.valueOf(port);
} catch (NumberFormatException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
}
return proxyPort;
@@ -170,7 +171,7 @@ public abstract class JNLPProxySelector extends ProxySelector {
*/
@Override
public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
- ioe.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ioe);
}
/**
@@ -178,15 +179,11 @@ public abstract class JNLPProxySelector extends ProxySelector {
*/
@Override
public List<Proxy> select(URI uri) {
- if (JNLPRuntime.isDebug()) {
- System.out.println("Selecting proxy for: " + uri);
- }
-
+ OutputController.getLogger().log("Selecting proxy for: " + uri);
+
if (inBypassList(uri)) {
List<Proxy> proxies = Arrays.asList(new Proxy[] { Proxy.NO_PROXY });
- if (JNLPRuntime.isDebug()) {
- System.out.println("Selected proxies: " + Arrays.toString(proxies.toArray()));
- }
+ OutputController.getLogger().log("Selected proxies: " + Arrays.toString(proxies.toArray()));
return proxies;
}
@@ -211,9 +208,7 @@ public abstract class JNLPProxySelector extends ProxySelector {
break;
}
- if (JNLPRuntime.isDebug()) {
- System.out.println("Selected proxies: " + Arrays.toString(proxies.toArray()));
- }
+ OutputController.getLogger().log("Selected proxies: " + Arrays.toString(proxies.toArray()));
return proxies;
}
@@ -344,7 +339,7 @@ public abstract class JNLPProxySelector extends ProxySelector {
String proxiesString = pacEvaluator.getProxies(uri.toURL());
proxies.addAll(getProxiesFromPacResult(proxiesString));
} catch (MalformedURLException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
proxies.add(Proxy.NO_PROXY);
}
@@ -403,9 +398,7 @@ public abstract class JNLPProxySelector extends ProxySelector {
} else if (token.startsWith("DIRECT")) {
proxies.add(Proxy.NO_PROXY);
} else {
- if (JNLPRuntime.isDebug()) {
- System.out.println("Unrecognized proxy token: " + token);
- }
+ OutputController.getLogger().log("Unrecognized proxy token: " + token);
}
}
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
index a2fcb7d..a79663b 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
@@ -67,7 +67,9 @@ import net.sourceforge.jnlp.security.SecurityDialogMessageHandler;
import net.sourceforge.jnlp.security.VariableX509TrustManager;
import net.sourceforge.jnlp.services.XServiceManagerStub;
import net.sourceforge.jnlp.util.FileUtils;
+import net.sourceforge.jnlp.util.logging.OutputController;
import net.sourceforge.jnlp.util.TeeOutputStream;
+import net.sourceforge.jnlp.util.logging.LogConfig;
import sun.net.www.protocol.jar.URLJarFile;
/**
@@ -87,7 +89,7 @@ import sun.net.www.protocol.jar.URLJarFile;
* @version $Revision: 1.19 $
*/
public class JNLPRuntime {
-
+
static {
loadResources();
}
@@ -129,11 +131,12 @@ public class JNLPRuntime {
/** whether debug mode is on */
private static boolean debug = false;
+ /**
+ * whether plugin debug mode is on
+ */
+ private static Boolean pluginDebug = null;
- /** whether streams should be redirected */
- private static boolean redirectStreams = false;
-
- /** mutex to wait on, for initialization */
+ /** mutex to wait on, for initialization */
public static Object initMutex = new Object();
/** set to true if this is a webstart application. */
@@ -196,15 +199,13 @@ public class JNLPRuntime {
} catch (ConfigurationException e) {
/* exit if there is a fatal exception loading the configuration */
if (isApplication) {
- System.out.println(getMessage("RConfigurationError"));
- System.exit(1);
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, getMessage("RConfigurationError"));
+ JNLPRuntime.exit(1);
}
}
KeyStores.setConfiguration(config);
- initializeStreams();
-
isWebstartApplication = isApplication;
//Setting the system property for javawebstart's version.
@@ -220,9 +221,9 @@ public class JNLPRuntime {
if (handler == null) {
if (headless) {
- handler = new DefaultLaunchHandler(System.err);
+ handler = new DefaultLaunchHandler(OutputController.getLogger());
} else {
- handler = new GuiLaunchHandler(System.err);
+ handler = new GuiLaunchHandler(OutputController.getLogger());
}
}
@@ -234,7 +235,7 @@ public class JNLPRuntime {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
doMainAppContextHacks();
@@ -259,8 +260,8 @@ public class JNLPRuntime {
HttpsURLConnection.setDefaultSSLSocketFactory(sslSocketFactory);
} catch (Exception e) {
- System.err.println("Unable to set SSLSocketfactory (may _prevent_ access to sites that should be trusted)! Continuing anyway...");
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Unable to set SSLSocketfactory (may _prevent_ access to sites that should be trusted)! Continuing anyway...");
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
// plug in a custom authenticator and proxy selector
@@ -294,14 +295,14 @@ public class JNLPRuntime {
try {
trustManagerClass = Class.forName("net.sourceforge.jnlp.security.VariableX509TrustManagerJDK6");
} catch (ClassNotFoundException cnfe) {
- System.err.println("Unable to find class net.sourceforge.jnlp.security.VariableX509TrustManagerJDK6");
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Unable to find class net.sourceforge.jnlp.security.VariableX509TrustManagerJDK6");
return null;
}
} else { // Java 7 or more (technically could be <= 1.5 but <= 1.5 is unsupported)
try {
trustManagerClass = Class.forName("net.sourceforge.jnlp.security.VariableX509TrustManagerJDK7");
} catch (ClassNotFoundException cnfe) {
- System.err.println("Unable to find class net.sourceforge.jnlp.security.VariableX509TrustManagerJDK7");
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Unable to find class net.sourceforge.jnlp.security.VariableX509TrustManagerJDK7");
return null;
}
}
@@ -318,7 +319,8 @@ public class JNLPRuntime {
return (TrustManager) tmCtor.newInstance();
} catch (RuntimeException e) {
- System.err.println("Unable to load JDK-specific TrustManager. Was this version of IcedTea-Web compiled with JDK6?");
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Unable to load JDK-specific TrustManager. Was this version of IcedTea-Web compiled with JDK 6 or 7?");
+ OutputController.getLogger().log(e);
throw e;
}
}
@@ -357,37 +359,7 @@ public class JNLPRuntime {
new ParserDelegator();
}
- /**
- * Initializes the standard output and error streams, redirecting them or
- * duplicating them as required.
- */
- private static void initializeStreams() {
- Boolean enableLogging = Boolean.valueOf(config
- .getProperty(DeploymentConfiguration.KEY_ENABLE_LOGGING));
- if (redirectStreams || enableLogging) {
- String logDir = config.getProperty(DeploymentConfiguration.KEY_USER_LOG_DIR);
-
- try {
- File errFile = new File(logDir, JNLPRuntime.STDERR_FILE);
- FileUtils.createParentDir(errFile);
- FileUtils.createRestrictedFile(errFile, true);
- File outFile = new File(logDir, JNLPRuntime.STDOUT_FILE);
- FileUtils.createParentDir(outFile);
- FileUtils.createRestrictedFile(outFile, true);
-
- if (redirectStreams) {
- System.setErr(new PrintStream(new FileOutputStream(errFile)));
- System.setOut(new PrintStream(new FileOutputStream(outFile)));
- } else {
- System.setErr(new TeeOutputStream(new FileOutputStream(errFile), System.err));
- System.setOut(new TeeOutputStream(new FileOutputStream(outFile), System.out));
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
+
/**
* Gets the Configuration associated with this runtime
* @return a {@link DeploymentConfiguration} object that can be queried to
@@ -513,6 +485,10 @@ public class JNLPRuntime {
* should be printed.
*/
public static boolean isDebug() {
+ return isSetDebug() || isPluginDebug() || LogConfig.getLogConfig().isEnableLogging();
+ }
+
+ public static boolean isSetDebug() {
return debug;
}
@@ -527,17 +503,7 @@ public class JNLPRuntime {
debug = enabled;
}
- /**
- * Sets whether the standard output/error streams should be redirected to
- * the loggging files.
- *
- * @throws IllegalStateException if the runtime has already been initialized
- */
- public static void setRedirectStreams(boolean redirect) {
- checkInitialized();
- redirectStreams = redirect;
- }
-
+
/**
* Sets the default update policy.
*
@@ -737,13 +703,11 @@ public class JNLPRuntime {
}
if (fileLock != null && fileLock.isShared()) {
- if (JNLPRuntime.isDebug()) {
- System.out.println("Acquired shared lock on " +
+ OutputController.getLogger().log("Acquired shared lock on " +
netxRunningFile.toString() + " to indicate javaws is running");
- }
}
} catch (IOException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
Runtime.getRuntime().addShutdownHook(new Thread("JNLPRuntimeShutdownHookThread") {
@@ -766,13 +730,10 @@ public class JNLPRuntime {
fileLock.release();
fileLock.channel().close();
fileLock = null;
- if (JNLPRuntime.isDebug()) {
- String file = JNLPRuntime.getConfiguration()
- .getProperty(DeploymentConfiguration.KEY_USER_NETX_RUNNING_FILE);
- System.out.println("Release shared lock on " + file);
- }
+ OutputController.getLogger().log("Release shared lock on " + JNLPRuntime.getConfiguration()
+ .getProperty(DeploymentConfiguration.KEY_USER_NETX_RUNNING_FILE));
} catch (IOException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(e);
}
}
@@ -791,7 +752,24 @@ public class JNLPRuntime {
public static void setIgnoreHeaders(boolean ignoreHeaders) {
JNLPRuntime.ignoreHeaders = ignoreHeaders;
}
-
-
+
+ public static boolean isPluginDebug() {
+ if (pluginDebug == null) {
+ try {
+ //there are cases when this itself is not allowed by security manager, and so
+ //throws exception. Under some conditions it can couse deadlock
+ pluginDebug = System.getenv().containsKey("ICEDTEAPLUGIN_DEBUG");
+ } catch (Exception ex) {
+ pluginDebug = false;
+ OutputController.getLogger().log(ex);
+ }
+ }
+ return pluginDebug;
+ }
+
+ public static void exit(int i) {
+ OutputController.getLogger().close();
+ System.exit(i);
+ }
}
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java b/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java
index 6842f2c..5c69b01 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java
@@ -32,6 +32,7 @@ import javax.swing.JWindow;
import net.sourceforge.jnlp.JNLPFile;
import net.sourceforge.jnlp.security.SecurityDialogs.AccessType;
import net.sourceforge.jnlp.services.ServiceUtil;
+import net.sourceforge.jnlp.util.logging.OutputController;
import net.sourceforge.jnlp.util.WeakList;
import sun.awt.AWTSecurityManager;
import sun.awt.AppContext;
@@ -263,7 +264,7 @@ class JNLPSecurityManager extends AWTSecurityManager {
// Enable this manually -- it'll produce too much output for -verbose
// otherwise.
// if (true)
- // System.out.println("Checking permission: " + perm.toString());
+ // OutputController.getLogger().log("Checking permission: " + perm.toString());
if (!JNLPRuntime.isWebstartApplication() &&
("setPolicy".equals(name) || "setSecurityManager".equals(name)))
@@ -283,9 +284,7 @@ class JNLPSecurityManager extends AWTSecurityManager {
super.checkPermission(perm);
} catch (SecurityException ex) {
- if (JNLPRuntime.isDebug()) {
- System.out.println("Denying permission: " + perm);
- }
+ OutputController.getLogger().log("Denying permission: " + perm);
throw ex;
}
}
@@ -318,14 +317,14 @@ class JNLPSecurityManager extends AWTSecurityManager {
JNLPClassLoader cl = (JNLPClassLoader) JNLPRuntime.getApplication().getClassLoader();
cl.addPermission(perm);
if (JNLPRuntime.isDebug()) {
- if (cl.getPermissions(null).implies(perm))
- System.err.println("Added permission: " + perm.toString());
- else
- System.err.println("Unable to add permission: " + perm.toString());
+ if (cl.getPermissions(null).implies(perm)){
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Added permission: " + perm.toString());
+ } else {
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Unable to add permission: " + perm.toString());
+ }
}
} else {
- if (JNLPRuntime.isDebug())
- System.err.println("Unable to add permission: " + perm + ", classloader not JNLP.");
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Unable to add permission: " + perm + ", classloader not JNLP.");
}
}
@@ -341,8 +340,7 @@ class JNLPSecurityManager extends AWTSecurityManager {
if (app != null && window instanceof Window) {
Window w = (Window) window;
- if (JNLPRuntime.isDebug())
- System.err.println("SM: app: " + app.getTitle() + " is adding a window: " + window + " with appContext " + AppContext.getAppContext());
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "SM: app: " + app.getTitle() + " is adding a window: " + window + " with appContext " + AppContext.getAppContext());
weakWindows.add(w); // for mapping window -> app
weakApplications.add(app);
diff --git a/netx/net/sourceforge/jnlp/runtime/PacEvaluatorFactory.java b/netx/net/sourceforge/jnlp/runtime/PacEvaluatorFactory.java
index 9ed6217..a034161 100644
--- a/netx/net/sourceforge/jnlp/runtime/PacEvaluatorFactory.java
+++ b/netx/net/sourceforge/jnlp/runtime/PacEvaluatorFactory.java
@@ -43,6 +43,7 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.Properties;
+import net.sourceforge.jnlp.util.logging.OutputController;
public class PacEvaluatorFactory {
@@ -60,16 +61,12 @@ public class PacEvaluatorFactory {
properties = new Properties();
properties.load(in);
} catch (IOException e) {
- if (JNLPRuntime.isDebug()) {
- e.printStackTrace();
- }
+ OutputController.getLogger().log(e);
} finally {
try {
in.close();
} catch (IOException e) {
- if (JNLPRuntime.isDebug()) {
- e.printStackTrace();
- }
+ OutputController.getLogger().log(e);
}
}
@@ -88,16 +85,16 @@ public class PacEvaluatorFactory {
} catch (ClassNotFoundException e) {
// ignore
} catch (InstantiationException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
} catch (IllegalAccessException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
} catch (NoSuchMethodException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
} catch (IllegalArgumentException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
} catch (InvocationTargetException e) {
if (e.getCause() != null) {
- e.getCause().printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e.getCause());
}
}
}
diff --git a/netx/net/sourceforge/jnlp/runtime/RhinoBasedPacEvaluator.java b/netx/net/sourceforge/jnlp/runtime/RhinoBasedPacEvaluator.java
index b1c290a..eb4030b 100644
--- a/netx/net/sourceforge/jnlp/runtime/RhinoBasedPacEvaluator.java
+++ b/netx/net/sourceforge/jnlp/runtime/RhinoBasedPacEvaluator.java
@@ -49,6 +49,7 @@ import java.security.Permissions;
import java.security.PrivilegedAction;
import java.security.ProtectionDomain;
import java.util.PropertyPermission;
+import net.sourceforge.jnlp.util.logging.OutputController;
import net.sourceforge.jnlp.util.TimedHashMap;
@@ -75,9 +76,7 @@ public class RhinoBasedPacEvaluator implements PacEvaluator {
* @param pacUrl the url of the PAC file to use
*/
public RhinoBasedPacEvaluator(URL pacUrl) {
- if (JNLPRuntime.isDebug()) {
- System.err.println("Using the Rhino based PAC evaluator for url " + pacUrl);
- }
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Using the Rhino based PAC evaluator for url " + pacUrl);
pacHelperFunctionContents = getHelperFunctionContents();
this.pacUrl = pacUrl;
pacContents = getPacContents(pacUrl);
@@ -119,7 +118,7 @@ public class RhinoBasedPacEvaluator implements PacEvaluator {
*/
private String getProxiesWithoutCaching(URL url) {
if (pacHelperFunctionContents == null) {
- System.err.println("Error loading pac functions");
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Error loading pac functions");
return "DIRECT";
}
@@ -151,7 +150,7 @@ public class RhinoBasedPacEvaluator implements PacEvaluator {
BufferedReader pacReader = new BufferedReader(new InputStreamReader(pacUrl.openStream()));
try {
while ((line = pacReader.readLine()) != null) {
- // System.out.println(line);
+ // OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, line);
contents = contents.append(line).append("\n");
}
} finally {
@@ -181,14 +180,14 @@ public class RhinoBasedPacEvaluator implements PacEvaluator {
try {
contents = new StringBuilder();
while ((line = pacFuncsReader.readLine()) != null) {
- // System.out.println(line);
+ // OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL,line);
contents = contents.append(line).append("\n");
}
} finally {
pacFuncsReader.close();
}
} catch (IOException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
contents = null;
}
@@ -249,7 +248,7 @@ public class RhinoBasedPacEvaluator implements PacEvaluator {
Object functionObj = scope.get("FindProxyForURL", scope);
if (!(functionObj instanceof Function)) {
- System.err.println("FindProxyForURL not found");
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "FindProxyForURL not found");
return null;
} else {
Function findProxyFunction = (Function) functionObj;
@@ -259,7 +258,7 @@ public class RhinoBasedPacEvaluator implements PacEvaluator {
return (String) result;
}
} catch (Exception e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
return "DIRECT";
} finally {
Context.exit();
diff --git a/netx/net/sourceforge/jnlp/security/CertWarningPane.java b/netx/net/sourceforge/jnlp/security/CertWarningPane.java
index fff814c..f9273fa 100644
--- a/netx/net/sourceforge/jnlp/security/CertWarningPane.java
+++ b/netx/net/sourceforge/jnlp/security/CertWarningPane.java
@@ -70,6 +70,7 @@ import net.sourceforge.jnlp.security.KeyStores.Level;
import net.sourceforge.jnlp.security.KeyStores.Type;
import net.sourceforge.jnlp.security.SecurityDialogs.AccessType;
import net.sourceforge.jnlp.util.FileUtils;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* Provides the panel for using inside a SecurityDialog. These dialogs are
@@ -266,13 +267,11 @@ public class CertWarningPane extends SecurityDialogPanel {
} finally {
os.close();
}
- if (JNLPRuntime.isDebug()) {
- System.out.println("certificate is now permanently trusted");
- }
+ OutputController.getLogger().log("certificate is now permanently trusted");
} catch (Exception ex) {
// TODO: Let NetX show a dialog here notifying user
// about being unable to add cert to keystore
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
}
}
}
diff --git a/netx/net/sourceforge/jnlp/security/CertificateUtils.java b/netx/net/sourceforge/jnlp/security/CertificateUtils.java
index 6987d8c..a8984b3 100644
--- a/netx/net/sourceforge/jnlp/security/CertificateUtils.java
+++ b/netx/net/sourceforge/jnlp/security/CertificateUtils.java
@@ -61,6 +61,7 @@ import java.util.Random;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
import net.sourceforge.jnlp.runtime.Translator;
+import net.sourceforge.jnlp.util.logging.OutputController;
import net.sourceforge.jnlp.util.replacements.BASE64Encoder;
import sun.security.provider.X509Factory;
@@ -77,9 +78,8 @@ public class CertificateUtils {
*/
public static final void addToKeyStore(File file, KeyStore ks) throws CertificateException,
IOException, KeyStoreException {
- if (JNLPRuntime.isDebug()) {
- System.out.println("Importing certificate from " + file + " into " + ks);
- }
+
+ OutputController.getLogger().log("Importing certificate from " + file + " into " + ks);
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
CertificateFactory cf = CertificateFactory.getInstance("X509");
@@ -100,9 +100,8 @@ public class CertificateUtils {
*/
public static final void addToKeyStore(X509Certificate cert, KeyStore ks)
throws KeyStoreException {
- if (JNLPRuntime.isDebug()) {
- System.out.println("Importing " + cert.getSubjectX500Principal().getName());
- }
+
+ OutputController.getLogger().log("Importing " + cert.getSubjectX500Principal().getName());
String alias = null;
@@ -173,16 +172,13 @@ public class CertificateUtils {
String alias = aliases.nextElement();
if (c.equals(keyStores[i].getCertificate(alias))) {
- if (JNLPRuntime.isDebug()) {
- System.out.println(Translator.R("LCertFoundIn", c.getSubjectX500Principal().getName(), KeyStores.getPathToKeystore(keyStores[i].hashCode())));
- }
-
+ OutputController.getLogger().log(Translator.R("LCertFoundIn", c.getSubjectX500Principal().getName(), KeyStores.getPathToKeystore(keyStores[i].hashCode())));
return true;
} // else continue
}
} catch (KeyStoreException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
// continue
}
}
diff --git a/netx/net/sourceforge/jnlp/security/HttpsCertVerifier.java b/netx/net/sourceforge/jnlp/security/HttpsCertVerifier.java
index edd5899..e7a101d 100644
--- a/netx/net/sourceforge/jnlp/security/HttpsCertVerifier.java
+++ b/netx/net/sourceforge/jnlp/security/HttpsCertVerifier.java
@@ -52,6 +52,7 @@ import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import net.sourceforge.jnlp.util.logging.OutputController;
import sun.security.util.DerValue;
import sun.security.util.HostnameChecker;
@@ -98,7 +99,7 @@ public class HttpsCertVerifier implements CertVerifier {
try {
certPaths.add(CertificateFactory.getInstance("X.509").generateCertPath(list));
} catch (CertificateException ce) {
- ce.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ce);
// carry on
}
@@ -187,9 +188,9 @@ public class HttpsCertVerifier implements CertVerifier {
names = names.substring(2); // remove proceeding ", "
} catch (CertificateParsingException cpe) {
- cpe.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, cpe);
} catch (IOException ioe) {
- ioe.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ioe);
}
return names;
diff --git a/netx/net/sourceforge/jnlp/security/KeyStores.java b/netx/net/sourceforge/jnlp/security/KeyStores.java
index a0b2895..eb6fe1d 100644
--- a/netx/net/sourceforge/jnlp/security/KeyStores.java
+++ b/netx/net/sourceforge/jnlp/security/KeyStores.java
@@ -55,6 +55,7 @@ import java.util.StringTokenizer;
import net.sourceforge.jnlp.config.DeploymentConfiguration;
import net.sourceforge.jnlp.runtime.Translator;
import net.sourceforge.jnlp.util.FileUtils;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* The <code>KeyStores</code> class allows easily accessing the various KeyStores
@@ -141,7 +142,7 @@ public final class KeyStores {
//to keystore, then this will not be blocker for garbage collection
keystoresPaths.put(ks.hashCode(),location);
} catch (Exception e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
return ks;
}
diff --git a/netx/net/sourceforge/jnlp/security/SecurityDialog.java b/netx/net/sourceforge/jnlp/security/SecurityDialog.java
index e204f0e..03f2225 100644
--- a/netx/net/sourceforge/jnlp/security/SecurityDialog.java
+++ b/netx/net/sourceforge/jnlp/security/SecurityDialog.java
@@ -53,6 +53,7 @@ import java.security.cert.X509Certificate;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.List;
+import net.sourceforge.jnlp.util.logging.OutputController;
import net.sourceforge.jnlp.util.ScreenFinder;
/**
@@ -321,22 +322,18 @@ public class SecurityDialog extends JDialog {
private void selectDefaultButton() {
if (panel == null) {
- System.out.println("initial value panel is null");
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "initial value panel is null");
}
panel.requestFocusOnDefaultButton();
}
protected void setValue(Object value) {
- if (JNLPRuntime.isDebug()) {
- System.out.println("Setting value:" + value);
- }
+ OutputController.getLogger().log("Setting value:" + value);
this.value = value;
}
public Object getValue() {
- if (JNLPRuntime.isDebug()) {
- System.out.println("Returning value:" + value);
- }
+ OutputController.getLogger().log("Returning value:" + value);
return value;
}
diff --git a/netx/net/sourceforge/jnlp/security/SecurityDialogMessageHandler.java b/netx/net/sourceforge/jnlp/security/SecurityDialogMessageHandler.java
index 2fbcb5b..a2f9588 100644
--- a/netx/net/sourceforge/jnlp/security/SecurityDialogMessageHandler.java
+++ b/netx/net/sourceforge/jnlp/security/SecurityDialogMessageHandler.java
@@ -45,6 +45,7 @@ import java.util.concurrent.LinkedBlockingQueue;
import sun.awt.AppContext;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* Handles {@link SecurityDialogMessage}s and shows appropriate security
@@ -72,9 +73,7 @@ public final class SecurityDialogMessageHandler implements Runnable {
*/
@Override
public void run() {
- if (JNLPRuntime.isDebug()) {
- System.out.println("Starting security dialog thread");
- }
+ OutputController.getLogger().log("Starting security dialog thread");
while (true) {
try {
SecurityDialogMessage msg = queue.take();
@@ -134,7 +133,7 @@ public final class SecurityDialogMessageHandler implements Runnable {
try {
queue.put(message);
} catch (InterruptedException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
}
diff --git a/netx/net/sourceforge/jnlp/security/SecurityUtil.java b/netx/net/sourceforge/jnlp/security/SecurityUtil.java
index 8b6dd9a..5948753 100644
--- a/netx/net/sourceforge/jnlp/security/SecurityUtil.java
+++ b/netx/net/sourceforge/jnlp/security/SecurityUtil.java
@@ -44,6 +44,7 @@ import java.security.KeyStore;
import net.sourceforge.jnlp.security.KeyStores.Level;
import net.sourceforge.jnlp.security.KeyStores.Type;
+import net.sourceforge.jnlp.util.logging.OutputController;
public class SecurityUtil {
@@ -210,7 +211,7 @@ public class SecurityUtil {
ks.load(fis, password);
}
} catch (Exception e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
throw e;
} finally {
if (fis != null)
diff --git a/netx/net/sourceforge/jnlp/security/VariableX509TrustManager.java b/netx/net/sourceforge/jnlp/security/VariableX509TrustManager.java
index 4f508d8..b92f02c 100644
--- a/netx/net/sourceforge/jnlp/security/VariableX509TrustManager.java
+++ b/netx/net/sourceforge/jnlp/security/VariableX509TrustManager.java
@@ -58,6 +58,7 @@ import javax.net.ssl.X509TrustManager;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
import net.sourceforge.jnlp.security.SecurityDialogs.AccessType;
+import net.sourceforge.jnlp.util.logging.OutputController;
import sun.security.util.HostnameChecker;
import sun.security.validator.ValidatorException;
@@ -110,7 +111,7 @@ final public class VariableX509TrustManager {
}
}
} catch (Exception e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
/*
@@ -135,7 +136,7 @@ final public class VariableX509TrustManager {
}
}
} catch (Exception e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
/*
@@ -159,7 +160,7 @@ final public class VariableX509TrustManager {
}
}
} catch (Exception e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
}
@@ -328,7 +329,7 @@ final public class VariableX509TrustManager {
// finally check temp trusted certs
if (!temporarilyTrusted.contains(chain[0])) {
if (savedException == null) {
- // System.out.println("IMPOSSIBLE!");
+ // OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "IMPOSSIBLE!");
throw new ValidatorException(ValidatorException.T_SIGNATURE_ERROR, chain[0]);
}
throw savedException;
diff --git a/netx/net/sourceforge/jnlp/security/appletextendedsecurity/ExtendedAppletSecurityHelp.java b/netx/net/sourceforge/jnlp/security/appletextendedsecurity/ExtendedAppletSecurityHelp.java
index e0da90a..0a11021 100644
--- a/netx/net/sourceforge/jnlp/security/appletextendedsecurity/ExtendedAppletSecurityHelp.java
+++ b/netx/net/sourceforge/jnlp/security/appletextendedsecurity/ExtendedAppletSecurityHelp.java
@@ -45,6 +45,7 @@ import javax.swing.JSeparator;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import net.sourceforge.jnlp.runtime.Translator;
+import net.sourceforge.jnlp.util.logging.OutputController;
public class ExtendedAppletSecurityHelp extends javax.swing.JDialog implements HyperlinkListener {
@@ -77,7 +78,7 @@ public class ExtendedAppletSecurityHelp extends javax.swing.JDialog implements H
mainHtmlPane.setPage(event.getURL());
}
} catch (IOException ioe) {
- ioe.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ioe);
}
}
}
diff --git a/netx/net/sourceforge/jnlp/security/appletextendedsecurity/UnsignedAppletTrustConfirmation.java b/netx/net/sourceforge/jnlp/security/appletextendedsecurity/UnsignedAppletTrustConfirmation.java
index d90a7c3..b869db8 100644
--- a/netx/net/sourceforge/jnlp/security/appletextendedsecurity/UnsignedAppletTrustConfirmation.java
+++ b/netx/net/sourceforge/jnlp/security/appletextendedsecurity/UnsignedAppletTrustConfirmation.java
@@ -52,9 +52,9 @@ import net.sourceforge.jnlp.PluginBridge;
import net.sourceforge.jnlp.cache.ResourceTracker;
import net.sourceforge.jnlp.security.SecurityDialogs;
import net.sourceforge.jnlp.security.UnsignedAppletTrustWarningPanel.UnsignedWarningAction;
+import net.sourceforge.jnlp.util.logging.OutputController;
public class UnsignedAppletTrustConfirmation {
- static private final boolean DEBUG = System.getenv().containsKey("ICEDTEAPLUGIN_DEBUG");
private static final AppletStartupSecuritySettings securitySettings = AppletStartupSecuritySettings.getInstance();
@@ -158,27 +158,21 @@ public class UnsignedAppletTrustConfirmation {
userActionStorage.unlock();
}
}
- static private void debug(String logMessage) {
- if (DEBUG) {
- System.err.println(logMessage);
- }
-
- }
public static void checkUnsignedWithUserIfRequired(PluginBridge file) throws LaunchException {
if (unsignedAppletsAreForbidden()) {
- debug("Not running unsigned applet at " + file.getCodeBase() +" because unsigned applets are disallowed by security policy.");
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Not running unsigned applet at " + file.getCodeBase() +" because unsigned applets are disallowed by security policy.");
throw new LaunchException(file, null, R("LSFatal"), R("LCClient"), R("LUnsignedApplet"), R("LUnsignedAppletPolicyDenied"));
}
if (!unsignedConfirmationIsRequired()) {
- debug("Running unsigned applet at " + file.getCodeBase() +" does not require confirmation according to security policy.");
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Running unsigned applet at " + file.getCodeBase() +" does not require confirmation according to security policy.");
return;
}
ExecuteUnsignedApplet storedAction = getStoredAction(file);
- debug("Stored action for unsigned applet at " + file.getCodeBase() +" was " + storedAction);
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Stored action for unsigned applet at " + file.getCodeBase() +" was " + storedAction);
boolean appletOK;
@@ -197,7 +191,7 @@ public class UnsignedAppletTrustConfirmation {
updateAppletAction(file, executeAction, warningResponse.rememberForCodeBase());
}
- debug("Decided action for unsigned applet at " + file.getCodeBase() +" was " + executeAction);
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Decided action for unsigned applet at " + file.getCodeBase() +" was " + executeAction);
}
if (!appletOK) {
diff --git a/netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java b/netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java
index 36a809b..61123d7 100644
--- a/netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java
+++ b/netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java
@@ -80,6 +80,7 @@ import net.sourceforge.jnlp.security.SecurityUtil;
import net.sourceforge.jnlp.security.SecurityDialog;
import net.sourceforge.jnlp.security.KeyStores.Level;
import net.sourceforge.jnlp.util.FileUtils;
+import net.sourceforge.jnlp.util.logging.OutputController;
public class CertificatePane extends JPanel {
@@ -150,7 +151,7 @@ public class CertificatePane extends JPanel {
try {
keyStore = KeyStores.getKeyStore(currentKeyStoreLevel, currentKeyStoreType);
} catch (Exception e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
}
@@ -278,7 +279,7 @@ public class CertificatePane extends JPanel {
}
} catch (Exception e) {
//TODO
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
}
@@ -404,7 +405,7 @@ public class CertificatePane extends JPanel {
repopulateTables();
} catch (Exception ex) {
// TODO: handle exception
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
}
}
}
@@ -446,8 +447,7 @@ public class CertificatePane extends JPanel {
}
}
} catch (Exception ex) {
- // TODO
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
}
}
}
@@ -491,8 +491,7 @@ public class CertificatePane extends JPanel {
repopulateTables();
}
} catch (Exception ex) {
- // TODO
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
}
}
diff --git a/netx/net/sourceforge/jnlp/services/ServiceUtil.java b/netx/net/sourceforge/jnlp/services/ServiceUtil.java
index 2972799..9885138 100644
--- a/netx/net/sourceforge/jnlp/services/ServiceUtil.java
+++ b/netx/net/sourceforge/jnlp/services/ServiceUtil.java
@@ -42,6 +42,7 @@ import net.sourceforge.jnlp.runtime.ApplicationInstance;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
import net.sourceforge.jnlp.security.SecurityDialogs;
import net.sourceforge.jnlp.security.SecurityDialogs.AccessType;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* Provides static methods to interact useful for using the JNLP
@@ -172,10 +173,10 @@ public class ServiceUtil {
public Object invoke(Object proxy, final Method method, final Object[] args) throws Throwable {
if (JNLPRuntime.isDebug()) {
- System.err.println("call privileged method: " + method.getName());
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "call privileged method: " + method.getName());
if (args != null)
for (int i = 0; i < args.length; i++)
- System.err.println(" arg: " + args[i]);
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, " arg: " + args[i]);
}
PrivilegedExceptionAction<Object> invoker = new PrivilegedExceptionAction<Object>() {
@@ -187,8 +188,7 @@ public class ServiceUtil {
try {
Object result = AccessController.doPrivileged(invoker);
- if (JNLPRuntime.isDebug())
- System.err.println(" result: " + result);
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, " result: " + result);
return result;
} catch (PrivilegedActionException e) {
@@ -306,11 +306,12 @@ public class ServiceUtil {
try {
c = Class.forName(stack[i].getClassName());
} catch (Exception e1) {
+ OutputController.getLogger().log(e1);
try {
c = Class.forName(stack[i].getClassName(), false,
app.getClassLoader());
} catch (Exception e2) {
- System.err.println(e2.getMessage());
+ OutputController.getLogger().log(e2);
}
}
diff --git a/netx/net/sourceforge/jnlp/services/XBasicService.java b/netx/net/sourceforge/jnlp/services/XBasicService.java
index d8c1388..007312f 100644
--- a/netx/net/sourceforge/jnlp/services/XBasicService.java
+++ b/netx/net/sourceforge/jnlp/services/XBasicService.java
@@ -33,6 +33,7 @@ import net.sourceforge.jnlp.Launcher;
import net.sourceforge.jnlp.config.DeploymentConfiguration;
import net.sourceforge.jnlp.runtime.ApplicationInstance;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* The BasicService JNLP service.
@@ -180,8 +181,7 @@ class XBasicService implements BasicService {
return true;
} catch (IOException ex) {
- if (JNLPRuntime.isDebug())
- ex.printStackTrace();
+ OutputController.getLogger().log(ex);
}
}
@@ -193,9 +193,7 @@ class XBasicService implements BasicService {
return;
initialized = true;
initializeBrowserCommand();
- if (JNLPRuntime.isDebug()) {
- System.out.println("browser is " + command);
- }
+ OutputController.getLogger().log("browser is " + command);
}
/**
@@ -228,7 +226,7 @@ class XBasicService implements BasicService {
try {
config.save();
} catch (IOException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
break;
}
@@ -245,7 +243,7 @@ class XBasicService implements BasicService {
try {
config.save();
} catch (IOException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
}
}
@@ -272,10 +270,10 @@ class XBasicService implements BasicService {
p.waitFor();
return (p.exitValue() == 0);
} catch (IOException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
return false;
} catch (InterruptedException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
return false;
}
}
diff --git a/netx/net/sourceforge/jnlp/services/XPersistenceService.java b/netx/net/sourceforge/jnlp/services/XPersistenceService.java
index f3a638f..4d79616 100644
--- a/netx/net/sourceforge/jnlp/services/XPersistenceService.java
+++ b/netx/net/sourceforge/jnlp/services/XPersistenceService.java
@@ -25,6 +25,7 @@ import net.sourceforge.jnlp.cache.*;
import net.sourceforge.jnlp.config.DeploymentConfiguration;
import net.sourceforge.jnlp.runtime.*;
import net.sourceforge.jnlp.util.FileUtils;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* The BasicService JNLP service.
@@ -67,10 +68,8 @@ class XPersistenceService implements PersistenceService {
else
requestPath = "";
- if (JNLPRuntime.isDebug()) {
- System.out.println("codebase path: " + source.getFile());
- System.out.println("request path: " + requestPath);
- }
+ OutputController.getLogger().log("codebase path: " + source.getFile());
+ OutputController.getLogger().log("request path: " + requestPath);
if (!source.getFile().startsWith(requestPath)
&& !ServiceUtil.isSigned(app)) // Allow trusted application to have access to data below source URL path
diff --git a/netx/net/sourceforge/jnlp/services/XPrintService.java b/netx/net/sourceforge/jnlp/services/XPrintService.java
index ddbeb98..678274e 100644
--- a/netx/net/sourceforge/jnlp/services/XPrintService.java
+++ b/netx/net/sourceforge/jnlp/services/XPrintService.java
@@ -47,6 +47,7 @@ import javax.jnlp.*;
import javax.swing.JOptionPane;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import net.sourceforge.jnlp.util.logging.OutputController;
public class XPrintService implements PrintService {
@@ -84,7 +85,8 @@ public class XPrintService implements PrintService {
pj.print();
return true;
} catch (PrinterException pe) {
- System.err.println("Could not print: " + pe);
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Could not print: " + pe);
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, pe);
return false;
}
}
@@ -102,7 +104,8 @@ public class XPrintService implements PrintService {
pj.print();
return true;
} catch (PrinterException pe) {
- System.err.println("Could not print: " + pe);
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Could not print: " + pe);
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, pe);
return false;
}
@@ -118,6 +121,6 @@ public class XPrintService implements PrintService {
"Unable to find a default printer.",
"Warning",
JOptionPane.WARNING_MESSAGE);
- System.err.println("Unable to print: Unable to find default printer.");
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Unable to print: Unable to find default printer.");
}
}
diff --git a/netx/net/sourceforge/jnlp/services/XSingleInstanceService.java b/netx/net/sourceforge/jnlp/services/XSingleInstanceService.java
index 35da018..f82889e 100644
--- a/netx/net/sourceforge/jnlp/services/XSingleInstanceService.java
+++ b/netx/net/sourceforge/jnlp/services/XSingleInstanceService.java
@@ -33,6 +33,7 @@ import javax.management.InstanceAlreadyExistsException;
import net.sourceforge.jnlp.JNLPFile;
import net.sourceforge.jnlp.PluginBridge;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* This class implements SingleInstanceService
@@ -63,9 +64,7 @@ public class XSingleInstanceService implements ExtendedSingleInstanceService {
listeningSocket = new ServerSocket(0);
lockFile.createWithPort(listeningSocket.getLocalPort());
- if (JNLPRuntime.isDebug()) {
- System.out.println("Starting SingleInstanceServer on port" + listeningSocket);
- }
+ OutputController.getLogger().log("Starting SingleInstanceServer on port" + listeningSocket);
while (true) {
try {
@@ -76,19 +75,19 @@ public class XSingleInstanceService implements ExtendedSingleInstanceService {
notifySingleInstanceListeners(arguments);
} catch (Exception exception) {
// not much to do here...
- exception.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, exception);
}
}
} catch (IOException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
} finally {
if (listeningSocket != null) {
try {
listeningSocket.close();
} catch (IOException e) {
// Give up.
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
}
}
@@ -136,9 +135,7 @@ public class XSingleInstanceService implements ExtendedSingleInstanceService {
SingleInstanceLock lockFile = new SingleInstanceLock(jnlpFile);
if (lockFile.isValid()) {
int port = lockFile.getPort();
- if (JNLPRuntime.isDebug()) {
- System.out.println("Lock file is valid (port=" + port + "). Exiting.");
- }
+ OutputController.getLogger().log("Lock file is valid (port=" + port + "). Exiting.");
String[] args = null;
if (jnlpFile.isApplet()) {
@@ -204,9 +201,7 @@ public class XSingleInstanceService implements ExtendedSingleInstanceService {
serverCommunicationSocket.close();
} catch (UnknownHostException unknownHost) {
- if (JNLPRuntime.isDebug()) {
- System.out.println("Unable to find localhost");
- }
+ OutputController.getLogger().log("Unable to find localhost");
throw new RuntimeException(unknownHost);
}
}
diff --git a/netx/net/sourceforge/jnlp/splashscreen/SplashUtils.java b/netx/net/sourceforge/jnlp/splashscreen/SplashUtils.java
index 7aa84cb..b43476e 100644
--- a/netx/net/sourceforge/jnlp/splashscreen/SplashUtils.java
+++ b/netx/net/sourceforge/jnlp/splashscreen/SplashUtils.java
@@ -41,6 +41,7 @@ import net.sourceforge.jnlp.runtime.AppletInstance;
import net.sourceforge.jnlp.runtime.Boot;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
import net.sourceforge.jnlp.splashscreen.impls.*;
+import net.sourceforge.jnlp.util.logging.OutputController;
public class SplashUtils {
@@ -77,11 +78,9 @@ public class SplashUtils {
try {
showError(ex, appletInstance);
} catch (Throwable t) {
- if (JNLPRuntime.isDebug()) {
// prinitng this exception is discutable. I have let it in for case that
//some retyping will fail
- t.printStackTrace();
- }
+ OutputController.getLogger().log(t);
}
}
@@ -174,7 +173,7 @@ public class SplashUtils {
pluginSplashEnvironmetVar = System.getenv(ICEDTEA_WEB_PLUGIN_SPLASH);
splashEnvironmetVar = System.getenv(ICEDTEA_WEB_SPLASH);
} catch (Exception ex) {
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
}
SplashPanel sp = null;
if (SplashReason.JAVAWS.equals(splashReason)) {
diff --git a/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java b/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java
index 510ae00..93905fe 100644
--- a/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java
+++ b/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java
@@ -62,6 +62,7 @@ import net.sourceforge.jnlp.splashscreen.SplashUtils.SplashReason;
import net.sourceforge.jnlp.splashscreen.parts.BasicComponentSplashScreen;
import net.sourceforge.jnlp.splashscreen.parts.InfoItem;
import net.sourceforge.jnlp.splashscreen.parts.InformationElement;
+import net.sourceforge.jnlp.util.logging.OutputController;
import net.sourceforge.jnlp.util.ScreenFinder;
public class BasePainter implements Observer {
@@ -416,7 +417,7 @@ public class BasePainter implements Observer {
this.notifyObservers();
Thread.sleep(MOOVING_TEXT_DELAY);
} catch (Exception e) {
- e.printStackTrace();
+ OutputController.getLogger().log(e);
}
}
}
@@ -450,7 +451,7 @@ public class BasePainter implements Observer {
//it is risinfg slower and slower
Thread.sleep((waterLevel / 4) * 30);
} catch (Exception e) {
- e.printStackTrace();
+ OutputController.getLogger().log(e);
}
}
}
@@ -570,7 +571,7 @@ public class BasePainter implements Observer {
}
});
} catch (Exception ex) {
- ex.printStackTrace();
+ OutputController.getLogger().log(ex);
}
}
diff --git a/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/ErrorPainter.java b/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/ErrorPainter.java
index 96372c2..7374dbd 100644
--- a/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/ErrorPainter.java
+++ b/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/ErrorPainter.java
@@ -48,6 +48,7 @@ import java.util.Observable;
import net.sourceforge.jnlp.runtime.Translator;
import net.sourceforge.jnlp.splashscreen.parts.BasicComponentSplashScreen;
import net.sourceforge.jnlp.splashscreen.parts.InformationElement;
+import net.sourceforge.jnlp.util.logging.OutputController;
public final class ErrorPainter extends BasePainter {
@@ -231,7 +232,7 @@ public final class ErrorPainter extends BasePainter {
}
}
} catch (Exception e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
} finally {
canWave = true;
errorIsFlying = false;
diff --git a/netx/net/sourceforge/jnlp/splashscreen/parts/InformationElement.java b/netx/net/sourceforge/jnlp/splashscreen/parts/InformationElement.java
index 01e2655..1590831 100644
--- a/netx/net/sourceforge/jnlp/splashscreen/parts/InformationElement.java
+++ b/netx/net/sourceforge/jnlp/splashscreen/parts/InformationElement.java
@@ -45,6 +45,7 @@ import java.util.List;
import net.sourceforge.jnlp.InformationDesc;
import net.sourceforge.jnlp.JNLPFile;
import net.sourceforge.jnlp.runtime.Translator;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* This class is wrapper arround <information> tag which should
@@ -227,7 +228,7 @@ public class InformationElement {
ie.addDescription(file.getInformation().getDescriptionStrict(InfoItem.descriptionKindToolTip), InfoItem.descriptionKindToolTip);
return ie;
} catch (Exception ex) {
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
String message = Translator.R(InfoItem.SPLASH + "errorInInformation");
InformationElement ie = new InformationElement();
ie.setHomepage("");
diff --git a/netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java b/netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java
index e7e1779..02110ce 100644
--- a/netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java
+++ b/netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java
@@ -65,6 +65,7 @@ import javax.swing.event.HyperlinkListener;
import net.sourceforge.jnlp.LaunchException;
import net.sourceforge.jnlp.about.AboutDialog;
import net.sourceforge.jnlp.runtime.Translator;
+import net.sourceforge.jnlp.util.logging.OutputController;
public class JEditorPaneBasedExceptionDialog extends JDialog implements HyperlinkListener {
@@ -107,7 +108,7 @@ public class JEditorPaneBasedExceptionDialog extends JDialog implements Hyperlin
Icon icon = new ImageIcon(this.getClass().getResource("/net/sourceforge/jnlp/resources/warning.png"));
iconLabel.setIcon(icon);
} catch (Exception lex) {
- lex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, lex);
}
htmlErrorAndHelpPanel.addHyperlinkListener(this);
homeButton.setVisible(false);
@@ -198,7 +199,7 @@ public class JEditorPaneBasedExceptionDialog extends JDialog implements Hyperlin
try{
AboutDialog.display(true);
}catch(Exception ex){
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
JOptionPane.showConfirmDialog(JEditorPaneBasedExceptionDialog.this, ex);
}
}
@@ -228,8 +229,8 @@ public class JEditorPaneBasedExceptionDialog extends JDialog implements Hyperlin
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(data, data);
} catch (Exception ex) {
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
JOptionPane.showMessageDialog(this, Translator.R(InfoItem.SPLASH + "cantCopyEx"));
- ex.printStackTrace();
}
} else {
JOptionPane.showMessageDialog(this, Translator.R(InfoItem.SPLASH + "noExRecorded"));
@@ -302,18 +303,14 @@ public class JEditorPaneBasedExceptionDialog extends JDialog implements Hyperlin
if (exception == null) {
return "";
}
- StringWriter sw = new StringWriter();
- exception.printStackTrace(new PrintWriter(sw));
- return sw.toString();
+ return OutputController.exceptionToString(exception);
}
public static String[] getExceptionStackTraceAsStrings(Throwable exception) {
if (exception == null) {
return new String[0];
}
- StringWriter sw = new StringWriter();
- exception.printStackTrace(new PrintWriter(sw));
- return sw.toString().split("\n");
+ return OutputController.exceptionToString(exception).split("\n");
}
@Override
diff --git a/netx/net/sourceforge/jnlp/tools/CertInformation.java b/netx/net/sourceforge/jnlp/tools/CertInformation.java
index 6d6d27e..18a7b64 100644
--- a/netx/net/sourceforge/jnlp/tools/CertInformation.java
+++ b/netx/net/sourceforge/jnlp/tools/CertInformation.java
@@ -46,6 +46,7 @@ import java.util.List;
import java.util.Map;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* Maintains information about a CertPath that has signed at least one of the
@@ -163,8 +164,7 @@ public class CertInformation {
*/
public void setNumJarEntriesSigned(String jarName, int signedEntriesCount) {
if (signedJars.containsKey(jarName)) {
- if (JNLPRuntime.isDebug())
- System.err.println("WARNING: A jar that has already been "
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "WARNING: A jar that has already been "
+ "verified is being yet again verified: " + jarName);
} else {
signedJars.put(jarName, signedEntriesCount);
diff --git a/netx/net/sourceforge/jnlp/tools/JarCertVerifier.java b/netx/net/sourceforge/jnlp/tools/JarCertVerifier.java
index db9699d..31270e8 100644
--- a/netx/net/sourceforge/jnlp/tools/JarCertVerifier.java
+++ b/netx/net/sourceforge/jnlp/tools/JarCertVerifier.java
@@ -52,6 +52,7 @@ import net.sourceforge.jnlp.security.AppVerifier;
import net.sourceforge.jnlp.security.CertVerifier;
import net.sourceforge.jnlp.security.CertificateUtils;
import net.sourceforge.jnlp.security.KeyStores;
+import net.sourceforge.jnlp.util.logging.OutputController;
import sun.security.util.DerInputStream;
import sun.security.util.DerValue;
import sun.security.x509.NetscapeCertTypeExtension;
@@ -117,19 +118,15 @@ public class JarCertVerifier implements CertVerifier {
public boolean getAlreadyTrustPublisher() {
boolean allPublishersTrusted = appVerifier.hasAlreadyTrustedPublisher(
certs, jarSignableEntries);
- if (JNLPRuntime.isDebug()) {
- System.out.println("App already has trusted publisher: "
+ OutputController.getLogger().log("App already has trusted publisher: "
+ allPublishersTrusted);
- }
return allPublishersTrusted;
}
public boolean getRootInCacerts() {
boolean allRootCAsTrusted = appVerifier.hasRootInCacerts(certs,
jarSignableEntries);
- if (JNLPRuntime.isDebug()) {
- System.out.println("App has trusted root CA: " + allRootCAsTrusted);
- }
+ OutputController.getLogger().log("App has trusted root CA: " + allRootCAsTrusted);
return allRootCAsTrusted;
}
@@ -181,10 +178,8 @@ public class JarCertVerifier implements CertVerifier {
return true;
boolean fullySigned = appVerifier.isFullySigned(certs,
jarSignableEntries);
- if (JNLPRuntime.isDebug()) {
- System.out.println("App already has trusted publisher: "
+ OutputController.getLogger().log("App already has trusted publisher: "
+ fullySigned);
- }
return fullySigned;
}
@@ -292,7 +287,7 @@ public class JarCertVerifier implements CertVerifier {
entriesVec);
} catch (Exception e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
throw e;
} finally { // close the resource
if (jarFile != null) {
@@ -418,10 +413,8 @@ public class JarCertVerifier implements CertVerifier {
result = VerifyResult.UNSIGNED;
}
- if (JNLPRuntime.isDebug()) {
- System.out.println("Jar found at " + jarName
+ OutputController.getLogger().log("Jar found at " + jarName
+ "has been verified as " + result);
- }
return result;
}
@@ -452,9 +445,7 @@ public class JarCertVerifier implements CertVerifier {
// TODO: Warn user about not being able to
// look through their cacerts/trusted.certs
// file depending on exception.
- if (JNLPRuntime.isDebug()) {
- System.out.println("WARNING: Unable to read through cert store files.");
- }
+ OutputController.getLogger().log("WARNING: Unable to read through cert store files.");
throw e;
}
diff --git a/netx/net/sourceforge/jnlp/util/BasicExceptionDialog.java b/netx/net/sourceforge/jnlp/util/BasicExceptionDialog.java
index 3966c17..2fca402 100644
--- a/netx/net/sourceforge/jnlp/util/BasicExceptionDialog.java
+++ b/netx/net/sourceforge/jnlp/util/BasicExceptionDialog.java
@@ -37,14 +37,13 @@ exception statement from your version. */
package net.sourceforge.jnlp.util;
+import net.sourceforge.jnlp.util.logging.OutputController;
import static net.sourceforge.jnlp.runtime.Translator.R;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.io.PrintWriter;
-import java.io.StringWriter;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
@@ -62,12 +61,6 @@ import javax.swing.JTextArea;
*/
public class BasicExceptionDialog {
- private static String exceptionToString(Exception exception) {
- StringWriter stringWriter = new StringWriter();
- PrintWriter printWriter = new PrintWriter(stringWriter);
- exception.printStackTrace(printWriter);
- return stringWriter.toString();
- }
/**
* Must be invoked from the Swing EDT.
@@ -75,7 +68,7 @@ public class BasicExceptionDialog {
* @param exception the exception to indicate
*/
public static void show(Exception exception) {
- String detailsText = exceptionToString(exception);
+ String detailsText = OutputController.exceptionToString(exception);
final JPanel mainPanel = new JPanel(new BorderLayout());
mainPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
diff --git a/netx/net/sourceforge/jnlp/util/FileUtils.java b/netx/net/sourceforge/jnlp/util/FileUtils.java
index d149bc0..f1ee124 100644
--- a/netx/net/sourceforge/jnlp/util/FileUtils.java
+++ b/netx/net/sourceforge/jnlp/util/FileUtils.java
@@ -16,6 +16,7 @@
package net.sourceforge.jnlp.util;
+import net.sourceforge.jnlp.util.logging.OutputController;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import static net.sourceforge.jnlp.runtime.Translator.R;
@@ -146,7 +147,7 @@ public final class FileUtils {
public static void deleteWithErrMesg(File f, String eMsg) {
if (f.exists()) {
if (!f.delete()) {
- System.err.println(R("RCantDeleteFile", eMsg == null ? f : eMsg));
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, R("RCantDeleteFile", eMsg == null ? f : eMsg));
}
}
}
@@ -187,34 +188,34 @@ public final class FileUtils {
if (JNLPRuntime.isWindows()) {
// remove all permissions
if (!tempFile.setExecutable(false, false)) {
- System.err.println(R("RRemoveXPermFailed", tempFile));
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, R("RRemoveXPermFailed", tempFile));
}
if (!tempFile.setReadable(false, false)) {
- System.err.println(R("RRemoveRPermFailed", tempFile));
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, R("RRemoveRPermFailed", tempFile));
}
if (!tempFile.setWritable(false, false)) {
- System.err.println(R("RRemoveWPermFailed", tempFile));
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, R("RRemoveWPermFailed", tempFile));
}
// allow owner to read
if (!tempFile.setReadable(true, true)) {
- System.err.println(R("RGetRPermFailed", tempFile));
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, R("RGetRPermFailed", tempFile));
}
// allow owner to write
if (writableByOwner && !tempFile.setWritable(true, true)) {
- System.err.println(R("RGetWPermFailed", tempFile));
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, R("RGetWPermFailed", tempFile));
}
// allow owner to enter directories
if (isDir && !tempFile.setExecutable(true, true)) {
- System.err.println(R("RGetXPermFailed", tempFile));
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, R("RGetXPermFailed", tempFile));
}
// rename this file. Unless the file is moved/renamed, any program that
// opened the file right after it was created might still be able to
// read the data.
if (!tempFile.renameTo(file)) {
- System.err.println(R("RCantRename", tempFile, file));
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, R("RCantRename", tempFile, file));
}
} else {
// remove all permissions
@@ -318,9 +319,7 @@ public final class FileUtils {
* outside the base
*/
public static void recursiveDelete(File file, File base) throws IOException {
- if (JNLPRuntime.isDebug()) {
- System.err.println("Deleting: " + file);
- }
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Deleting: " + file);
if (!(file.getCanonicalPath().startsWith(base.getCanonicalPath()))) {
throw new IOException("Trying to delete a file outside Netx's basedir: "
@@ -373,7 +372,7 @@ public final class FileUtils {
}
}
} catch (IOException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
return lock;
}
diff --git a/netx/net/sourceforge/jnlp/util/HttpUtils.java b/netx/net/sourceforge/jnlp/util/HttpUtils.java
index 5bbfa69..9d69976 100644
--- a/netx/net/sourceforge/jnlp/util/HttpUtils.java
+++ b/netx/net/sourceforge/jnlp/util/HttpUtils.java
@@ -36,6 +36,7 @@
*/
package net.sourceforge.jnlp.util;
+import net.sourceforge.jnlp.util.logging.OutputController;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
@@ -50,7 +51,7 @@ public class HttpUtils {
try {
consumeAndCloseConnection(c);
} catch (IOException ex) {
- ex.printStackTrace(System.err);
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
}
}
diff --git a/netx/net/sourceforge/jnlp/util/ImageResources.java b/netx/net/sourceforge/jnlp/util/ImageResources.java
index 0f03ffb..b4260b6 100644
--- a/netx/net/sourceforge/jnlp/util/ImageResources.java
+++ b/netx/net/sourceforge/jnlp/util/ImageResources.java
@@ -37,6 +37,7 @@ exception statement from your version. */
package net.sourceforge.jnlp.util;
+import net.sourceforge.jnlp.util.logging.OutputController;
import java.awt.Image;
import java.io.IOException;
import java.io.InputStream;
@@ -81,7 +82,7 @@ public enum ImageResources {
cache.put(APPLICATION_ICON_PATH, image);
return image;
} catch (IOException ioe) {
- ioe.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ioe);
return null;
}
}
diff --git a/netx/net/sourceforge/jnlp/util/PropertiesFile.java b/netx/net/sourceforge/jnlp/util/PropertiesFile.java
index b9dd176..15c000d 100644
--- a/netx/net/sourceforge/jnlp/util/PropertiesFile.java
+++ b/netx/net/sourceforge/jnlp/util/PropertiesFile.java
@@ -16,6 +16,7 @@
package net.sourceforge.jnlp.util;
+import net.sourceforge.jnlp.util.logging.OutputController;
import java.io.*;
import java.util.*;
@@ -138,7 +139,7 @@ public class PropertiesFile extends Properties {
}
}
} catch (IOException ex) {
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
}
}
@@ -164,7 +165,7 @@ public class PropertiesFile extends Properties {
if (s != null) s.close();
}
} catch (IOException ex) {
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
}
}
diff --git a/netx/net/sourceforge/jnlp/util/Reflect.java b/netx/net/sourceforge/jnlp/util/Reflect.java
index 0983424..6673974 100644
--- a/netx/net/sourceforge/jnlp/util/Reflect.java
+++ b/netx/net/sourceforge/jnlp/util/Reflect.java
@@ -16,6 +16,7 @@
package net.sourceforge.jnlp.util;
+import net.sourceforge.jnlp.util.logging.OutputController;
import java.lang.reflect.*;
/**
@@ -107,7 +108,7 @@ public class Reflect {
return m.invoke(object, args);
} catch (Exception ex) { // eat
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
return null;
}
}
@@ -131,7 +132,7 @@ public class Reflect {
}
}
} catch (Exception ex) { // eat
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
}
return null;
diff --git a/netx/net/sourceforge/jnlp/util/StreamUtils.java b/netx/net/sourceforge/jnlp/util/StreamUtils.java
index 294944a..9432d37 100644
--- a/netx/net/sourceforge/jnlp/util/StreamUtils.java
+++ b/netx/net/sourceforge/jnlp/util/StreamUtils.java
@@ -37,6 +37,7 @@ exception statement from your version.
package net.sourceforge.jnlp.util;
+import net.sourceforge.jnlp.util.logging.OutputController;
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
@@ -48,7 +49,7 @@ public class StreamUtils {
/**
* Closes a stream, without throwing IOException.
- * In case of IOException, prints the stack trace to System.err.
+ * In IOException is properly logged and consumed
*
* @param stream the stream that will be closed
*/
@@ -57,7 +58,7 @@ public class StreamUtils {
try {
stream.close();
} catch (IOException e) {
- e.printStackTrace(System.err);
+ OutputController.getLogger().log(e);
}
}
}
@@ -77,7 +78,11 @@ public class StreamUtils {
}
}
- public static String readStreamAsString(InputStream stream)
+ public static String readStreamAsString(InputStream stream) throws IOException {
+ return readStreamAsString(stream, false);
+ }
+
+ public static String readStreamAsString(InputStream stream, boolean includeEndOfLines)
throws IOException {
InputStreamReader is = new InputStreamReader(stream);
StringBuilder sb = new StringBuilder();
@@ -88,6 +93,9 @@ public class StreamUtils {
break;
}
sb.append(read);
+ if (includeEndOfLines){
+ sb.append('\n');
+ }
}
diff --git a/netx/net/sourceforge/jnlp/util/TimedHashMap.java b/netx/net/sourceforge/jnlp/util/TimedHashMap.java
index 81496ee..4638d94 100644
--- a/netx/net/sourceforge/jnlp/util/TimedHashMap.java
+++ b/netx/net/sourceforge/jnlp/util/TimedHashMap.java
@@ -37,6 +37,7 @@ exception statement from your version. */
package net.sourceforge.jnlp.util;
+import net.sourceforge.jnlp.util.logging.OutputController;
import java.util.HashMap;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
@@ -82,15 +83,11 @@ public class TimedHashMap<K, V> {
// Item exists. If it has not expired, renew its access time and return it
if (age <= expiry) {
- if (JNLPRuntime.isDebug()) {
- System.err.println("Returning proxy " + actualMap.get(key) + " from cache for " + key);
- }
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Returning proxy " + actualMap.get(key) + " from cache for " + key);
timeStamps.put(key, System.nanoTime());
return actualMap.get(key);
} else {
- if (JNLPRuntime.isDebug()) {
- System.err.println("Proxy cache for " + key + " has expired (age=" + (age * 1e-9) + " seconds)");
- }
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Proxy cache for " + key + " has expired (age=" + (age * 1e-9) + " seconds)");
}
}
diff --git a/netx/net/sourceforge/jnlp/util/UrlUtils.java b/netx/net/sourceforge/jnlp/util/UrlUtils.java
index 73d896a..f090266 100644
--- a/netx/net/sourceforge/jnlp/util/UrlUtils.java
+++ b/netx/net/sourceforge/jnlp/util/UrlUtils.java
@@ -37,6 +37,7 @@ exception statement from your version.
package net.sourceforge.jnlp.util;
+import net.sourceforge.jnlp.util.logging.OutputController;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@@ -55,9 +56,9 @@ public class UrlUtils {
URL strippedUrl = new URL(urlParts[0]);
return normalizeUrl(strippedUrl, encodeFileUrls);
} catch (IOException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
} catch (URISyntaxException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
return url;
}
@@ -81,7 +82,7 @@ public class UrlUtils {
try {
return new URL(URLDecoder.decode(url.toString(), UTF8));
} catch (IOException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
return url;
}
}
@@ -134,11 +135,11 @@ public class UrlUtils {
try {
return normalizeUrl(url, encodeFileUrls);
} catch (MalformedURLException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
} catch (UnsupportedEncodingException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
} catch (URISyntaxException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
return url;
}
diff --git a/netx/net/sourceforge/jnlp/util/XDesktopEntry.java b/netx/net/sourceforge/jnlp/util/XDesktopEntry.java
index 05c451e..57b1d7e 100644
--- a/netx/net/sourceforge/jnlp/util/XDesktopEntry.java
+++ b/netx/net/sourceforge/jnlp/util/XDesktopEntry.java
@@ -16,6 +16,7 @@
package net.sourceforge.jnlp.util;
+import net.sourceforge.jnlp.util.logging.OutputController;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
@@ -155,7 +156,7 @@ public class XDesktopEntry {
cacheIcon();
installDesktopLauncher();
} catch (Exception e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
}
@@ -195,9 +196,7 @@ public class XDesktopEntry {
String[] execString = new String[] { "xdg-desktop-icon", "install", "--novendor",
shortcutFile.getCanonicalPath() };
- if (JNLPRuntime.isDebug()) {
- System.err.println("Execing: " + Arrays.toString(execString));
- }
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Execing: " + Arrays.toString(execString));
Process installer = Runtime.getRuntime().exec(execString);
new StreamEater(installer.getInputStream()).start();
new StreamEater(installer.getErrorStream()).start();
@@ -205,7 +204,7 @@ public class XDesktopEntry {
try {
installer.waitFor();
} catch (InterruptedException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
if (!shortcutFile.delete()) {
@@ -213,9 +212,9 @@ public class XDesktopEntry {
}
} catch (FileNotFoundException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
} catch (IOException e) {
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
}
@@ -241,9 +240,7 @@ public class XDesktopEntry {
this.iconLocation = location.substring("file:".length());
- if (JNLPRuntime.isDebug()) {
- System.err.println("Cached desktop shortcut icon: " + this.iconLocation);
- }
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Cached desktop shortcut icon: " + this.iconLocation);
}
}
@@ -259,7 +256,7 @@ public class XDesktopEntry {
try {
return findFreedesktopOrgDesktopPath();
} catch (Exception ex) {
- ex.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
return System.getProperty("user.home") + "/Desktop/";
}
}
diff --git a/netx/net/sourceforge/jnlp/util/logging/FileLog.java b/netx/net/sourceforge/jnlp/util/logging/FileLog.java
new file mode 100644
index 0000000..05b079a
--- /dev/null
+++ b/netx/net/sourceforge/jnlp/util/logging/FileLog.java
@@ -0,0 +1,107 @@
+/* FileLog.java
+ Copyright (C) 2011, 2013 Red Hat, Inc.
+
+ This file is part of IcedTea.
+
+ IcedTea is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ IcedTea is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with IcedTea; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+package net.sourceforge.jnlp.util.logging;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.logging.FileHandler;
+import java.util.logging.Formatter;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+import net.sourceforge.jnlp.util.FileUtils;
+
+/**
+ * This class writes log information to file.
+ *
+ */
+public final class FileLog implements SingleStreamLogger {
+
+ private final Logger impl;
+ private final FileHandler fh;
+ private static final String defaultloggerName = "IcedTea-Web file-logger";
+
+ public FileLog() {
+ this(defaultloggerName, LogConfig.getLogConfig().getIcedteaLogDir() + "itw-" + java.lang.System.currentTimeMillis() + ".log", false);
+ }
+
+ public FileLog(boolean append) {
+ this(defaultloggerName, LogConfig.getLogConfig().getIcedteaLogDir() + "itw-" + java.lang.System.currentTimeMillis() + ".log", append);
+ }
+
+
+
+ public FileLog(String fileName, boolean append) {
+ this(fileName, fileName, append);
+ }
+
+ public FileLog(String loggerName, String fileName, boolean append) {
+ try{
+ File futureFile = new File(fileName);
+ if (!futureFile.exists()) {
+ FileUtils.createRestrictedFile(futureFile, true);
+ }
+ fh = new FileHandler(fileName, append);
+ fh.setFormatter(new Formatter() {
+ @Override
+ public String format(LogRecord record) {
+ return record.getMessage() + "\n";
+ }
+ });
+ impl = Logger.getLogger(loggerName);
+ impl.setLevel(Level.ALL);
+ impl.addHandler(fh);
+ log(OutputController.getHeader(null, null));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Log the String to file.
+ *
+ * @param e Exception that was thrown.
+ */
+ @Override
+ public synchronized void log(String s) {
+ impl.log(Level.FINE, s);
+ }
+
+ public void close(){
+ fh.close();
+ }
+}
diff --git a/netx/net/sourceforge/jnlp/util/logging/LogConfig.java b/netx/net/sourceforge/jnlp/util/logging/LogConfig.java
new file mode 100644
index 0000000..5e1644c
--- /dev/null
+++ b/netx/net/sourceforge/jnlp/util/logging/LogConfig.java
@@ -0,0 +1,156 @@
+/* LogConfig.java
+ Copyright (C) 2011, 2013 Red Hat, Inc.
+
+ This file is part of IcedTea.
+
+ IcedTea is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, version 2.
+
+ IcedTea is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with IcedTea; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version.
+ */
+package net.sourceforge.jnlp.util.logging;
+
+import java.io.File;
+import javax.naming.ConfigurationException;
+
+import net.sourceforge.jnlp.config.DeploymentConfiguration;
+import net.sourceforge.jnlp.runtime.JNLPRuntime;
+
+/**
+ * This file provides the information required to do logging.
+ *
+ */
+public class LogConfig {
+
+ // Directory where the logs are stored.
+ private String icedteaLogDir;
+ private boolean enableLogging;
+ private boolean enableHeaders;
+ private boolean logToFile;
+ private boolean logToStreams;
+ private boolean logToSysLog;
+
+ private static LogConfig logConfig;
+
+ public LogConfig() {
+ try {
+ DeploymentConfiguration 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!
+ }
+
+ // Check whether logging and tracing is enabled.
+ enableLogging = Boolean.parseBoolean(config.getProperty(DeploymentConfiguration.KEY_ENABLE_LOGGING));
+ //enagle disable headers
+ enableHeaders = Boolean.parseBoolean(config.getProperty(DeploymentConfiguration.KEY_ENABLE_LOGGING_HEADERS));
+ //enable/disable individual channels
+ logToFile = Boolean.parseBoolean(config.getProperty(DeploymentConfiguration.KEY_ENABLE_LOGGING_TOFILE));
+ logToStreams = Boolean.parseBoolean(config.getProperty(DeploymentConfiguration.KEY_ENABLE_LOGGING_TOSTREAMS));
+ logToSysLog = Boolean.parseBoolean(config.getProperty(DeploymentConfiguration.KEY_ENABLE_LOGGING_TOSYSTEMLOG));
+
+ // Get log directory, create it if it doesn't exist. If unable to create and doesn't exist, don't log.
+ icedteaLogDir = config.getProperty(DeploymentConfiguration.KEY_USER_LOG_DIR);
+ if (icedteaLogDir != null) {
+ File f = new File(icedteaLogDir);
+ if (f.isDirectory() || f.mkdirs()) {
+ icedteaLogDir += File.separator;
+ } else {
+ enableLogging = false;
+ }
+ }
+ } catch (ConfigurationException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static LogConfig getLogConfig() {
+ if (logConfig == null) {
+ logConfig = new LogConfig();
+ }
+ return logConfig;
+ }
+
+ public String getIcedteaLogDir() {
+ return icedteaLogDir;
+ }
+
+ public boolean isEnableLogging() {
+ return enableLogging;
+ }
+
+ public boolean isLogToFile() {
+ return logToFile;
+ }
+
+ public boolean isLogToStreams() {
+ return logToStreams;
+ }
+
+ public boolean isLogToSysLog() {
+ return logToSysLog;
+ }
+
+ public boolean isEnableHeaders() {
+ return enableHeaders;
+ }
+
+
+
+ //package private setters for testing
+
+ void setEnableHeaders(boolean enableHeaders) {
+ this.enableHeaders = enableHeaders;
+ }
+
+ void setEnableLogging(boolean enableLogging) {
+ this.enableLogging = enableLogging;
+ }
+
+ void setIcedteaLogDir(String icedteaLogDir) {
+ this.icedteaLogDir = icedteaLogDir;
+ }
+
+ void setLogToFile(boolean logToFile) {
+ this.logToFile = logToFile;
+ }
+
+ void setLogToStreams(boolean logToStreams) {
+ this.logToStreams = logToStreams;
+ }
+
+ void setLogToSysLog(boolean logToSysLog) {
+ this.logToSysLog = logToSysLog;
+ }
+
+
+
+
+}
diff --git a/netx/net/sourceforge/jnlp/util/logging/OutputController.java b/netx/net/sourceforge/jnlp/util/logging/OutputController.java
new file mode 100644
index 0000000..1efc691
--- /dev/null
+++ b/netx/net/sourceforge/jnlp/util/logging/OutputController.java
@@ -0,0 +1,398 @@
+/*Copyright (C) 2013 Red Hat, Inc.
+
+ This file is part of IcedTea.
+
+ IcedTea is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, version 2.
+
+ IcedTea is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with IcedTea; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version.
+ */
+package net.sourceforge.jnlp.util.logging;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
+import net.sourceforge.jnlp.runtime.JNLPRuntime;
+
+public class OutputController {
+
+ public static enum Level {
+
+ MESSAGE_ALL, // - stdout/log in all cases
+ MESSAGE_DEBUG, // - stdout/log in verbose/debug mode
+ WARNING_ALL, // - stdout+stderr/log in all cases (default for
+ WARNING_DEBUG, // - stdou+stde/logrr in verbose/debug mode
+ ERROR_ALL, // - stderr/log in all cases (default for
+ ERROR_DEBUG, // - stderr/log in verbose/debug mode
+ //ERROR_DEBUG is default for Throwable
+ //MESSAGE_VERBOSE is defautrl for String
+ }
+
+ private static final class MessageWithLevel {
+
+ public final String message;
+ public final Level level;
+ public final StackTraceElement[] stack = Thread.currentThread().getStackTrace();
+
+ public MessageWithLevel(String message, Level level) {
+ this.message = message;
+ this.level = level;
+ }
+ }
+ /*
+ * singleton instance
+ */
+ private static OutputController logger;
+ private static final String NULL_OBJECT = "Trying to log null object";
+ private FileLog fileLog;
+ private PrintStreamLogger outLog;
+ private PrintStreamLogger errLog;
+ private SingleStreamLogger sysLog;
+ private List<MessageWithLevel> messageQue = new LinkedList<MessageWithLevel>();
+ private MessageQueConsumer messageQueConsumer = new MessageQueConsumer();
+
+ //bounded to instance
+ private class MessageQueConsumer implements Runnable {
+
+ @Override
+ public void run() {
+ while (true) {
+ try {
+ synchronized (OutputController.this) {
+ OutputController.this.wait();
+ if (!(OutputController.this == null || messageQue.isEmpty())) {
+ flush();
+ }
+ }
+
+ } catch (Throwable t) {
+ OutputController.getLogger().log(t);
+ }
+ }
+ }
+ };
+
+ public synchronized void flush() {
+
+ while (!messageQue.isEmpty()) {
+ consume();
+ }
+ }
+
+ public void close() {
+ flush();
+ if (LogConfig.getLogConfig().isLogToFile()){
+ getFileLog().close();
+ }
+ }
+
+ private void consume() {
+ MessageWithLevel s = messageQue.get(0);
+ messageQue.remove(0);
+ if (!JNLPRuntime.isDebug() && (s.level == Level.MESSAGE_DEBUG
+ || s.level == Level.WARNING_DEBUG
+ || s.level == Level.ERROR_DEBUG)) {
+ //filter out debug messages
+ //must be here to prevent deadlock, casued by exception form jnlpruntime, loggers or configs themselves
+ return;
+ }
+ String message = s.message;
+ if (LogConfig.getLogConfig().isEnableHeaders()) {
+ if (message.contains("\n")) {
+ message = getHeader(s.level, s.stack) + "\n" + message;
+ } else {
+ message = getHeader(s.level, s.stack) + " " + message;
+ }
+ }
+ if (LogConfig.getLogConfig().isLogToStreams()) {
+ if (s.level == Level.MESSAGE_ALL
+ || s.level == Level.MESSAGE_DEBUG
+ || s.level == Level.WARNING_ALL
+ || s.level == Level.WARNING_DEBUG) {
+ outLog.log(message);
+ }
+ if (s.level == Level.ERROR_ALL
+ || s.level == Level.ERROR_DEBUG
+ || s.level == Level.WARNING_ALL
+ || s.level == Level.WARNING_DEBUG) {
+ errLog.log(message);
+ }
+ }
+ if (LogConfig.getLogConfig().isLogToFile()) {
+ getFileLog().log(message);
+ }
+ if (LogConfig.getLogConfig().isLogToSysLog()) {
+ getSystemLog().log(message);
+ }
+
+ }
+
+ private OutputController() {
+ this(System.out, System.err);
+ }
+
+ /**
+ * This should be the only legal way to get logger for ITW
+ *
+ * @return logging singleton
+ */
+ synchronized public static OutputController getLogger() {
+ if (logger == null) {
+ logger = new OutputController();
+ }
+ return logger;
+ }
+
+ /**
+ * for testing purposes the logger with custom streams can be created
+ * otherwise only getLogger()'s singleton can be called.
+ */
+ public OutputController(PrintStream out, PrintStream err) {
+ if (out == null || err == null) {
+ throw new IllegalArgumentException("No stream can be null");
+ }
+ outLog = new PrintStreamLogger(out);
+ errLog = new PrintStreamLogger(err);
+ //itw logger have to be fully initialised before start
+ Thread t = new Thread(messageQueConsumer);
+ t.setDaemon(true);
+ t.start();
+ //some messages were probably posted before start of consumer
+ synchronized (this){
+ this.notifyAll();
+ }
+ Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
+ @Override
+ public void run() {
+ while (!messageQue.isEmpty()) {
+ consume();
+ }
+ }
+ }));
+ }
+
+ /**
+ *
+ * @return current stream for std.out reprint
+ */
+ public PrintStream getOut() {
+ flush();
+ return outLog.getStream();
+ }
+
+ /**
+ *
+ * @return current stream for std.err reprint
+ */
+ public PrintStream getErr() {
+ flush();
+ return errLog.getStream();
+ }
+
+ /**
+ * Some tests may require set the output stream and check the output. This
+ * is the gate for it.
+ */
+ public void setOut(PrintStream out) {
+ flush();
+ this.outLog.setStream(out);
+ }
+
+ /**
+ * Some tests may require set the output stream and check the output. This
+ * is the gate for it.
+ */
+ public void setErr(PrintStream err) {
+ flush();
+ this.errLog.setStream(err);
+ }
+
+ public static String exceptionToString(Throwable t) {
+ if (t == null) {
+ return null;
+ }
+ String s = "Error during processing of exception";
+ try {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ t.printStackTrace(pw);
+ s = sw.toString();
+ pw.close();
+ sw.close();
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ return s;
+ }
+
+ public void log(Level level, String s) {
+ log(level, (Object) s);
+ }
+
+ public void log(Level level, Throwable s) {
+ log(level, (Object) s);
+ }
+
+ public void log(String s) {
+ log(Level.MESSAGE_DEBUG, (Object) s);
+ }
+
+ public void log(Throwable s) {
+ log(Level.ERROR_DEBUG, (Object) s);
+ }
+
+ private synchronized void log(Level level, Object o) {
+ if (o == null) {
+ messageQue.add(new MessageWithLevel(NULL_OBJECT, level));
+ } else if (o instanceof Throwable) {
+ messageQue.add(new MessageWithLevel(exceptionToString((Throwable) o), level));
+ } else {
+ messageQue.add(new MessageWithLevel(o.toString(), level));
+ }
+ this.notifyAll();
+ }
+
+ private FileLog getFileLog() {
+ if (fileLog == null) {
+ fileLog = new FileLog();
+ }
+ return fileLog;
+ }
+
+ private SingleStreamLogger getSystemLog() {
+ if (sysLog == null) {
+ if (JNLPRuntime.isWindows()) {
+ sysLog = new WinSystemLog();
+ } else {
+ sysLog = new UnixSystemLog();
+ }
+ }
+ return sysLog;
+ }
+
+ public void printErrorLn(String e) {
+ getErr().println(e);
+
+ }
+
+ public void printOutLn(String e) {
+ getOut().println(e);
+
+ }
+
+ public void printWarningLn(String e) {
+ printOutLn(e);
+ printErrorLn(e);
+ }
+
+ public void printError(String e) {
+ getErr().print(e);
+
+ }
+
+ public void printOut(String e) {
+ getOut().print(e);
+
+ }
+
+ public void printWarning(String e) {
+ printOut(e);
+ printError(e);
+ }
+
+ public static String getHeader(Level level, StackTraceElement[] stack) {
+ StringBuilder sb = new StringBuilder();
+ try {
+ String user = System.getProperty("user.name");
+ sb.append("[").append(user).append("]");
+ if (JNLPRuntime.isWebstartApplication()) {
+ sb.append("[ITW-JAVAWS]");
+ } else {
+ sb.append("[ITW]");
+ }
+ if (level != null) {
+ sb.append('[').append(level.toString()).append(']');
+ }
+ sb.append('[').append(new Date().toString()).append(']');
+ if (stack != null) {
+ sb.append('[').append(getCallerClass(stack)).append(']');
+ }
+ } catch (Exception ex) {
+ getLogger().log(ex);
+ }
+ return sb.toString();
+
+ }
+
+ static String getCallerClass(StackTraceElement[] stack) {
+ try {
+ //0 is always thread
+ //1..? is OutputController itself
+ //pick up first after.
+ StackTraceElement result = stack[0];
+ int i = 1;
+ for (; i < stack.length; i++) {
+ result = stack[i];//at least moving up
+ if (stack[i].getClassName().contains(OutputController.class.getName())) {
+ continue;
+ } else {
+ break;
+ }
+ }
+ return result.toString();
+ } catch (Exception ex) {
+ getLogger().log(ex);
+ return "Unknown caller";
+ }
+ }
+
+
+ //package private setters for testing
+
+ void setErrLog(PrintStreamLogger errLog) {
+ this.errLog = errLog;
+ }
+
+ void setFileLog(FileLog fileLog) {
+ this.fileLog = fileLog;
+ }
+
+ void setOutLog(PrintStreamLogger outLog) {
+ this.outLog = outLog;
+ }
+
+ void setSysLog(SingleStreamLogger sysLog) {
+ this.sysLog = sysLog;
+ }
+
+
+}
diff --git a/netx/net/sourceforge/jnlp/util/logging/PrintStreamLogger.java b/netx/net/sourceforge/jnlp/util/logging/PrintStreamLogger.java
new file mode 100644
index 0000000..2cba912
--- /dev/null
+++ b/netx/net/sourceforge/jnlp/util/logging/PrintStreamLogger.java
@@ -0,0 +1,68 @@
+/*Copyright (C) 2013 Red Hat, Inc.
+
+ This file is part of IcedTea.
+
+ IcedTea is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, version 2.
+
+ IcedTea is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with IcedTea; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version.
+ */
+
+package net.sourceforge.jnlp.util.logging;
+
+import java.io.PrintStream;
+
+public class PrintStreamLogger implements SingleStreamLogger{
+ private PrintStream stream;
+
+ public PrintStreamLogger(PrintStream stream){
+ this.stream = stream;
+ }
+
+
+ @Override
+ public void log(String s) {
+ stream.println(s);
+ }
+
+ public PrintStream getStream() {
+ return stream;
+ }
+
+ public void setStream(PrintStream stream) {
+ this.stream = stream;
+ }
+
+
+
+
+
+
+
+}
diff --git a/netx/net/sourceforge/jnlp/util/logging/SingleStreamLogger.java b/netx/net/sourceforge/jnlp/util/logging/SingleStreamLogger.java
new file mode 100644
index 0000000..6e34b99
--- /dev/null
+++ b/netx/net/sourceforge/jnlp/util/logging/SingleStreamLogger.java
@@ -0,0 +1,46 @@
+/*Copyright (C) 2013 Red Hat, Inc.
+
+ This file is part of IcedTea.
+
+ IcedTea is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, version 2.
+
+ IcedTea is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with IcedTea; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version.
+ */
+
+package net.sourceforge.jnlp.util.logging;
+
+public interface SingleStreamLogger {
+
+
+
+ public void log(String s);
+
+
+}
diff --git a/netx/net/sourceforge/jnlp/util/logging/UnixSystemLog.java b/netx/net/sourceforge/jnlp/util/logging/UnixSystemLog.java
new file mode 100644
index 0000000..157d91f
--- /dev/null
+++ b/netx/net/sourceforge/jnlp/util/logging/UnixSystemLog.java
@@ -0,0 +1,57 @@
+/*Copyright (C) 2013 Red Hat, Inc.
+
+ This file is part of IcedTea.
+
+ IcedTea is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, version 2.
+
+ IcedTea is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with IcedTea; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version.
+ */
+
+package net.sourceforge.jnlp.util.logging;
+
+
+
+public class UnixSystemLog implements SingleStreamLogger{
+
+ public UnixSystemLog(){
+
+ }
+
+
+ @Override
+ public void log(String s) {
+
+ }
+
+
+
+
+
+}
diff --git a/netx/net/sourceforge/jnlp/util/logging/WinSystemLog.java b/netx/net/sourceforge/jnlp/util/logging/WinSystemLog.java
new file mode 100644
index 0000000..59f015b
--- /dev/null
+++ b/netx/net/sourceforge/jnlp/util/logging/WinSystemLog.java
@@ -0,0 +1,57 @@
+/*Copyright (C) 2013 Red Hat, Inc.
+
+ This file is part of IcedTea.
+
+ IcedTea is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, version 2.
+
+ IcedTea is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with IcedTea; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version.
+ */
+
+package net.sourceforge.jnlp.util.logging;
+
+
+
+public class WinSystemLog implements SingleStreamLogger{
+
+ public WinSystemLog(){
+
+ }
+
+
+ @Override
+ public void log(String s) {
+ //not yet implemented
+ }
+
+
+
+
+
+}
diff --git a/netx/net/sourceforge/nanoxml/XMLElement.java b/netx/net/sourceforge/nanoxml/XMLElement.java
index 662b6cb..dab8056 100644
--- a/netx/net/sourceforge/nanoxml/XMLElement.java
+++ b/netx/net/sourceforge/nanoxml/XMLElement.java
@@ -34,6 +34,7 @@ import java.io.*;
import java.util.*;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import net.sourceforge.jnlp.util.logging.OutputController;
/**
* XMLElement is a representation of an XML object. The object is able to parse
@@ -1204,11 +1205,11 @@ public class XMLElement {
out.flush();
if (JNLPRuntime.isDebug()) {
if (ch == 10) {
- System.out.println();
- System.out.print("line: " + newline + " ");
+ OutputController.getLogger().printOutLn("");
+ OutputController.getLogger().printOut("line: " + newline + " ");
newline++;
} else {
- System.out.print(ch);
+ OutputController.getLogger().printOut(ch+"");
}
}
break;
@@ -1235,9 +1236,9 @@ public class XMLElement {
out.print('-');
this.sanitizeCharReadTooMuch = ch;
if (JNLPRuntime.isDebug()) {
- System.out.print('<');
- System.out.print('!');
- System.out.print('-');
+ OutputController.getLogger().printOut("<");
+ OutputController.getLogger().printOut("!");
+ OutputController.getLogger().printOut("-");
}
}
} else {
@@ -1245,8 +1246,8 @@ public class XMLElement {
out.print('!');
this.sanitizeCharReadTooMuch = ch;
if (JNLPRuntime.isDebug()) {
- System.out.print('<');
- System.out.print('!');
+ OutputController.getLogger().printOut("<");
+ OutputController.getLogger().printOut("!");
}
}
}
@@ -1255,11 +1256,11 @@ public class XMLElement {
out.print(ch);
if (JNLPRuntime.isDebug()) {
if (ch == 10) {
- System.out.println();
- System.out.print("line: " + newline + " ");
+ OutputController.getLogger().printOutLn("");
+ OutputController.getLogger().printOut("line: " + newline + " ");
newline++;
} else {
- System.out.print(ch);
+ OutputController.getLogger().printOut(ch+"");
}
}
}
@@ -1271,7 +1272,7 @@ public class XMLElement {
} catch (Exception e) {
// Print the stack trace here -- xml.parseFromReader() will
// throw the ParseException if something goes wrong.
- e.printStackTrace();
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
}
}