logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From psm...@apache.org
Subject cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LogUI.java
Date Fri, 19 Sep 2003 03:56:56 GMT
psmith      2003/09/18 20:56:56

  Modified:    src/java/org/apache/log4j/chainsaw LogUI.java
  Log:
  Small change to Plugin Listener notification within Chainsaw.
  
  Revision  Changes    Path
  1.32      +47 -21    jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogUI.java
  
  Index: LogUI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogUI.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- LogUI.java	18 Sep 2003 04:03:38 -0000	1.31
  +++ LogUI.java	19 Sep 2003 03:56:56 -0000	1.32
  @@ -49,6 +49,24 @@
   
   package org.apache.log4j.chainsaw;
   
  +import org.apache.log4j.Level;
  +import org.apache.log4j.LogManager;
  +import org.apache.log4j.Priority;
  +import org.apache.log4j.UtilLoggingLevel;
  +import org.apache.log4j.chainsaw.icons.ChainsawIcons;
  +import org.apache.log4j.chainsaw.prefs.LoadSettingsEvent;
  +import org.apache.log4j.chainsaw.prefs.SaveSettingsEvent;
  +import org.apache.log4j.chainsaw.prefs.SettingsListener;
  +import org.apache.log4j.chainsaw.prefs.SettingsManager;
  +import org.apache.log4j.helpers.LogLog;
  +import org.apache.log4j.helpers.OptionConverter;
  +import org.apache.log4j.net.SocketNodeEventListener;
  +import org.apache.log4j.plugins.Plugin;
  +import org.apache.log4j.plugins.PluginEvent;
  +import org.apache.log4j.plugins.PluginListener;
  +import org.apache.log4j.plugins.PluginRegistry;
  +import org.apache.log4j.plugins.Receiver;
  +
   import java.awt.BorderLayout;
   import java.awt.Component;
   import java.awt.Dimension;
  @@ -63,15 +81,20 @@
   import java.awt.event.MouseEvent;
   import java.awt.event.WindowAdapter;
   import java.awt.event.WindowEvent;
  +
   import java.beans.PropertyChangeEvent;
   import java.beans.PropertyChangeListener;
  +
   import java.io.BufferedInputStream;
   import java.io.File;
   import java.io.FileInputStream;
   import java.io.IOException;
   import java.io.ObjectInputStream;
  +
   import java.lang.reflect.Method;
  +
   import java.net.URL;
  +
   import java.util.ArrayList;
   import java.util.HashMap;
   import java.util.Iterator;
  @@ -97,24 +120,6 @@
   import javax.swing.event.ChangeListener;
   import javax.swing.event.EventListenerList;
   
  -import org.apache.log4j.Level;
  -import org.apache.log4j.LogManager;
  -import org.apache.log4j.Priority;
  -import org.apache.log4j.UtilLoggingLevel;
  -import org.apache.log4j.chainsaw.icons.ChainsawIcons;
  -import org.apache.log4j.chainsaw.prefs.LoadSettingsEvent;
  -import org.apache.log4j.chainsaw.prefs.SaveSettingsEvent;
  -import org.apache.log4j.chainsaw.prefs.SettingsListener;
  -import org.apache.log4j.chainsaw.prefs.SettingsManager;
  -import org.apache.log4j.helpers.LogLog;
  -import org.apache.log4j.helpers.OptionConverter;
  -import org.apache.log4j.net.SocketNodeEventListener;
  -import org.apache.log4j.plugins.Plugin;
  -import org.apache.log4j.plugins.PluginEvent;
  -import org.apache.log4j.plugins.PluginListener;
  -import org.apache.log4j.plugins.PluginRegistry;
  -import org.apache.log4j.plugins.Receiver;
  -
   
   /**
    * The main entry point for Chainsaw, this class represents the first frame
  @@ -357,9 +362,19 @@
         new PluginListener() {
           public void pluginStarted(PluginEvent e) {
             statusBar.setMessage(e.getPlugin().getName() + " started!");
  +
  +          Method method = getAddListenerMethod(e.getPlugin());
  +
  +          if (method != null) {
  +            try {
  +              method.invoke(e.getPlugin(), new Object[] { socketListener });
  +            } catch (Exception ex) {
  +              LogLog.error("Failed to add a SocketNodeEventListener", ex);
  +            }
  +          }
           }
   
  -        Method getSocketNodeEventListenerMethod(Plugin p) {
  +        Method getRemoveListenerMethod(Plugin p) {
             try {
               return p.getClass().getMethod(
                 "removeSocketNodeEventListener",
  @@ -369,8 +384,18 @@
             }
           }
   
  +        Method getAddListenerMethod(Plugin p) {
  +          try {
  +            return p.getClass().getMethod(
  +              "addSocketNodeEventListener",
  +              new Class[] { SocketNodeEventListener.class });
  +          } catch (Exception e) {
  +            return null;
  +          }
  +        }
  +
           public void pluginStopped(PluginEvent e) {
  -          Method method = getSocketNodeEventListenerMethod(e.getPlugin());
  +          Method method = getRemoveListenerMethod(e.getPlugin());
   
             if (method != null) {
               try {
  @@ -379,7 +404,8 @@
                 LogLog.error("Failed to remove SocketNodeEventListener", ex);
               }
             }
  -		  statusBar.setMessage(e.getPlugin().getName() + " stopped!");
  +
  +          statusBar.setMessage(e.getPlugin().getName() + " stopped!");
           }
         };
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org


Mime
View raw message