commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwins...@apache.org
Subject svn commit: r436969 - in /jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net: ./ bsd/ io/ nntp/ ntp/ pop3/ smtp/ telnet/ tftp/ util/
Date Fri, 25 Aug 2006 21:51:35 GMT
Author: rwinston
Date: Fri Aug 25 14:51:30 2006
New Revision: 436969

URL: http://svn.apache.org/viewvc?rev=436969&view=rev
Log:
* Import cleanup
* Use CopyOnWriteArrayList to store listener list
* Make ListenerList.java implement Iterable<EventListener>

Modified:
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/FingerClient.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/ProtocolCommandSupport.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/TimeTCPClient.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/bsd/RExecClient.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/io/CopyStreamAdapter.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/nntp/NNTP.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/nntp/NNTPClient.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/ntp/NTPUDPClient.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/ntp/TimeInfo.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/ntp/TimeStamp.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/pop3/POP3.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/pop3/POP3Client.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/smtp/SMTP.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/smtp/SMTPClient.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/telnet/Telnet.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/telnet/TelnetClient.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/telnet/TelnetInputStream.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/tftp/TFTP.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/tftp/TFTPClient.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/util/ListenerList.java

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/FingerClient.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/FingerClient.java?rev=436969&r1=436968&r2=436969&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/FingerClient.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/FingerClient.java
Fri Aug 25 14:51:30 2006
@@ -15,12 +15,12 @@
  */
 package org.apache.commons.net;
 
+import java.io.BufferedOutputStream;
 import java.io.BufferedReader;
+import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.io.BufferedOutputStream;
-import java.io.DataOutputStream;
 
 /***
  * The FingerClient class implements the client side of the Internet Finger

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/ProtocolCommandSupport.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/ProtocolCommandSupport.java?rev=436969&r1=436968&r2=436969&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/ProtocolCommandSupport.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/ProtocolCommandSupport.java
Fri Aug 25 14:51:30 2006
@@ -17,6 +17,8 @@
 
 import java.io.Serializable;
 import java.util.Enumeration;
+import java.util.EventListener;
+
 import org.apache.commons.net.util.ListenerList;
 
 /***
@@ -62,18 +64,13 @@
      ***/
     public void fireCommandSent(String command, String message)
     {
-        Enumeration en;
         ProtocolCommandEvent event;
-        ProtocolCommandListener listener;
-
-        en = __listeners.getListeners();
 
         event = new ProtocolCommandEvent(__source, command, message);
 
-        while (en.hasMoreElements())
+        for (EventListener listener : __listeners)
         {
-            listener = (ProtocolCommandListener)en.nextElement();
-            listener.protocolCommandSent(event);
+           ((ProtocolCommandListener)listener).protocolCommandSent(event);
         }
     }
 
@@ -92,18 +89,12 @@
      ***/
     public void fireReplyReceived(int replyCode, String message)
     {
-        Enumeration en;
         ProtocolCommandEvent event;
-        ProtocolCommandListener listener;
-
-        en = __listeners.getListeners();
-
         event = new ProtocolCommandEvent(__source, replyCode, message);
 
-        while (en.hasMoreElements())
+        for (EventListener listener : __listeners)
         {
-            listener = (ProtocolCommandListener)en.nextElement();
-            listener.protocolReplyReceived(event);
+            ((ProtocolCommandListener)listener).protocolReplyReceived(event);
         }
     }
 

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/TimeTCPClient.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/TimeTCPClient.java?rev=436969&r1=436968&r2=436969&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/TimeTCPClient.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/TimeTCPClient.java
Fri Aug 25 14:51:30 2006
@@ -15,9 +15,9 @@
  */
 package org.apache.commons.net;
 
+import java.io.DataInputStream;
 import java.io.IOException;
 import java.util.Date;
