aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge/jnlp
diff options
context:
space:
mode:
authorJiri Vanek <[email protected]>2013-11-05 20:07:27 +0100
committerJiri Vanek <[email protected]>2013-11-05 20:07:27 +0100
commit8f59c1b0bf5fed4fce80ebcc0bc588e62dde706d (patch)
tree96448b23078bd930c2786b76c5d0e168ccd63a73 /netx/net/sourceforge/jnlp
parent7b561bedfe5dec3afe77574ef879b91f942db735 (diff)
Java console resurrected and connected to new logging.
Diffstat (limited to 'netx/net/sourceforge/jnlp')
-rw-r--r--netx/net/sourceforge/jnlp/config/Defaults.java4
-rw-r--r--netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java38
-rw-r--r--netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java8
-rw-r--r--netx/net/sourceforge/jnlp/resources/Messages.properties18
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java8
-rw-r--r--netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java32
-rw-r--r--netx/net/sourceforge/jnlp/util/BasicExceptionDialog.java29
-rw-r--r--netx/net/sourceforge/jnlp/util/logging/JavaConsole.java384
-rw-r--r--netx/net/sourceforge/jnlp/util/logging/LogConfig.java4
-rw-r--r--netx/net/sourceforge/jnlp/util/logging/OutputController.java36
10 files changed, 533 insertions, 28 deletions
diff --git a/netx/net/sourceforge/jnlp/config/Defaults.java b/netx/net/sourceforge/jnlp/config/Defaults.java
index c3fdade..95b91d1 100644
--- a/netx/net/sourceforge/jnlp/config/Defaults.java
+++ b/netx/net/sourceforge/jnlp/config/Defaults.java
@@ -337,7 +337,9 @@ public class Defaults {
BasicValueValidators.getStringValidator(new String[] {
DeploymentConfiguration.CONSOLE_DISABLE,
DeploymentConfiguration.CONSOLE_HIDE,
- DeploymentConfiguration.CONSOLE_SHOW
+ DeploymentConfiguration.CONSOLE_SHOW,
+ DeploymentConfiguration.CONSOLE_SHOW_PLUGIN,
+ DeploymentConfiguration.CONSOLE_SHOW_JAVAWS
}),
DeploymentConfiguration.CONSOLE_HIDE
},
diff --git a/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java b/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java
index 3dbcaab..02a4933 100644
--- a/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java
+++ b/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java
@@ -64,14 +64,31 @@ public final class DeploymentConfiguration {
public static final int JNLP_ASSOCIATION_ASK_USER = 2;
public static final int JNLP_ASSOCIATION_REPLACE_ASK = 3;
- /*
- * FIXME these should be moved into JavaConsole, but there is a strange
- * dependency in the build system. First all of netx is built. Then the
- * plugin is built. So we cannot refer to plugin code in here :(
+ /**
+ * when set to as value of KEY_CONSOLE_STARTUP_MODE = "deployment.console.startup.mode",
+ * then console is not visible by default, but may be shown
*/
public static final String CONSOLE_HIDE = "HIDE";
+ /**
+ * when set to as value of KEY_CONSOLE_STARTUP_MODE = "deployment.console.startup.mode",
+ * then console show for both javaws and plugin
+ */
public static final String CONSOLE_SHOW = "SHOW";
+ /**
+ * when set to as value of KEY_CONSOLE_STARTUP_MODE = "deployment.console.startup.mode",
+ * then console is not visible by default, nop data are passed to it (save memory and cpu) but can not be shown
+ */
public static final String CONSOLE_DISABLE = "DISABLE";
+ /**
+ * when set to as value of KEY_CONSOLE_STARTUP_MODE = "deployment.console.startup.mode",
+ * then console show for plugin
+ */
+ public static final String CONSOLE_SHOW_PLUGIN = "SHOW_PLUGIN_ONLY";
+ /**
+ * when set to as value of KEY_CONSOLE_STARTUP_MODE = "deployment.console.startup.mode",
+ * then console show for javaws
+ */
+ public static final String CONSOLE_SHOW_JAVAWS = "SHOW_JAVAWS_ONLY";
public static final String KEY_USER_CACHE_DIR = "deployment.user.cachedir";
public static final String KEY_USER_PERSISTENCE_CACHE_DIR = "deployment.user.pcachedir";
@@ -156,10 +173,19 @@ public final class DeploymentConfiguration {
public static final String KEY_ENABLE_LOGGING_TOSTREAMS = "deployment.log.stdstreams";
public static final String KEY_ENABLE_LOGGING_TOSYSTEMLOG = "deployment.log.system";
- /*
- * Console
+ /**
+ * Console initial status.
+ * One of CONSOLE_* values
+ * See declaration above:
+ * CONSOLE_HIDE = "HIDE";
+ * CONSOLE_SHOW = "SHOW";
+ * CONSOLE_DISABLE = "DISABLE";
+ * CONSOLE_SHOW_PLUGIN = "SHOW_PLUGIN_ONLY";
+ * CONSOLE_SHOW_JAVAWS = "SHOW_JAVAWS_ONLY";
*/
public static final String KEY_CONSOLE_STARTUP_MODE = "deployment.console.startup.mode";
+
+
/*
* Desktop Integration
diff --git a/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java b/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java
index 003f486..bee0a53 100644
--- a/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java
+++ b/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java
@@ -91,9 +91,11 @@ public class DebuggingPanel extends NamedBorderPanel implements ItemListener {
(Translator.R("DPEnableSyslogHint"))
};
- ComboItem[] javaConsoleItems = { new ComboItem(Translator.R("DPDisable"), "DISABLE"),
- new ComboItem(Translator.R("DPHide"), "HIDE"),
- new ComboItem(Translator.R("DPShow"), "SHOW"), };
+ ComboItem[] javaConsoleItems = { new ComboItem(Translator.R("DPDisable"), DeploymentConfiguration.CONSOLE_DISABLE),
+ new ComboItem(Translator.R("DPHide"), DeploymentConfiguration.CONSOLE_HIDE),
+ new ComboItem(Translator.R("DPShow"), DeploymentConfiguration.CONSOLE_SHOW),
+ new ComboItem(Translator.R("DPShowPluginOnly"), DeploymentConfiguration.CONSOLE_SHOW_PLUGIN),
+ new ComboItem(Translator.R("DPShowJavawsOnly"), DeploymentConfiguration.CONSOLE_SHOW_JAVAWS) };
JLabel consoleLabel = new JLabel(Translator.R("DPJavaConsole"));
JComboBox consoleComboBox = new JComboBox();
diff --git a/netx/net/sourceforge/jnlp/resources/Messages.properties b/netx/net/sourceforge/jnlp/resources/Messages.properties
index 8f1050a..5cea7d2 100644
--- a/netx/net/sourceforge/jnlp/resources/Messages.properties
+++ b/netx/net/sourceforge/jnlp/resources/Messages.properties
@@ -415,7 +415,24 @@ DPEnableSyslogHint=output messages will be saved to system logs
DPDisable=Disable
DPHide=Hide on startup
DPShow=Show on startup
+DPShowPluginOnly=Show on plugin startup
+DPShowJavawsOnly=Show on javaws startup
DPJavaConsole=Java Console
+DPJavaConsoleDisabledHint=Java console is disabled. Use itweb-settings to configure it out of disabled to any show or hide value.
+
+#conole itself labels
+CONSOLErungc = Run GC
+CONSOLErunFinalizers = Run Finalizers
+CONSOLErunningFinalizers = Running finalization....
+CONSOLEmemoryInfo = Memory Info
+CONSOLEsystemProperties = System Properties
+CONSOLEclassLoaders = Available Classloaders
+CONSOLEthreadList = Thread List
+CONSOLEthread = Thread
+CONSOLEnoClassLoaders = No Classloader info exists in system
+CONSOLEmemoryMax = Max Memory
+CONSOLEmemoryTotal = Total Memory
+CONSOLEmemoryFree = Free Memory
# Control Panel - DesktopShortcutPanel
DSPNeverCreate=Never create
@@ -525,6 +542,7 @@ SPLASHurlLooks = http://icedtea.classpath.org/wiki/IcedTea-Web
SPLASHmainL3 = No further information available, try to launch the browser from the command line and examine the output.
SPLASHcloseAndCopyShorter = Close and copy to clipboard
SPLASHmainL4 = The folloing exception has occured. For more information, try to launch the browser from the command line and examine the output.
+SPLASHmainL2 = Additional information may be available in the console or logs. Even more information is available if debugging is enabled.
SPLASHexWas = Exception was:
SPLASHcfl = Can't follow link to
SPLASHvendorsInfo = Information from vendor of your application
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
index a0744a0..3a50f6c 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
@@ -67,8 +67,8 @@ 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.JavaConsole;
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;
@@ -162,8 +162,7 @@ public class JNLPRuntime {
/** a lock which is held to indicate that an instance of netx is running */
private static FileLock fileLock;
- public static final String STDERR_FILE = "java.stderr";
- public static final String STDOUT_FILE = "java.stdout";
+
/**
@@ -196,6 +195,9 @@ public class JNLPRuntime {
try {
config.load();
config.copyTo(System.getProperties());
+ if (JavaConsole.canShowOnStartup(isApplication)) {
+ JavaConsole.getConsole().showConsoleLater();
+ }
} catch (ConfigurationException e) {
/* exit if there is a fatal exception loading the configuration */
if (isApplication) {
diff --git a/netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java b/netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java
index 02110ce..b726be4 100644
--- a/netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java
+++ b/netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java
@@ -40,8 +40,6 @@ import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.WindowEvent;
-import java.io.PrintWriter;
-import java.io.StringWriter;
import java.text.DateFormat;
import java.util.Date;
import java.util.List;
@@ -65,6 +63,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.BasicExceptionDialog;
import net.sourceforge.jnlp.util.logging.OutputController;
public class JEditorPaneBasedExceptionDialog extends JDialog implements HyperlinkListener {
@@ -74,6 +73,7 @@ public class JEditorPaneBasedExceptionDialog extends JDialog implements Hyperlin
private JButton closeAndCopyButton;
private JButton homeButton;
private JButton aboutButton;
+ private JButton consoleButton;
private JEditorPane htmlErrorAndHelpPanel;
private JLabel exceptionLabel;
private JLabel iconLabel;
@@ -142,6 +142,7 @@ public class JEditorPaneBasedExceptionDialog extends JDialog implements Hyperlin
htmlErrorAndHelpPanel = new JEditorPane();
homeButton = new JButton();
aboutButton = new JButton();
+ consoleButton = BasicExceptionDialog.getShowButton(JEditorPaneBasedExceptionDialog.this);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
@@ -166,9 +167,27 @@ public class JEditorPaneBasedExceptionDialog extends JDialog implements Hyperlin
GroupLayout jPanel2Layout = new GroupLayout(topPanel);
topPanel.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
- jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout.createSequentialGroup().addContainerGap().addComponent(closeButton).addContainerGap().addComponent(aboutButton).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 314, Short.MAX_VALUE).addComponent(closeAndCopyButton).addContainerGap()));
+ jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel2Layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(closeButton)
+ .addContainerGap()
+ .addComponent(aboutButton)
+ .addContainerGap()
+ .addComponent(consoleButton)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 314, Short.MAX_VALUE)
+ .addComponent(closeAndCopyButton)
+ .addContainerGap()));
jPanel2Layout.setVerticalGroup(
- jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup().addContainerGap(24, Short.MAX_VALUE).addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(closeButton).addComponent(aboutButton).addComponent(closeAndCopyButton)).addContainerGap()));
+ jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addGroup(GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
+ .addContainerGap(24, Short.MAX_VALUE)
+ .addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(closeButton)
+ .addComponent(aboutButton)
+ .addComponent(consoleButton)
+ .addComponent(closeAndCopyButton))
+ .addContainerGap()));
exceptionLabel.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
exceptionLabel.setHorizontalAlignment(SwingConstants.CENTER);
@@ -204,7 +223,7 @@ public class JEditorPaneBasedExceptionDialog extends JDialog implements Hyperlin
}
}
});
-
+
GroupLayout jPanel1Layout = new GroupLayout(mainPanel);
mainPanel.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
@@ -271,6 +290,9 @@ public class JEditorPaneBasedExceptionDialog extends JDialog implements Hyperlin
StringBuilder s = new StringBuilder("<html><body>");
String info = "<p>"
+ Translator.R(InfoItem.SPLASH + "mainL1", createLink())
+ + " </p> \n" +
+ "<p>"
+ + Translator.R(InfoItem.SPLASH + "mainL2", createLink())
+ " </p> \n";
String t = "<p>"
+ Translator.R(InfoItem.SPLASH + "mainL3")
diff --git a/netx/net/sourceforge/jnlp/util/BasicExceptionDialog.java b/netx/net/sourceforge/jnlp/util/BasicExceptionDialog.java
index 2fca402..752974f 100644
--- a/netx/net/sourceforge/jnlp/util/BasicExceptionDialog.java
+++ b/netx/net/sourceforge/jnlp/util/BasicExceptionDialog.java
@@ -41,6 +41,7 @@ import net.sourceforge.jnlp.util.logging.OutputController;
import static net.sourceforge.jnlp.runtime.Translator.R;
import java.awt.BorderLayout;
+import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -55,6 +56,8 @@ import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
+import net.sourceforge.jnlp.runtime.Translator;
+import net.sourceforge.jnlp.util.logging.JavaConsole;
/**
* A dialog that displays some basic information about an exception
@@ -91,6 +94,10 @@ public class BasicExceptionDialog {
viewDetails.setActionCommand("show");
quickInfoPanel.add(viewDetails);
+ final JButton consoleButton = getShowButton(errorDialog);
+ consoleButton.setAlignmentY(JComponent.LEFT_ALIGNMENT);
+ quickInfoPanel.add(consoleButton);
+
JTextArea textArea = new JTextArea();
textArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
textArea.setEditable(false);
@@ -120,4 +127,26 @@ public class BasicExceptionDialog {
errorDialog.setVisible(true);
errorDialog.dispose();
}
+
+ public static JButton getShowButton(final Component parent) {
+ JButton consoleButton = new JButton();
+ consoleButton.setText(R("DPJavaConsole"));
+ consoleButton.addActionListener(new java.awt.event.ActionListener() {
+
+ @Override
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ try {
+ JavaConsole.getConsole().showConsoleLater(true);
+ } catch (Exception ex) {
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
+ JOptionPane.showConfirmDialog(parent, ex);
+ }
+ }
+ });
+ if (!JavaConsole.isEnabled()) {
+ consoleButton.setEnabled(false);
+ consoleButton.setToolTipText(R("DPJavaConsoleDisabledHint"));
+ }
+ return consoleButton;
+ }
}
diff --git a/netx/net/sourceforge/jnlp/util/logging/JavaConsole.java b/netx/net/sourceforge/jnlp/util/logging/JavaConsole.java
new file mode 100644
index 0000000..939b755
--- /dev/null
+++ b/netx/net/sourceforge/jnlp/util/logging/JavaConsole.java
@@ -0,0 +1,384 @@
+/* JavaConsole -- A java console for the plugin
+Copyright (C) 2009, 2013 Red Hat
+
+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 static net.sourceforge.jnlp.runtime.Translator.R;
+
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.TitledBorder;
+import net.sourceforge.jnlp.config.DeploymentConfiguration;
+import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import net.sourceforge.jnlp.util.ImageResources;
+
+/**
+ * A simple Java console for IcedTeaPlugin and JavaWS
+ *
+ */
+public class JavaConsole {
+
+ public static interface ClassLoaderInfoProvider {
+
+ public Map<String, String> getLoaderInfo();
+ }
+ private static JavaConsole console;
+
+ public static JavaConsole getConsole() {
+ if (console == null) {
+ console = new JavaConsole();
+ }
+ return console;
+ }
+
+ public static boolean isEnabled() {
+ return isEnabled(JNLPRuntime.getConfiguration());
+ }
+
+ public static boolean isEnabled(DeploymentConfiguration config) {
+ return !DeploymentConfiguration.CONSOLE_DISABLE.equals(config.getProperty(DeploymentConfiguration.KEY_CONSOLE_STARTUP_MODE))
+ && !JNLPRuntime.isHeadless();
+ }
+
+ public static boolean canShowOnStartup(boolean isApplication) {
+ return canShowOnStartup(isApplication, JNLPRuntime.getConfiguration());
+ }
+
+ public static boolean canShowOnStartup(boolean isApplication, DeploymentConfiguration config) {
+ if (!isEnabled(config)) {
+ return false;
+ }
+ return DeploymentConfiguration.CONSOLE_SHOW.equals(config.getProperty(DeploymentConfiguration.KEY_CONSOLE_STARTUP_MODE))
+ || (DeploymentConfiguration.CONSOLE_SHOW_PLUGIN.equals(config.getProperty(DeploymentConfiguration.KEY_CONSOLE_STARTUP_MODE))
+ && !isApplication)
+ || (DeploymentConfiguration.CONSOLE_SHOW_JAVAWS.equals(config.getProperty(DeploymentConfiguration.KEY_CONSOLE_STARTUP_MODE))
+ && isApplication);
+ }
+ private JDialog consoleWindow;
+ private JTextArea stdErrText;
+ private JTextArea stdOutText;
+ private ClassLoaderInfoProvider classLoaderInfoProvider;
+
+ public JavaConsole() {
+ initialize();
+ }
+
+ /**
+ * Initialize the console
+ */
+ private void initialize() {
+
+ try {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ } catch (Exception e) {
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
+ }
+
+ consoleWindow = new JDialog((JFrame) null, R("DPJavaConsole"));
+ consoleWindow.setIconImages(ImageResources.INSTANCE.getApplicationImages());
+
+ JPanel contentPanel = new JPanel();
+ contentPanel.setLayout(new GridBagLayout());
+
+ GridBagConstraints c;
+
+ Font monoSpace = new Font("Monospaced", Font.PLAIN, 12);
+
+
+ stdOutText = new JTextArea();
+ JScrollPane stdOutScrollPane = new JScrollPane(stdOutText);
+ stdOutScrollPane.setBorder(new TitledBorder(
+ new EmptyBorder(5, 5, 5, 5), "System.out"));
+ stdOutText.setEditable(false);
+ stdOutText.setFont(monoSpace);
+
+ stdErrText = new JTextArea();
+ JScrollPane stdErrScrollPane = new JScrollPane(stdErrText);
+ stdErrScrollPane.setBorder(new TitledBorder(
+ new EmptyBorder(5, 5, 5, 5), "System.err"));
+ stdErrText.setEditable(false);
+ stdErrText.setFont(monoSpace);
+
+ JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
+ stdOutScrollPane, stdErrScrollPane);
+
+ c = new GridBagConstraints();
+ c.fill = GridBagConstraints.BOTH;
+ c.gridheight = 10;
+ c.weighty = 1;
+
+ contentPanel.add(splitPane, c);
+
+ /* buttons */
+
+ c = new GridBagConstraints();
+ c.gridy = 10;
+ c.gridheight = 1;
+ c.weightx = 0.5;
+ c.weighty = 0;
+
+ JPanel buttonPanel = new JPanel();
+ contentPanel.add(buttonPanel, c);
+
+ JButton gcButton = new JButton(R("CONSOLErungc"));
+ buttonPanel.add(gcButton);
+ gcButton.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ printMemoryInfo();
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "Performing Garbage Collection....");
+ System.gc();
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, R("ButDone"));
+ printMemoryInfo();
+ }
+ });
+
+ JButton finalizersButton = new JButton(R("CONSOLErunFinalizers"));
+ buttonPanel.add(finalizersButton);
+ finalizersButton.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ printMemoryInfo();
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, R("CONSOLErunningFinalizers"));
+ Runtime.getRuntime().runFinalization();
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, R("ButDone"));
+ printMemoryInfo();
+ }
+ });
+
+ JButton memoryButton = new JButton(R("CONSOLEmemoryInfo"));
+ buttonPanel.add(memoryButton);
+ memoryButton.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ printMemoryInfo();
+ }
+ });
+
+ JButton systemPropertiesButton = new JButton(R("CONSOLEsystemProperties"));
+ buttonPanel.add(systemPropertiesButton);
+ systemPropertiesButton.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ printSystemProperties();
+ }
+ });
+
+ JButton classloadersButton = new JButton(R("CONSOLEclassLoaders"));
+ buttonPanel.add(classloadersButton);
+ classloadersButton.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ printClassLoaders();
+ }
+ });
+
+ JButton threadListButton = new JButton(R("CONSOLEthreadList"));
+ buttonPanel.add(threadListButton);
+ threadListButton.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ printThreadInfo();
+ }
+ });
+
+ JButton closeButton = new JButton(R("ButClose"));
+ buttonPanel.add(closeButton);
+ closeButton.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ public void run() {
+ hideConsole();
+ }
+ });
+ }
+ });
+
+ consoleWindow.add(contentPanel);
+ consoleWindow.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
+ consoleWindow.pack();
+ consoleWindow.setSize(new Dimension(900, 600));
+ consoleWindow.setMinimumSize(new Dimension(900, 300));
+
+ splitPane.setDividerLocation(0.5);
+ splitPane.setResizeWeight(0.5);
+ }
+
+ public void showConsole() {
+ showConsole(false);
+ }
+
+ public void showConsole(boolean b) {
+ consoleWindow.setModal(b);
+ consoleWindow.setVisible(true);
+ }
+
+ public void hideConsole() {
+ consoleWindow.setModal(false);
+ consoleWindow.setVisible(false);
+ }
+
+ public void showConsoleLater() {
+ showConsoleLater(false);
+ }
+
+ public void showConsoleLater(final boolean b) {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ public void run() {
+ JavaConsole.getConsole().showConsole(b);
+ }
+ });
+ }
+
+ public void hideConsoleLater() {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ public void run() {
+ JavaConsole.getConsole().hideConsole();
+ }
+ });
+ }
+
+ protected void printSystemProperties() {
+
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " ----");
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, R("CONSOLEsystemProperties") + ":");
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "");
+ Properties p = System.getProperties();
+ Set<Object> keys = p.keySet();
+ for (Object key : keys) {
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, key.toString() + ": " + p.get(key));
+ }
+
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " ----");
+ }
+
+ public void setClassLoaderInfoProvider(ClassLoaderInfoProvider clip) {
+ classLoaderInfoProvider = clip;
+ }
+
+ private void printClassLoaders() {
+ if (classLoaderInfoProvider == null) {
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, R("CONSOLEnoClassLoaders"));
+ } else {
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " ----");
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, R("CONSOLEclassLoaders") + ": ");
+ Set<String> loaders = classLoaderInfoProvider.getLoaderInfo().keySet();
+ for (String loader : loaders) {
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, loader + "\n"
+ + " codebase = "
+ + classLoaderInfoProvider.getLoaderInfo().get(loader));
+ }
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " ----");
+ }
+ }
+
+ private void printMemoryInfo() {
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " ----- ");
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " " + R("CONSOLEmemoryInfo") + ":");
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " " + R("CONSOLEmemoryMax") + ": "
+ + String.format("%1$10d", Runtime.getRuntime().maxMemory()));
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " " + R("CONSOLEmemoryTotal") + ": "
+ + String.format("%1$10d", Runtime.getRuntime().totalMemory()));
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " " + R("CONSOLEmemoryFree") + ": "
+ + String.format("%1$10d", Runtime.getRuntime().freeMemory()));
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " ----");
+
+ }
+
+ private void printThreadInfo() {
+ Map<Thread, StackTraceElement[]> map = Thread.getAllStackTraces();
+ Set<Thread> keys = map.keySet();
+ for (Thread key : keys) {
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, R("CONSOLEthread") + " " + key.getId() + ": " + key.getName());
+ for (StackTraceElement element : map.get(key)) {
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " " + element);
+ }
+
+ }
+ }
+
+ public static void main(String[] args) {
+
+ final JavaConsole console = new JavaConsole();
+
+ boolean toShowConsole = false;
+
+ for (String arg : args) {
+ if ("--show-console".equals(arg)) {
+ toShowConsole = true;
+ }
+ }
+
+ if (toShowConsole) {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ public void run() {
+ console.showConsole();
+ }
+ });
+ }
+
+ }
+
+ void logOutput(String s) {
+ stdOutText.setText(stdOutText.getText() + s + "\n");
+ }
+
+ void logError(String s) {
+ stdErrText.setText(stdErrText.getText() + s + "\n");
+ }
+}
diff --git a/netx/net/sourceforge/jnlp/util/logging/LogConfig.java b/netx/net/sourceforge/jnlp/util/logging/LogConfig.java
index 70db30c..2c98cd2 100644
--- a/netx/net/sourceforge/jnlp/util/logging/LogConfig.java
+++ b/netx/net/sourceforge/jnlp/util/logging/LogConfig.java
@@ -156,6 +156,10 @@ public class LogConfig {
void setLogToSysLog(boolean logToSysLog) {
this.logToSysLog = logToSysLog;
}
+
+ boolean isLogToConsole() {
+ return JavaConsole.isEnabled();
+ }
diff --git a/netx/net/sourceforge/jnlp/util/logging/OutputController.java b/netx/net/sourceforge/jnlp/util/logging/OutputController.java
index 7a78f58..3606e6c 100644
--- a/netx/net/sourceforge/jnlp/util/logging/OutputController.java
+++ b/netx/net/sourceforge/jnlp/util/logging/OutputController.java
@@ -45,16 +45,30 @@ import net.sourceforge.jnlp.runtime.JNLPRuntime;
public class OutputController {
- public static enum Level {
+ 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; // - stderr/log in verbose/debug mode
//ERROR_DEBUG is default for Throwable
//MESSAGE_VERBOSE is defautrl for String
+
+ private static boolean isOutput(MessageWithLevel s) {
+ return s.level == Level.MESSAGE_ALL
+ || s.level == Level.MESSAGE_DEBUG
+ || s.level == Level.WARNING_ALL
+ || s.level == Level.WARNING_DEBUG;
+ }
+
+ private static boolean isError(MessageWithLevel s) {
+ return s.level == Level.ERROR_ALL
+ || s.level == Level.ERROR_DEBUG
+ || s.level == Level.WARNING_ALL
+ || s.level == Level.WARNING_DEBUG;
+ }
}
private static final class MessageWithLevel {
@@ -134,16 +148,10 @@ public class OutputController {
}
}
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) {
+ if (Level.isOutput(s)) {
outLog.log(message);
}
- if (s.level == Level.ERROR_ALL
- || s.level == Level.ERROR_DEBUG
- || s.level == Level.WARNING_ALL
- || s.level == Level.WARNING_DEBUG) {
+ if (Level.isError(s)) {
errLog.log(message);
}
}
@@ -153,6 +161,14 @@ public class OutputController {
if (LogConfig.getLogConfig().isLogToSysLog()) {
getSystemLog().log(message);
}
+ if (LogConfig.getLogConfig().isLogToConsole()) {
+ if (Level.isOutput(s)){
+ JavaConsole.getConsole().logOutput(message);
+ }
+ if (Level.isError(s)){
+ JavaConsole.getConsole().logError(message);
+ }
+ }
}