diff options
author | Jiri Vanek <[email protected]> | 2013-09-25 18:50:18 +0200 |
---|---|---|
committer | Jiri Vanek <[email protected]> | 2013-09-25 18:50:18 +0200 |
commit | 19e74fe5dacd03e0cb5582f840e15262e39fe24f (patch) | |
tree | 38ffc4f47f7641f8d20ba0e0e8a97a97ffb1db64 /plugin/icedteanp/java/sun | |
parent | fcd5c4c69fc5ea84b04f309eb40e295eab921fd8 (diff) |
Introduced logging bottleneck
Diffstat (limited to 'plugin/icedteanp/java/sun')
12 files changed, 80 insertions, 69 deletions
diff --git a/plugin/icedteanp/java/sun/applet/JavaConsole.java b/plugin/icedteanp/java/sun/applet/JavaConsole.java index 9074e1b..a7c7aab 100644 --- a/plugin/icedteanp/java/sun/applet/JavaConsole.java +++ b/plugin/icedteanp/java/sun/applet/JavaConsole.java @@ -66,6 +66,7 @@ import javax.swing.border.TitledBorder; import net.sourceforge.jnlp.config.DeploymentConfiguration; import net.sourceforge.jnlp.runtime.JNLPRuntime; import net.sourceforge.jnlp.util.ImageResources; +import net.sourceforge.jnlp.util.logging.OutputController; /** * A simple Java console for IcedTeaPlugin @@ -87,7 +88,7 @@ public class JavaConsole { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { - e.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); } final String logDir = JNLPRuntime.getConfiguration().getProperty(DeploymentConfiguration.KEY_USER_LOG_DIR); @@ -154,9 +155,9 @@ public class JavaConsole { gcButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { printMemoryInfo(); - System.out.print("Performing Garbage Collection...."); + OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "Performing Garbage Collection...."); System.gc(); - System.out.println("Done"); + OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "Done"); printMemoryInfo(); } @@ -167,9 +168,9 @@ public class JavaConsole { finalizersButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { printMemoryInfo(); - System.out.print("Running finalization...."); + OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "Running finalization...."); Runtime.getRuntime().runFinalization(); - System.out.println("Done"); + OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "Done"); printMemoryInfo(); } }); @@ -253,40 +254,40 @@ public class JavaConsole { protected void printSystemProperties() { - System.out.println(" ----"); - System.out.println("System Properties:"); - System.out.println(); + OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " ----"); + OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "System Properties:"); + OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, ""); Properties p = System.getProperties(); Set<Object> keys = p.keySet(); for (Object key : keys) { - System.out.println(key.toString() + ": " + p.get(key)); + OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, key.toString() + ": " + p.get(key)); } - System.out.println(" ----"); + OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " ----"); } private void printClassLoaders() { - System.out.println(" ----"); - System.out.println("Available Classloaders: "); + OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " ----"); + OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "Available Classloaders: "); Set<String> loaders = PluginAppletSecurityContext.getLoaderInfo().keySet(); for (String loader : loaders) { - System.out.println(loader + "\n" + OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, loader + "\n" + " codebase = " + PluginAppletSecurityContext.getLoaderInfo().get(loader)); } - System.out.println(" ----"); + OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " ----"); } private void printMemoryInfo() { - System.out.println(" ----- "); - System.out.println(" Memory Info:"); - System.out.println(" Max Memory: " + OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " ----- "); + OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " Memory Info:"); + OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " Max Memory: " + String.format("%1$10d", Runtime.getRuntime().maxMemory())); - System.out.println(" Total Memory: " + OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " Total Memory: " + String.format("%1$10d", Runtime.getRuntime().totalMemory())); - System.out.println(" Free Memory: " + OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " Free Memory: " + String.format("%1$10d", Runtime.getRuntime().freeMemory())); - System.out.println(" ----"); + OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " ----"); } @@ -294,9 +295,9 @@ public class JavaConsole { Map<Thread, StackTraceElement[]> map = Thread.getAllStackTraces(); Set<Thread> keys = map.keySet(); for (Thread key : keys) { - System.out.println("Thread " + key.getId() + ": " + key.getName()); + OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "Thread " + key.getId() + ": " + key.getName()); for (StackTraceElement element : map.get(key)) { - System.out.println(" " + element); + OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " " + element); } } @@ -355,13 +356,11 @@ public class JavaConsole { } } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); } catch (InterruptedException e) { - e.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); Thread.currentThread().interrupt(); } diff --git a/plugin/icedteanp/java/sun/applet/PluginAppletPanelFactory.java b/plugin/icedteanp/java/sun/applet/PluginAppletPanelFactory.java index e368eca..429cb62 100644 --- a/plugin/icedteanp/java/sun/applet/PluginAppletPanelFactory.java +++ b/plugin/icedteanp/java/sun/applet/PluginAppletPanelFactory.java @@ -71,6 +71,7 @@ import javax.swing.SwingUtilities; import net.sourceforge.jnlp.NetxPanel; import net.sourceforge.jnlp.PluginParameters; +import net.sourceforge.jnlp.util.logging.OutputController; /** * Lets us construct one using unix-style one shot behaviors @@ -115,7 +116,7 @@ class PluginAppletPanelFactory { try { panelInit.join(); } catch (InterruptedException e) { - e.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); } setAppletViewerSize(panel, params.getWidth(), params.getHeight()); @@ -161,11 +162,11 @@ class PluginAppletPanelFactory { } catch (InvocationTargetException e) { // Not being able to resize is non-fatal PluginDebug.debug("Unable to resize panel: "); - e.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); } catch (InterruptedException e) { // Not being able to resize is non-fatal PluginDebug.debug("Unable to resize panel: "); - e.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); } } /** diff --git a/plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java b/plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java index cef0ac9..fb343f3 100644 --- a/plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java +++ b/plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java @@ -60,6 +60,7 @@ import java.util.Map; import net.sourceforge.jnlp.DefaultLaunchHandler; import net.sourceforge.jnlp.runtime.JNLPRuntime; +import net.sourceforge.jnlp.util.logging.OutputController; import netscape.javascript.JSObject; import netscape.javascript.JSObjectCreatePermission; import netscape.javascript.JSUtil; @@ -250,7 +251,7 @@ public class PluginAppletSecurityContext { // that JNLPRuntime will try to install if (System.getSecurityManager() == null) { JNLPRuntime.initialize(/* isApplication */false); - JNLPRuntime.setDefaultLaunchHandler(new DefaultLaunchHandler(System.err)); + JNLPRuntime.setDefaultLaunchHandler(new DefaultLaunchHandler(OutputController.getLogger())); } JNLPRuntime.disableExit(); @@ -260,7 +261,7 @@ public class PluginAppletSecurityContext { try { u = new URL("file://"); } catch (Exception e) { - e.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); } this.classLoaders.put(liveconnectLoader, u); @@ -1058,7 +1059,7 @@ public class PluginAppletSecurityContext { write(reference, "GetClassID " + store.getIdentifier(store.getObject(objectID).getClass())); } } catch (Throwable t) { - t.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,t); String msg = t.getCause() != null ? t.getCause().getMessage() : t.getMessage(); // add an identifier string to let javaside know of the type of error @@ -1182,7 +1183,7 @@ public class PluginAppletSecurityContext { store.reference(c); } catch (ClassNotFoundException cnfe) { // do nothing ... this should never happen - cnfe.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,cnfe); } return store.getIdentifier(c); @@ -1207,7 +1208,7 @@ public class PluginAppletSecurityContext { } } catch (NoSuchMethodException e) { // should never happen - e.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); } return store.getIdentifier(m); @@ -1221,10 +1222,10 @@ public class PluginAppletSecurityContext { f = c.getField(fieldName); } catch (SecurityException e) { // should never happen - e.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); } catch (NoSuchFieldException e) { // should never happen - e.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); } store.reference(f); diff --git a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java index cfa3109..f0c1cc5 100644 --- a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java +++ b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java @@ -122,6 +122,7 @@ import sun.awt.X11.XEmbeddedFrame; import sun.misc.Ref; import com.sun.jndi.toolkit.url.UrlUtil; +import net.sourceforge.jnlp.util.logging.OutputController; /* */ @@ -268,7 +269,7 @@ public class PluginAppletViewer extends XEmbeddedFrame try { SwingUtilities.invokeAndWait(new SplashCreator(fPanel)); } catch (Exception e) { - e.printStackTrace(); // Not much we can do other than print + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); // Not much we can do other than print } } @@ -298,7 +299,7 @@ public class PluginAppletViewer extends XEmbeddedFrame } }); } catch (Exception e) { - e.printStackTrace(); // Not much we can do other than print + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); // Not much we can do other than print } } @@ -325,7 +326,7 @@ public class PluginAppletViewer extends XEmbeddedFrame } }); } catch (Exception e) { - e.printStackTrace(); // Not much we can do other than print + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); // Not much we can do other than print } } @@ -550,7 +551,7 @@ public class PluginAppletViewer extends XEmbeddedFrame } } catch (Exception e) { - e.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); // If an exception happened during pre-init, we need to update status updateStatus(identifier, PAV_INIT_STATUS.INACTIVE); @@ -835,8 +836,8 @@ public class PluginAppletViewer extends XEmbeddedFrame return ref; } } catch (Exception e) { - System.err.println("Error occurred when trying to fetch image:"); - e.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Error occurred when trying to fetch image:"); + OutputController.getLogger().log(e); return null; } } @@ -1213,7 +1214,7 @@ public class PluginAppletViewer extends XEmbeddedFrame " " + encodedURI, reference); } catch (UnsupportedEncodingException e) { - e.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); return null; } @@ -1255,7 +1256,7 @@ public class PluginAppletViewer extends XEmbeddedFrame requestURI = UrlUtil.encode(scheme + "://" + uri.getHost() + port + "/" + uri.getPath(), "UTF-8"); } catch (Exception e) { PluginDebug.debug("Cannot construct URL from ", uri.toString(), " ... falling back to DIRECT proxy"); - e.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); return null; } diff --git a/plugin/icedteanp/java/sun/applet/PluginDebug.java b/plugin/icedteanp/java/sun/applet/PluginDebug.java index 54787a4..8de96f1 100644 --- a/plugin/icedteanp/java/sun/applet/PluginDebug.java +++ b/plugin/icedteanp/java/sun/applet/PluginDebug.java @@ -37,9 +37,12 @@ exception statement from your version. */ package sun.applet; +import net.sourceforge.jnlp.runtime.JNLPRuntime; +import net.sourceforge.jnlp.util.logging.OutputController; + public class PluginDebug { - static final boolean DEBUG = System.getenv().containsKey("ICEDTEAPLUGIN_DEBUG"); + static final boolean DEBUG = JNLPRuntime.isPluginDebug(); public static void debug(Object... messageChunks) { if (DEBUG) { @@ -50,7 +53,7 @@ public class PluginDebug { for (Object chunk : messageChunks) { b.append(chunk); } - System.err.println(b.toString()); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL, b.toString()); } } } diff --git a/plugin/icedteanp/java/sun/applet/PluginException.java b/plugin/icedteanp/java/sun/applet/PluginException.java index cec37e4..ab1eb43 100644 --- a/plugin/icedteanp/java/sun/applet/PluginException.java +++ b/plugin/icedteanp/java/sun/applet/PluginException.java @@ -37,10 +37,12 @@ exception statement from your version. */ package sun.applet; +import net.sourceforge.jnlp.util.logging.OutputController; + public class PluginException extends Exception { public PluginException(PluginStreamHandler sh, int instance, int reference, Throwable t) { - t.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,t); this.setStackTrace(t.getStackTrace()); AppletSecurityContextManager.dumpStore(0); diff --git a/plugin/icedteanp/java/sun/applet/PluginMain.java b/plugin/icedteanp/java/sun/applet/PluginMain.java index 3bfbfff..cef5313 100644 --- a/plugin/icedteanp/java/sun/applet/PluginMain.java +++ b/plugin/icedteanp/java/sun/applet/PluginMain.java @@ -82,6 +82,7 @@ import sun.awt.SunToolkit; import net.sourceforge.jnlp.config.DeploymentConfiguration; import net.sourceforge.jnlp.runtime.JNLPRuntime; import net.sourceforge.jnlp.security.JNLPAuthenticator; +import net.sourceforge.jnlp.util.logging.OutputController; /** * The main entry point into PluginAppletViewer. @@ -109,8 +110,8 @@ public class PluginMain { // Place an arbitrary handler, we only need the URL construction to not error-out handlers.put("javascript", new sun.net.www.protocol.http.Handler()); } catch (Exception e) { - System.err.println("Unable to install 'javascript:' URL protocol handler!"); - e.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Unable to install 'javascript:' URL protocol handler!"); + OutputController.getLogger().log(e); } } @@ -125,16 +126,12 @@ public class PluginMain { installDummyJavascriptProtocolHandler(); if (args.length != 2 || !(new File(args[0]).exists()) || !(new File(args[1]).exists())) { - System.err.println("Invalid pipe names provided. Refusing to proceed."); - System.exit(1); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Invalid pipe names provided. Refusing to proceed."); + JNLPRuntime.exit(1); } DeploymentConfiguration.move14AndOlderFilesTo15StructureCatched(); try { PluginStreamHandler streamHandler = connect(args[0], args[1]); - boolean redirectStreams = System.getenv().containsKey("ICEDTEAPLUGIN_DEBUG"); - - // must be called before JNLPRuntime.initialize() - JNLPRuntime.setRedirectStreams(redirectStreams); PluginAppletSecurityContext sc = new PluginAppletSecurityContext(0); sc.prePopulateLCClasses(); @@ -152,9 +149,9 @@ public class PluginMain { setCookieHandler(streamHandler); } catch (Exception e) { - e.printStackTrace(); - System.err.println("Something very bad happened. I don't know what to do, so I am going to exit :("); - System.exit(1); + OutputController.getLogger().log(e); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Something very bad happened. I don't know what to do, so I am going to exit :("); + JNLPRuntime.exit(1); } } @@ -168,7 +165,7 @@ public class PluginMain { streamHandler = new PluginStreamHandler(new FileInputStream(inPipe), new FileOutputStream(outPipe)); PluginDebug.debug("Streams initialized"); } catch (IOException ioe) { - ioe.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,ioe); } return streamHandler; } diff --git a/plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java b/plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java index a5db7be..1de8bd7 100644 --- a/plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java +++ b/plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java @@ -39,6 +39,7 @@ package sun.applet; import java.util.ArrayList; import java.util.LinkedList; +import net.sourceforge.jnlp.util.logging.OutputController; class PluginMessageConsumer { @@ -143,7 +144,7 @@ class PluginMessageConsumer { wait(1000); } catch (InterruptedException e) { // Should not typically occur - e.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); } } diff --git a/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java b/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java index 6115c53..907a2b2 100644 --- a/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java +++ b/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java @@ -37,6 +37,8 @@ exception statement from your version. */ package sun.applet; +import net.sourceforge.jnlp.util.logging.OutputController; + class PluginMessageHandlerWorker extends Thread { private boolean free = true; @@ -56,7 +58,7 @@ class PluginMessageHandlerWorker extends Thread { wait(1000); } catch (InterruptedException e) { // Should not typically occur - e.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); } } diff --git a/plugin/icedteanp/java/sun/applet/PluginProxyInfoRequest.java b/plugin/icedteanp/java/sun/applet/PluginProxyInfoRequest.java index 8631f41..1f86c86 100644 --- a/plugin/icedteanp/java/sun/applet/PluginProxyInfoRequest.java +++ b/plugin/icedteanp/java/sun/applet/PluginProxyInfoRequest.java @@ -38,6 +38,7 @@ exception statement from your version. */ package sun.applet; import java.net.URI; +import net.sourceforge.jnlp.util.logging.OutputController; /** * This class represents a request object for proxy information for a given URI @@ -68,7 +69,7 @@ public class PluginProxyInfoRequest extends PluginCallRequest { } catch (ArrayIndexOutOfBoundsException aioobe) { // Nothing.. this is expected if there is no proxy } catch (Exception e) { - e.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); } setDone(true); diff --git a/plugin/icedteanp/java/sun/applet/PluginProxySelector.java b/plugin/icedteanp/java/sun/applet/PluginProxySelector.java index af6efc6..4a1ce33 100644 --- a/plugin/icedteanp/java/sun/applet/PluginProxySelector.java +++ b/plugin/icedteanp/java/sun/applet/PluginProxySelector.java @@ -45,6 +45,7 @@ import java.util.List; import net.sourceforge.jnlp.config.DeploymentConfiguration; import net.sourceforge.jnlp.runtime.JNLPProxySelector; +import net.sourceforge.jnlp.util.logging.OutputController; import net.sourceforge.jnlp.util.TimedHashMap; /** @@ -107,7 +108,7 @@ public class PluginProxySelector extends JNLPProxySelector { } } } catch (Exception e) { - e.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); } proxyList.add(proxy); diff --git a/plugin/icedteanp/java/sun/applet/PluginStreamHandler.java b/plugin/icedteanp/java/sun/applet/PluginStreamHandler.java index e351aef..fb23755 100644 --- a/plugin/icedteanp/java/sun/applet/PluginStreamHandler.java +++ b/plugin/icedteanp/java/sun/applet/PluginStreamHandler.java @@ -48,6 +48,8 @@ import java.net.MalformedURLException; import java.nio.charset.Charset; import javax.swing.SwingUtilities; +import net.sourceforge.jnlp.runtime.JNLPRuntime; +import net.sourceforge.jnlp.util.logging.OutputController; public class PluginStreamHandler { @@ -103,7 +105,7 @@ public class PluginStreamHandler { } AppletSecurityContextManager.dumpStore(0); PluginDebug.debug("APPLETVIEWER: exiting appletviewer"); - System.exit(0); + JNLPRuntime.exit(0); } } } @@ -332,10 +334,10 @@ public class PluginStreamHandler { } AppletSecurityContextManager.dumpStore(0); PluginDebug.debug("APPLETVIEWER: exiting appletviewer"); - System.exit(0); + JNLPRuntime.exit(0); } } catch (IOException e) { - e.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); } return message; @@ -360,13 +362,13 @@ public class PluginStreamHandler { // if we are shutting down, ignore write failures as // pipe may have closed if (!shuttingDown) { - e.printStackTrace(); + OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); } // either ways, if the pipe is broken, there is nothing // we can do anymore. Don't hang around. PluginDebug.debug("Unable to write to PIPE. APPLETVIEWER exiting"); - System.exit(1); + JNLPRuntime.exit(1); } } |