-import java.io.DataInputStream;
 
 /***
  * The TimeTCPClient class is a TCP implementation of a client for the

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/bsd/RExecClient.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/bsd/RExecClient.java?rev=436969&r1=436968&r2=436969&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/bsd/RExecClient.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/bsd/RExecClient.java
Fri Aug 25 14:51:30 2006
@@ -17,11 +17,12 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.net.ServerSocket;
 import java.net.Socket;
-import org.apache.commons.net.io.SocketInputStream;
+
 import org.apache.commons.net.SocketClient;
-import java.io.OutputStream;
+import org.apache.commons.net.io.SocketInputStream;
 
 /***
  * RExecClient implements the rexec() facility that first appeared in

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/io/CopyStreamAdapter.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/io/CopyStreamAdapter.java?rev=436969&r1=436968&r2=436969&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/io/CopyStreamAdapter.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/io/CopyStreamAdapter.java
Fri Aug 25 14:51:30 2006
@@ -16,6 +16,8 @@
 package org.apache.commons.net.io;
 
 import java.util.Enumeration;
+import java.util.EventListener;
+
 import org.apache.commons.net.util.ListenerList;
 
 /**
@@ -83,20 +85,16 @@
     public void bytesTransferred(long totalBytesTransferred,
                                  int bytesTransferred, long streamSize)
     {
-        Enumeration listeners;
         CopyStreamEvent event;
 
-        listeners = internalListeners.getListeners();
-
         event = new CopyStreamEvent(this,
                                     totalBytesTransferred,
                                     bytesTransferred,
                                     streamSize);
 
-        while (listeners.hasMoreElements())
+        for (EventListener listener : internalListeners)
         {
-            ((CopyStreamListener) (listeners.nextElement())).
-                bytesTransferred(event);
+            ((CopyStreamListener) (listener)).bytesTransferred(event);
         }
     }
 

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/nntp/NNTP.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/nntp/NNTP.java?rev=436969&r1=436968&r2=436969&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/nntp/NNTP.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/nntp/NNTP.java
Fri Aug 25 14:51:30 2006
@@ -20,9 +20,10 @@
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
+
 import org.apache.commons.net.MalformedServerReplyException;
-import org.apache.commons.net.ProtocolCommandSupport;
 import org.apache.commons.net.ProtocolCommandListener;
+import org.apache.commons.net.ProtocolCommandSupport;
 import org.apache.commons.net.SocketClient;
 
 /***

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/nntp/NNTPClient.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/nntp/NNTPClient.java?rev=436969&r1=436968&r2=436969&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/nntp/NNTPClient.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/nntp/NNTPClient.java
Fri Aug 25 14:51:30 2006
@@ -22,10 +22,11 @@
 import java.io.Writer;
 import java.util.StringTokenizer;
 import java.util.Vector;
+
+import org.apache.commons.net.MalformedServerReplyException;
 import org.apache.commons.net.io.DotTerminatedMessageReader;
 import org.apache.commons.net.io.DotTerminatedMessageWriter;
 import org.apache.commons.net.io.Util;
-import org.apache.commons.net.MalformedServerReplyException;
 
 /***
  * NNTPClient encapsulates all the functionality necessary to post and

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/ntp/NTPUDPClient.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/ntp/NTPUDPClient.java?rev=436969&r1=436968&r2=436969&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/ntp/NTPUDPClient.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/ntp/NTPUDPClient.java
Fri Aug 25 14:51:30 2006
@@ -18,6 +18,7 @@
 import java.io.IOException;
 import java.net.DatagramPacket;
 import java.net.InetAddress;
+
 import org.apache.commons.net.DatagramSocketClient;
 
 /***

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/ntp/TimeInfo.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/ntp/TimeInfo.java?rev=436969&r1=436968&r2=436969&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/ntp/TimeInfo.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/ntp/TimeInfo.java
Fri Aug 25 14:51:30 2006
@@ -15,8 +15,8 @@
  * limitations under the License.
  */
 
-import java.util.List;
 import java.util.ArrayList;
+import java.util.List;
 
 /**
  * Wrapper class to network time packet messages (NTP, etc) that computes

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/ntp/TimeStamp.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/ntp/TimeStamp.java?rev=436969&r1=436968&r2=436969&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/ntp/TimeStamp.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/ntp/TimeStamp.java
Fri Aug 25 14:51:30 2006
@@ -16,12 +16,12 @@
  */
 
 
-import java.util.TimeZone;
-import java.util.Date;
-import java.util.Locale;
 import java.lang.ref.SoftReference;
