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/net SocketHubReceiver.java
Date Thu, 18 Sep 2003 03:05:31 GMT
psmith      2003/09/17 20:05:31

  Modified:    src/java/org/apache/log4j/net SocketHubReceiver.java
  Log:
  added SocketNodeEventListener support to SocketHubReceiver.
  
  Revision  Changes    Path
  1.7       +31 -1     jakarta-log4j/src/java/org/apache/log4j/net/SocketHubReceiver.java
  
  Index: SocketHubReceiver.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/net/SocketHubReceiver.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SocketHubReceiver.java	15 Sep 2003 06:37:46 -0000	1.6
  +++ SocketHubReceiver.java	18 Sep 2003 03:05:31 -0000	1.7
  @@ -10,6 +10,8 @@
   import java.io.IOException;
   import java.net.Socket;
   
  +import javax.swing.event.EventListenerList;
  +
   import org.apache.log4j.spi.LoggerRepository;
   import org.apache.log4j.plugins.Receiver;
   import org.apache.log4j.helpers.LogLog;
  @@ -25,6 +27,7 @@
     
     @author Mark Womack
     @author Ceki Gülcü
  +  @author Paul Smith <psmith@apache.org>
     @since 1.3
   */
   public class SocketHubReceiver
  @@ -39,6 +42,8 @@
     protected Connector connector;
     
     protected Socket socket;
  +  
  +  private EventListenerList listenerList = new EventListenerList();
       
     public SocketHubReceiver() { }
     
  @@ -54,6 +59,24 @@
     }
     
     /**
  +   * Adds a SocketNodeEventListener to this receiver to be notified
  +   * of SocketNode events
  +   * @param l
  +   */
  +  public void addSocketNodeEventListener(SocketNodeEventListener l){
  +  	listenerList.add(SocketNodeEventListener.class, l);
  +  }
  +  
  +  /**
  +   * Removes a specific SocketNodeEventListener from this instance
  +   * so that it will no  longer be notified of SocketNode events.
  +   * @param l
  +   */
  +  public void removeSocketNodeEventListener(SocketNodeEventListener l){
  +  	listenerList.remove(SocketNodeEventListener.class, l);
  +  }
  +  
  +  /**
       Get the remote host to connect to for logging events. */
     public String getHost() {
       return host;
  @@ -189,7 +212,14 @@
       connector = null;
       socket = _socket;
       SocketNode node = new SocketNode(socket, this);
  -    node.setListener(this);
  +    node.addSocketNodeEventListener(this);
  +	SocketNodeEventListener[] listeners =
  +	  (SocketNodeEventListener[]) listenerList.getListeners(
  +		SocketNodeEventListener.class);
  +
  +	for (int i = 0; i < listeners.length; i++) {
  +	  node.addSocketNodeEventListener(listeners[i]);
  +	}
       new Thread(node).start();
     }
     
  
  
  

---------------------------------------------------------------------
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