You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2014/10/05 01:55:56 UTC

[1/3] git commit: Use of constants in JConsole plugin.

Repository: logging-log4j2
Updated Branches:
  refs/heads/master 5ae0e6c00 -> 85f586c99


Use of constants in JConsole plugin.


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/1ebbf54b
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/1ebbf54b
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/1ebbf54b

Branch: refs/heads/master
Commit: 1ebbf54b4d95f1b19f684521ebf1b84f86e9293c
Parents: 5ae0e6c
Author: Matt Sicker <ma...@apache.org>
Authored: Sat Oct 4 18:40:42 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Sat Oct 4 18:40:42 2014 -0500

----------------------------------------------------------------------
 .../log4j/jmx/gui/ClientEditConfigPanel.java        |  3 +--
 .../org/apache/logging/log4j/jmx/gui/ClientGui.java | 16 +++-------------
 2 files changed, 4 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/1ebbf54b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientEditConfigPanel.java
----------------------------------------------------------------------
diff --git a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientEditConfigPanel.java b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientEditConfigPanel.java
index 51d6468..972e0bb 100644
--- a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientEditConfigPanel.java
+++ b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientEditConfigPanel.java
@@ -128,8 +128,7 @@ public class ClientEditConfigPanel extends JPanel {
         // configTextArea.setEditable(false);
         configTextArea.setBackground(Color.white);
         configTextArea.setForeground(Color.black);
-        configTextArea.setFont(new Font("Monospaced", Font.PLAIN,
-                configTextArea.getFont().getSize()));
+        configTextArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, configTextArea.getFont().getSize()));
         final JScrollPane scrollConfig = new JScrollPane(configTextArea);
 
         locationTextField = new JTextField(LOCATION_TEXT_COLS);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/1ebbf54b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
----------------------------------------------------------------------
diff --git a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
index 67a8018..0215fb5 100644
--- a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
+++ b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
@@ -40,17 +40,7 @@ import javax.management.ObjectName;
 import javax.management.remote.JMXConnector;
 import javax.management.remote.JMXConnectorFactory;
 import javax.management.remote.JMXServiceURL;
-import javax.swing.AbstractAction;
-import javax.swing.JFrame;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTabbedPane;
-import javax.swing.JTextArea;
-import javax.swing.JToggleButton;
-import javax.swing.ScrollPaneConstants;
-import javax.swing.SwingUtilities;
-import javax.swing.UIManager;
+import javax.swing.*;
 import javax.swing.UIManager.LookAndFeelInfo;
 
 import org.apache.logging.log4j.core.jmx.LoggerContextAdminMBean;
@@ -142,7 +132,7 @@ public class ClientGui extends JPanel implements NotificationListener {
         result.setEditable(false);
         result.setBackground(this.getBackground());
         result.setForeground(Color.black);
-        result.setFont(new Font("Monospaced", Font.PLAIN, result.getFont().getSize()));
+        result.setFont(new Font(Font.MONOSPACED, Font.PLAIN, result.getFont().getSize()));
         result.setWrapStyleWord(true);
         return result;
     }