-import java.text.SimpleDateFormat;
 import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
 
 /***
  * TimeStamp class represents the Network Time Protocol (NTP) timestamp

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/pop3/POP3.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/pop3/POP3.java?rev=436969&r1=436968&r2=436969&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/pop3/POP3.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/pop3/POP3.java
Fri Aug 25 14:51:30 2006
@@ -21,9 +21,9 @@
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
-import java.lang.StringBuffer;
 import java.util.Enumeration;
 import java.util.Vector;
+
 import org.apache.commons.net.MalformedServerReplyException;
 import org.apache.commons.net.ProtocolCommandListener;
 import org.apache.commons.net.ProtocolCommandSupport;

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/pop3/POP3Client.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/pop3/POP3Client.java?rev=436969&r1=436968&r2=436969&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/pop3/POP3Client.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/pop3/POP3Client.java
Fri Aug 25 14:51:30 2006
@@ -21,6 +21,7 @@
 import java.security.NoSuchAlgorithmException;
 import java.util.Enumeration;
 import java.util.StringTokenizer;
+
 import org.apache.commons.net.io.DotTerminatedMessageReader;
 
 /***

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/smtp/SMTP.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/smtp/SMTP.java?rev=436969&r1=436968&r2=436969&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/smtp/SMTP.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/smtp/SMTP.java
Fri Aug 25 14:51:30 2006
@@ -22,6 +22,7 @@
 import java.io.OutputStreamWriter;
 import java.util.Enumeration;
 import java.util.Vector;
+
 import org.apache.commons.net.MalformedServerReplyException;
 import org.apache.commons.net.ProtocolCommandListener;
 import org.apache.commons.net.ProtocolCommandSupport;

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/smtp/SMTPClient.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/smtp/SMTPClient.java?rev=436969&r1=436968&r2=436969&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/smtp/SMTPClient.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/smtp/SMTPClient.java
Fri Aug 25 14:51:30 2006
@@ -18,6 +18,7 @@
 import java.io.IOException;
 import java.io.Writer;
 import java.net.InetAddress;
+
 import org.apache.commons.net.io.DotTerminatedMessageWriter;
 
 /***

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/telnet/Telnet.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/telnet/Telnet.java?rev=436969&r1=436968&r2=436969&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/telnet/Telnet.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/telnet/Telnet.java
Fri Aug 25 14:51:30 2006
@@ -17,8 +17,9 @@
 
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
-import java.io.OutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
+
 import org.apache.commons.net.SocketClient;
 
 /**

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/telnet/TelnetClient.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/telnet/TelnetClient.java?rev=436969&r1=436968&r2=436969&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/telnet/TelnetClient.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/telnet/TelnetClient.java
Fri Aug 25 14:51:30 2006
@@ -19,6 +19,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+
 import org.apache.commons.net.io.FromNetASCIIInputStream;
 import org.apache.commons.net.io.ToNetASCIIOutputStream;
 

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/telnet/TelnetInputStream.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/telnet/TelnetInputStream.java?rev=436969&r1=436968&r2=436969&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/telnet/TelnetInputStream.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/telnet/TelnetInputStream.java
Fri Aug 25 14:51:30 2006
@@ -86,6 +86,7 @@
 
         int priority;
         __isClosed = false;
+        // TODO remove this
         // Need to set a higher priority in case JVM does not use pre-emptive
         // threads.  This should prevent scheduler induced deadlock (rather than
         // deadlock caused by a bug in this code).

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/tftp/TFTP.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/tftp/TFTP.java?rev=436969&r1=436968&r2=436969&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/tftp/TFTP.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/tftp/TFTP.java
Fri Aug 25 14:51:30 2006
@@ -19,6 +19,7 @@
 import java.io.InterruptedIOException;
 import java.net.DatagramPacket;
 import java.net.SocketException;
+
 import org.apache.commons.net.DatagramSocketClient;
 
 /***

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/tftp/TFTPClient.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/tftp/TFTPClient.java?rev=436969&r1=436968&r2=436969&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/tftp/TFTPClient.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/tftp/TFTPClient.java
Fri Aug 25 14:51:30 2006
@@ -22,6 +22,7 @@
 import java.net.InetAddress;
 import java.net.SocketException;
 import java.net.UnknownHostException;
+
 import org.apache.commons.net.io.FromNetASCIIOutputStream;
 import org.apache.commons.net.io.ToNetASCIIInputStream;
 

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/util/ListenerList.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/util/ListenerList.java?rev=436969&r1=436968&r2=436969&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/util/ListenerList.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/java/org/apache/commons/net/util/ListenerList.java
Fri Aug 25 14:51:30 2006
@@ -18,39 +18,45 @@
 import java.io.Serializable;
 import java.util.Enumeration;
 import java.util.EventListener;
+import java.util.Iterator;
 import java.util.Vector;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 /**
  * @author Daniel F. Savarese
  */
 
-public class ListenerList implements Serializable
+public class ListenerList implements Serializable, Iterable<EventListener>
 {
-    private Vector __listeners;
+    private final CopyOnWriteArrayList<EventListener> __listeners;
 
     public ListenerList()
     {
-        __listeners = new Vector();
+        __listeners = new CopyOnWriteArrayList<EventListener>();
     }
 
     public synchronized void addListener(EventListener listener)
     {
-        __listeners.addElement(listener);
+    		__listeners.add(listener);
     }
 
     public synchronized void removeListener(EventListener listener)
     {
-        __listeners.removeElement(listener);
-    }
-
-    public synchronized Enumeration getListeners()
-    {
-        return ((Vector)__listeners.clone()).elements();
+    		__listeners.remove(listener);
     }
 
     public int getListenerCount()
     {
         return __listeners.size();
+    }
+    
+    /**
+     * Return an {@link Iterator} for the {@link EventListener} instances
+     * 
+     * TODO Check that this is a good defensive strategy
+     */
+    public Iterator<EventListener> iterator() {
+    		return __listeners.iterator();
     }
 
 }



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


Mime
View raw message