psmith      2003/06/17 16:25:41

  Modified:    src/java/org/apache/log4j/net SocketReceiver.java
  Log:
  Modified to use an inner class SocketDetails encapsulating the details
  of the Socket, without exposing the socket itself to outside classes.
  
  Revision  Changes    Path
  1.7       +34 -3     
jakarta-log4j-sandbox/src/java/org/apache/log4j/net/SocketReceiver.java
  
  Index: SocketReceiver.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/net/SocketReceiver.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SocketReceiver.java       17 Jun 2003 16:33:57 -0000      1.6
  +++ SocketReceiver.java       17 Jun 2003 23:25:41 -0000      1.7
  @@ -57,6 +57,7 @@
   import java.net.Socket;
   
   import java.util.Enumeration;
  +import java.util.Iterator;
   import java.util.Vector;
   
   
  @@ -70,6 +71,8 @@
     appenders currently configured in the LoggerRespository.
   
     @author Mark Womack
  +  @author Scott Deboy <[EMAIL PROTECTED]>
  +  @author Paul Smith <[EMAIL PROTECTED]>
     @since 1.3
   */
   public class SocketReceiver extends Receiver implements Runnable, PortBased {
  @@ -229,18 +232,46 @@
     }
     
     /**
  -   * Returns a Vector of Strings representing the IP/Domain name
  +   * Returns a Vector of SocketDetail representing the IP/Domain name
      * of the currently connected sockets that this receiver has
      * been responsible for creating.
  -   * @return
  +   * @return Vector of SocketDetails
      */
     public Vector getConnectedSocketDetails() {
       Vector details = new Vector(socketList.size());
       for(Enumeration enum = socketList.elements(); enum.hasMoreElements();) {
         Socket socket = (Socket)enum.nextElement();
  -      details.add(socket.getInetAddress().getHostName() + ":" + socket.getPort());
  +      details.add(new SocketDetail(socket));
       }
       return details; 
  +  }
  +  
  +  public static class SocketDetail implements AddressBased, PortBased {
  +
  +    private String address;
  +    private int port;
  +    
  +    private SocketDetail(Socket socket) {
  +      this.address = socket.getInetAddress().getHostName();
  +      this.port = socket.getPort();
  +    }
  +    
  +    public String getAddress() {
  +      return address;
  +    }
  +
  +    public int getPort() {
  +      return port;
  +    }
  +    public String getName() {
  +      return "Socket";
  +    }
  +    
  +    public boolean isActive() {
  +//      TODO allow a Socket to be active/inactive/paused etc.
  +      return true;
  +    }
  +    
     }
     
     /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to