@@ -284,7 +274,7 @@ public class ClientGui extends JPanel implements NotificationListener {
                 try {
                     final ClientGui gui = new ClientGui(client);
                     final JFrame frame = new JFrame(title);
-                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+                    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                     frame.getContentPane().add(gui, BorderLayout.CENTER);
                     frame.pack();
                     frame.setVisible(true);


[2/3] git commit: Use Closer.

Posted by ma...@apache.org.
Use Closer.


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/16045e64
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/16045e64
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/16045e64

Branch: refs/heads/master
Commit: 16045e641811576346f277ebfbea5382c18dbc6c
Parents: 1ebbf54
Author: Matt Sicker <ma...@apache.org>
Authored: Sat Oct 4 18:45:23 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Sat Oct 4 18:45:23 2014 -0500

----------------------------------------------------------------------
 .../apache/logging/log4j/jmx/gui/Client.java    | 21 +++++++++-----------
 1 file changed, 9 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/16045e64/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/Client.java
----------------------------------------------------------------------
diff --git a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/Client.java b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/Client.java
index 5bf0fb8..1bfbd66 100644
--- a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/Client.java
+++ b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/Client.java
@@ -32,6 +32,7 @@ import org.apache.logging.log4j.core.jmx.LoggerContextAdminMBean;
 import org.apache.logging.log4j.core.jmx.Server;
 import org.apache.logging.log4j.core.jmx.StatusLoggerAdminMBean;
 import org.apache.logging.log4j.core.util.Assert;
+import org.apache.logging.log4j.core.util.Closer;
 
 /**
  * This class allows client-side code to perform operations on remote
@@ -44,7 +45,7 @@ public class Client {
     /**
      * Constructs a new {@code Client} object and creates proxies for all known
      * remote MBeans.
-     * 
+     *
      * @param connector used to create the MBean server connection through which
      *            to communicate with the remote mbeans
      * @throws MalformedObjectNameException if a problem occurred identifying
@@ -61,7 +62,7 @@ public class Client {
     /**
      * Constructs a new {@code Client} object and creates proxies for all known
      * remote MBeans.
-     * 
+     *
      * @param mBeanServerConnection the MBean server connection through which to
      *            communicate with the remote mbeans
      * @throws MalformedObjectNameException if a problem occurred identifying
@@ -85,7 +86,7 @@ public class Client {
     /**
      * Returns a list of proxies that allow operations to be performed on the
      * remote {@code LoggerContextAdminMBean}s.
-     * 
+     *
      * @return a list of proxies to the remote {@code LoggerContextAdminMBean}s
      * @throws IOException If an I/O error occurred
      * @throws JMException If a management error occurred
@@ -111,17 +112,13 @@ public class Client {
      * to the MBeanServerConnection will fail.
      */
     public void close() {
-        try {
-            connector.close();
-        } catch (final IOException e) {
-            e.printStackTrace();
-        }
+        Closer.closeSilently(connector);
     }
 
     /**
      * Returns the MBean server connection through which to communicate with the
      * remote mbeans.
-     * 
+     *
      * @return the MBean server connection
      */
     public MBeanServerConnection getConnection() {
@@ -131,7 +128,7 @@ public class Client {
     /**
      * Returns the {@code StatusLoggerAdminMBean} associated with the specified
      * context name, or {@code null}.
-     * 
+     *
      * @param contextName search key
      * @return StatusLoggerAdminMBean or null
      * @throws MalformedObjectNameException If an object name is malformed
@@ -158,7 +155,7 @@ public class Client {
     /**
      * Returns {@code true} if the specified {@code ObjectName} is for a
      * {@code LoggerContextAdminMBean}, {@code false} otherwise.
-     * 
+     *
      * @param mbeanName the {@code ObjectName} to check.
      * @return {@code true} if the specified {@code ObjectName} is for a
      *         {@code LoggerContextAdminMBean}, {@code false} otherwise
@@ -172,7 +169,7 @@ public class Client {
     /**
      * Returns the {@code ObjectName} of the {@code StatusLoggerAdminMBean}
      * associated with the specified {@code LoggerContextAdminMBean}.
-     * 
+     *
      * @param loggerContextObjName the {@code ObjectName} of a
      *            {@code LoggerContextAdminMBean}
      * @return {@code ObjectName} of the {@code StatusLoggerAdminMBean}


Re: [3/3] git commit: Add more type safety.

Posted by Gary Gregory <ga...@gmail.com>.
YW!

G

On Sat, Oct 4, 2014 at 8:23 PM, Matt Sicker <bo...@gmail.com> wrote:

> My IDE settings must be messed up. Let me look into this. Thanks for
> noticing, though!
>
> On 4 October 2014 19:06, Gary Gregory <ga...@gmail.com> wrote:
>
>> -1. This is backwards:
>>
>> -import java.awt.BorderLayout;
>> -import java.awt.Color;
>> -import java.awt.Component;
>> -import java.awt.Font;
>> +import java.awt.*;
>>
>> We do _not_ want * imports for normal imports, only for special cases
>> like static imports of JUnit Assert methods.
>>
>> Gary
>>
>> ---------- Forwarded message ----------
>> From: <ma...@apache.org>
>> Date: Sat, Oct 4, 2014 at 7:55 PM
>> Subject: [3/3] git commit: Add more type safety.
>> To: commits@logging.apache.org
>>
>>
>> Add more type safety.
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>> Commit:
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/85f586c9
>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/85f586c9
>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/85f586c9
>>
>> Branch: refs/heads/master
>> Commit: 85f586c99514cf5bc73586d2d078fe0237581ad7
>> Parents: 16045e6
>> Author: Matt Sicker <ma...@apache.org>
>> Authored: Sat Oct 4 18:55:28 2014 -0500
>> Committer: Matt Sicker <ma...@apache.org>
>> Committed: Sat Oct 4 18:55:28 2014 -0500
>>
>> ----------------------------------------------------------------------
>>  .../apache/logging/log4j/jmx/gui/ClientGui.java | 22 +++++++++++---------
>>  1 file changed, 12 insertions(+), 10 deletions(-)
>> ----------------------------------------------------------------------
>>
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85f586c9/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
>> b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
>> index 0215fb5..b36cc67 100644
>> ---
>> a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
>> +++
>> b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
>> @@ -16,17 +16,14 @@
>>   */
>>  package org.apache.logging.log4j.jmx.gui;
>>
>> -import java.awt.BorderLayout;
>> -import java.awt.Color;
>> -import java.awt.Component;
>> -import java.awt.Font;
>> +import java.awt.*;
>>  import java.awt.event.ActionEvent;
>>  import java.io.IOException;
>>  import java.io.PrintWriter;
>>  import java.io.StringWriter;
>>  import java.util.HashMap;
>>  import java.util.Map;
>> -
>> +import java.util.Properties;
>>  import javax.management.InstanceNotFoundException;
>>  import javax.management.JMException;
>>  import javax.management.ListenerNotFoundException;
>> @@ -177,7 +174,12 @@ public class ClientGui extends JPanel implements
>> NotificationListener {
>>
>>      private void handleNotificationInAwtEventThread(final Notification
>> notif, final Object paramObject) {
>>          if
>> (StatusLoggerAdminMBean.NOTIF_TYPE_MESSAGE.equals(notif.getType())) {
>> -            final JTextArea text = statusLogTextAreaMap.get(paramObject);
>> +            if (!(paramObject instanceof ObjectName)) {
>> +                handle("Invalid notification object type", new
>> ClassCastException(paramObject.getClass().getName()));
>> +                return;
>> +            }
>> +            final ObjectName param = (ObjectName) paramObject;
>> +            final JTextArea text = statusLogTextAreaMap.get(param);
>>              if (text != null) {
>>                  text.append(notif.getMessage() + '\n');
>>              }
>> @@ -258,10 +260,10 @@ public class ClientGui extends JPanel implements
>> NotificationListener {
>>              serviceUrl = "service:jmx:rmi:///jndi/rmi://" + args[0] +
>> "/jmxrmi";
>>          }
>>          final JMXServiceURL url = new JMXServiceURL(serviceUrl);
>> -        final Map<String, String> paramMap = new HashMap<String,
>> String>();
>> -        for (final Object objKey : System.getProperties().keySet()) {
>> -            final String key = (String) objKey;
>> -            paramMap.put(key, System.getProperties().getProperty(key));
>> +        final Properties props = System.getProperties();
>> +        final Map<String, String> paramMap = new HashMap<String,
>> String>(props.size());
>> +        for (final String key : props.stringPropertyNames()) {
>> +            paramMap.put(key, props.getProperty(key));
>>          }
>>          final JMXConnector connector = JMXConnectorFactory.connect(url,
>> paramMap);
>>          final Client client = new Client(connector);
>>
>>
>>
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> Java Persistence with Hibernate, Second Edition
>> <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>>
>
>
>
> --
> Matt Sicker <bo...@gmail.com>
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: [3/3] git commit: Add more type safety.

Posted by Matt Sicker <bo...@gmail.com>.
My IDE settings must be messed up. Let me look into this. Thanks for
noticing, though!

On 4 October 2014 19:06, Gary Gregory <ga...@gmail.com> wrote:

> -1. This is backwards:
>
> -import java.awt.BorderLayout;
> -import java.awt.Color;
> -import java.awt.Component;
> -import java.awt.Font;
> +import java.awt.*;
>
> We do _not_ want * imports for normal imports, only for special cases like
> static imports of JUnit Assert methods.
>
> Gary
>
> ---------- Forwarded message ----------
> From: <ma...@apache.org>
> Date: Sat, Oct 4, 2014 at 7:55 PM
> Subject: [3/3] git commit: Add more type safety.
> To: commits@logging.apache.org
>
>
> Add more type safety.
>
>
> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
> Commit:
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/85f586c9
> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/85f586c9
> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/85f586c9
>
> Branch: refs/heads/master
> Commit: 85f586c99514cf5bc73586d2d078fe0237581ad7
> Parents: 16045e6
> Author: Matt Sicker <ma...@apache.org>
> Authored: Sat Oct 4 18:55:28 2014 -0500
> Committer: Matt Sicker <ma...@apache.org>
> Committed: Sat Oct 4 18:55:28 2014 -0500
>
> ----------------------------------------------------------------------
>  .../apache/logging/log4j/jmx/gui/ClientGui.java | 22 +++++++++++---------
>  1 file changed, 12 insertions(+), 10 deletions(-)
> ----------------------------------------------------------------------
>
>
>
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85f586c9/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
> ----------------------------------------------------------------------
> diff --git
> a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
> b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
> index 0215fb5..b36cc67 100644
> ---
> a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
> +++
> b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
> @@ -16,17 +16,14 @@
>   */
>  package org.apache.logging.log4j.jmx.gui;
>
> -import java.awt.BorderLayout;
> -import java.awt.Color;
> -import java.awt.Component;
> -import java.awt.Font;
> +import java.awt.*;
>  import java.awt.event.ActionEvent;
>  import java.io.IOException;
>  import java.io.PrintWriter;
>  import java.io.StringWriter;
>  import java.util.HashMap;
>  import java.util.Map;
> -
> +import java.util.Properties;
>  import javax.management.InstanceNotFoundException;
>  import javax.management.JMException;
>  import javax.management.ListenerNotFoundException;
> @@ -177,7 +174,12 @@ public class ClientGui extends JPanel implements
> NotificationListener {
>
>      private void handleNotificationInAwtEventThread(final Notification
> notif, final Object paramObject) {
>          if
> (StatusLoggerAdminMBean.NOTIF_TYPE_MESSAGE.equals(notif.getType())) {
> -            final JTextArea text = statusLogTextAreaMap.get(paramObject);
> +            if (!(paramObject instanceof ObjectName)) {
> +                handle("Invalid notification object type", new
> ClassCastException(paramObject.getClass().getName()));
> +                return;
> +            }
> +            final ObjectName param = (ObjectName) paramObject;
> +            final JTextArea text = statusLogTextAreaMap.get(param);
>              if (text != null) {
>                  text.append(notif.getMessage() + '\n');
>              }
> @@ -258,10 +260,10 @@ public class ClientGui extends JPanel implements
> NotificationListener {
>              serviceUrl = "service:jmx:rmi:///jndi/rmi://" + args[0] +
> "/jmxrmi";
>          }
>          final JMXServiceURL url = new JMXServiceURL(serviceUrl);
> -        final Map<String, String> paramMap = new HashMap<String,
> String>();
> -        for (final Object objKey : System.getProperties().keySet()) {
> -            final String key = (String) objKey;
> -            paramMap.put(key, System.getProperties().getProperty(key));
> +        final Properties props = System.getProperties();
> +        final Map<String, String> paramMap = new HashMap<String,
> String>(props.size());
> +        for (final String key : props.stringPropertyNames()) {
> +            paramMap.put(key, props.getProperty(key));
>          }
>          final JMXConnector connector = JMXConnectorFactory.connect(url,
> paramMap);
>          final Client client = new Client(connector);
>
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
Matt Sicker <bo...@gmail.com>

Fwd: [3/3] git commit: Add more type safety.

Posted by Gary Gregory <ga...@gmail.com>.
-1. This is backwards:

-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Font;
+import java.awt.*;

We do _not_ want * imports for normal imports, only for special cases like
static imports of JUnit Assert methods.

Gary

---------- Forwarded message ----------
From: <ma...@apache.org>
Date: Sat, Oct 4, 2014 at 7:55 PM
Subject: [3/3] git commit: Add more type safety.
To: commits@logging.apache.org


Add more type safety.


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit:
http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/85f586c9
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/85f586c9
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/85f586c9

Branch: refs/heads/master
Commit: 85f586c99514cf5bc73586d2d078fe0237581ad7
Parents: 16045e6
Author: Matt Sicker <ma...@apache.org>
Authored: Sat Oct 4 18:55:28 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Sat Oct 4 18:55:28 2014 -0500

----------------------------------------------------------------------
 .../apache/logging/log4j/jmx/gui/ClientGui.java | 22 +++++++++++---------
 1 file changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85f586c9/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
----------------------------------------------------------------------
diff --git
a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
index 0215fb5..b36cc67 100644
---
a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
+++
b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
@@ -16,17 +16,14 @@
  */
 package org.apache.logging.log4j.jmx.gui;

-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Font;
+import java.awt.*;
 import java.awt.event.ActionEvent;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.HashMap;
 import java.util.Map;
-
+import java.util.Properties;
 import javax.management.InstanceNotFoundException;
 import javax.management.JMException;
 import javax.management.ListenerNotFoundException;
@@ -177,7 +174,12 @@ public class ClientGui extends JPanel implements
NotificationListener {

     private void handleNotificationInAwtEventThread(final Notification
notif, final Object paramObject) {
         if
(StatusLoggerAdminMBean.NOTIF_TYPE_MESSAGE.equals(notif.getType())) {
-            final JTextArea text = statusLogTextAreaMap.get(paramObject);
+            if (!(paramObject instanceof ObjectName)) {
+                handle("Invalid notification object type", new
ClassCastException(paramObject.getClass().getName()));
+                return;
+            }
+            final ObjectName param = (ObjectName) paramObject;
+            final JTextArea text = statusLogTextAreaMap.get(param);
             if (text != null) {
                 text.append(notif.getMessage() + '\n');
             }
@@ -258,10 +260,10 @@ public class ClientGui extends JPanel implements
NotificationListener {
             serviceUrl = "service:jmx:rmi:///jndi/rmi://" + args[0] +
"/jmxrmi";
         }
         final JMXServiceURL url = new JMXServiceURL(serviceUrl);
-        final Map<String, String> paramMap = new HashMap<String, String>();
-        for (final Object objKey : System.getProperties().keySet()) {
-            final String key = (String) objKey;
-            paramMap.put(key, System.getProperties().getProperty(key));
+        final Properties props = System.getProperties();
+        final Map<String, String> paramMap = new HashMap<String,
String>(props.size());
+        for (final String key : props.stringPropertyNames()) {
+            paramMap.put(key, props.getProperty(key));
         }
         final JMXConnector connector = JMXConnectorFactory.connect(url,
paramMap);
         final Client client = new Client(connector);




-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

[3/3] git commit: Add more type safety.

Posted by ma...@apache.org.
Add more type safety.


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/85f586c9
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/85f586c9
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/85f586c9

Branch: refs/heads/master
Commit: 85f586c99514cf5bc73586d2d078fe0237581ad7
Parents: 16045e6
Author: Matt Sicker <ma...@apache.org>
Authored: Sat Oct 4 18:55:28 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Sat Oct 4 18:55:28 2014 -0500

----------------------------------------------------------------------
 .../apache/logging/log4j/jmx/gui/ClientGui.java | 22 +++++++++++---------
 1 file changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85f586c9/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
----------------------------------------------------------------------
diff --git a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
index 0215fb5..b36cc67 100644
--- a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
+++ b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
@@ -16,17 +16,14 @@
  */
 package org.apache.logging.log4j.jmx.gui;
 
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Font;
+import java.awt.*;
 import java.awt.event.ActionEvent;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.HashMap;
 import java.util.Map;
-
+import java.util.Properties;
 import javax.management.InstanceNotFoundException;
 import javax.management.JMException;
 import javax.management.ListenerNotFoundException;
@@ -177,7 +174,12 @@ public class ClientGui extends JPanel implements NotificationListener {
 
     private void handleNotificationInAwtEventThread(final Notification notif, final Object paramObject) {
         if (StatusLoggerAdminMBean.NOTIF_TYPE_MESSAGE.equals(notif.getType())) {
-            final JTextArea text = statusLogTextAreaMap.get(paramObject);
+            if (!(paramObject instanceof ObjectName)) {
+                handle("Invalid notification object type", new ClassCastException(paramObject.getClass().getName()));
+                return;
+            }
+            final ObjectName param = (ObjectName) paramObject;
+            final JTextArea text = statusLogTextAreaMap.get(param);
             if (text != null) {
                 text.append(notif.getMessage() + '\n');
             }
@@ -258,10 +260,10 @@ public class ClientGui extends JPanel implements NotificationListener {
             serviceUrl = "service:jmx:rmi:///jndi/rmi://" + args[0] + "/jmxrmi";
         }
         final JMXServiceURL url = new JMXServiceURL(serviceUrl);
-        final Map<String, String> paramMap = new HashMap<String, String>();
-        for (final Object objKey : System.getProperties().keySet()) {
-            final String key = (String) objKey;
-            paramMap.put(key, System.getProperties().getProperty(key));
+        final Properties props = System.getProperties();
+        final Map<String, String> paramMap = new HashMap<String, String>(props.size());
+        for (final String key : props.stringPropertyNames()) {
+            paramMap.put(key, props.getProperty(key));
         }
         final JMXConnector connector = JMXConnectorFactory.connect(url, paramMap);
         final Client client = new Client(connector);


Re: [1/3] git commit: Use of constants in JConsole plugin.

Posted by Remko Popma <re...@gmail.com>.
Thanks!

On Sun, Oct 5, 2014 at 10:58 AM, Remko Popma <re...@gmail.com> wrote:

> Thanks!
>
> On Sun, Oct 5, 2014 at 8:55 AM, <ma...@apache.org> wrote:
>
>> Repository: logging-log4j2
>> Updated Branches:
>>   refs/heads/master 5ae0e6c00 -> 85f586c99
>>
>>
>> Use of constants in JConsole plugin.
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>> Commit:
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/1ebbf54b
>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/1ebbf54b
>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/1ebbf54b
>>
>> Branch: refs/heads/master
>> Commit: 1ebbf54b4d95f1b19f684521ebf1b84f86e9293c
>> Parents: 5ae0e6c
>> Author: Matt Sicker <ma...@apache.org>
>> Authored: Sat Oct 4 18:40:42 2014 -0500
>> Committer: Matt Sicker <ma...@apache.org>
>> Committed: Sat Oct 4 18:40:42 2014 -0500
>>
>> ----------------------------------------------------------------------
>>  .../log4j/jmx/gui/ClientEditConfigPanel.java        |  3 +--
>>  .../org/apache/logging/log4j/jmx/gui/ClientGui.java | 16 +++-------------
>>  2 files changed, 4 insertions(+), 15 deletions(-)
>> ----------------------------------------------------------------------
>>
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/1ebbf54b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientEditConfigPanel.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientEditConfigPanel.java
>> b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientEditConfigPanel.java
>> index 51d6468..972e0bb 100644
>> ---
>> a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientEditConfigPanel.java
>> +++
>> b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientEditConfigPanel.java
>> @@ -128,8 +128,7 @@ public class ClientEditConfigPanel extends JPanel {
>>          // configTextArea.setEditable(false);
>>          configTextArea.setBackground(Color.white);
>>          configTextArea.setForeground(Color.black);
>> -        configTextArea.setFont(new Font("Monospaced", Font.PLAIN,
>> -                configTextArea.getFont().getSize()));
>> +        configTextArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN,
>> configTextArea.getFont().getSize()));
>>          final JScrollPane scrollConfig = new JScrollPane(configTextArea);
>>
>>          locationTextField = new JTextField(LOCATION_TEXT_COLS);
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/1ebbf54b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
>> b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
>> index 67a8018..0215fb5 100644
>> ---
>> a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
>> +++
>> b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
>> @@ -40,17 +40,7 @@ import javax.management.ObjectName;
>>  import javax.management.remote.JMXConnector;
>>  import javax.management.remote.JMXConnectorFactory;
>>  import javax.management.remote.JMXServiceURL;
>> -import javax.swing.AbstractAction;
>> -import javax.swing.JFrame;
>> -import javax.swing.JOptionPane;
>> -import javax.swing.JPanel;
>> -import javax.swing.JScrollPane;
>> -import javax.swing.JTabbedPane;
>> -import javax.swing.JTextArea;
>> -import javax.swing.JToggleButton;
>> -import javax.swing.ScrollPaneConstants;
>> -import javax.swing.SwingUtilities;
>> -import javax.swing.UIManager;
>> +import javax.swing.*;
>>  import javax.swing.UIManager.LookAndFeelInfo;
>>
>>  import org.apache.logging.log4j.core.jmx.LoggerContextAdminMBean;
>> @@ -142,7 +132,7 @@ public class ClientGui extends JPanel implements
>> NotificationListener {
>>          result.setEditable(false);
>>          result.setBackground(this.getBackground());
>>          result.setForeground(Color.black);
>> -        result.setFont(new Font("Monospaced", Font.PLAIN,
>> result.getFont().getSize()));
>> +        result.setFont(new Font(Font.MONOSPACED, Font.PLAIN,
>> result.getFont().getSize()));
>>          result.setWrapStyleWord(true);
>>          return result;
>>      }
>> @@ -284,7 +274,7 @@ public class ClientGui extends JPanel implements
>> NotificationListener {
>>                  try {
>>                      final ClientGui gui = new ClientGui(client);
>>                      final JFrame frame = new JFrame(title);
>> -                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>> +
>> frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
>>                      frame.getContentPane().add(gui, BorderLayout.CENTER);
>>                      frame.pack();
>>                      frame.setVisible(true);
>>
>>
>