[prev in list] [next in list] [prev in thread] [next in thread]
List: jakarta-commons-dev
Subject: svn commit: r1087387 - in
From: sebb () apache ! org
Date: 2011-03-31 17:54:10
Message-ID: 20110331175410.991212388901 () eris ! apache ! org
[Download RAW message or body]
Author: sebb
Date: Thu Mar 31 17:54:10 2011
New Revision: 1087387
URL: http://svn.apache.org/viewvc?rev=1087387&view=rev
Log:
Redo CommandSupport reorg - restore field to original classes
Modified:
commons/proper/net/trunk/src/main/java/org/apache/commons/net/SocketClient.java
commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTP.java
commons/proper/net/trunk/src/main/java/org/apache/commons/net/nntp/NNTP.java
commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/SMTP.java
Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/SocketClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/SocketClient.java?rev=1087387&r1=1087386&r2=1087387&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/SocketClient.java \
(original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/SocketClient.java \
Thu Mar 31 17:54:10 2011 @@ -68,6 +68,12 @@ public abstract class SocketClient
private static final ServerSocketFactory __DEFAULT_SERVER_SOCKET_FACTORY =
ServerSocketFactory.getDefault();
+ /**
+ * A ProtocolCommandSupport object used to manage the registering of
+ * ProtocolCommandListeners and te firing of ProtocolCommandEvents.
+ */
+ private ProtocolCommandSupport __commandSupport;
+
/** The timeout to use after opening a socket. */
protected int _timeout_;
@@ -100,12 +106,6 @@ public abstract class SocketClient
int sendBufferSize = -1;
/**
- * A ProtocolCommandSupport object used to manage the registering of
- * ProtocolCommandListeners and te firing of ProtocolCommandEvents.
- */
- private ProtocolCommandSupport _commandSupport_;
-
- /**
* Default constructor for SocketClient. Initializes
* _socket_ to null, _timeout_ to 0, _defaultPort to 0,
* _isConnected_ to false, and _socketFactory_ to a shared instance of
@@ -120,7 +120,6 @@ public abstract class SocketClient
_defaultPort_ = 0;
_socketFactory_ = __DEFAULT_SOCKET_FACTORY;
_serverSocketFactory_ = __DEFAULT_SERVER_SOCKET_FACTORY;
- _commandSupport_ = new ProtocolCommandSupport(this);
}
@@ -682,23 +681,21 @@ public abstract class SocketClient
/**
- * Adds a ProtocolCommandListener. Delegates this task to
- * {@link #_commandSupport_ _commandSupport_ }.
- * <p>
+ * Adds a ProtocolCommandListener.
+ *
* @param listener The ProtocolCommandListener to add.
*/
public void addProtocolCommandListener(ProtocolCommandListener listener) {
- _commandSupport_.addProtocolCommandListener(listener);
+ getCommandSupport().addProtocolCommandListener(listener);
}
/***
- * Removes a ProtocolCommandListener. Delegates this task to
- * {@link #_commandSupport_ _commandSupport_ }.
- * <p>
+ * Removes a ProtocolCommandListener.
+ *
* @param listener The ProtocolCommandListener to remove.
***/
public void removeProtocolCommandListener(ProtocolCommandListener listener) {
- _commandSupport_.removeProtocolCommandListener(listener);
+ getCommandSupport().removeProtocolCommandListener(listener);
}
/**
@@ -708,8 +705,8 @@ public abstract class SocketClient
* @param reply the full reply text
*/
protected void fireReplyReceived(int replyCode, String reply) {
- if (_commandSupport_.getListenerCount() > 0) {
- _commandSupport_.fireReplyReceived(replyCode, reply);
+ if (getCommandSupport().getListenerCount() > 0) {
+ getCommandSupport().fireReplyReceived(replyCode, reply);
}
}
@@ -718,18 +715,36 @@ public abstract class SocketClient
*
* @param command the command name
* @param message the complete message, including command name
+ * @since 3.0
*/
protected void fireCommandSent(String command, String message) {
- if (_commandSupport_.getListenerCount() > 0) {
- _commandSupport_.fireCommandSent(command, message);
+ if (getCommandSupport().getListenerCount() > 0) {
+ getCommandSupport().fireCommandSent(command, message);
}
}
-
- // Provide read-only access (mainly for use in restoring binary compatibility)
+
+ /**
+ * Create the CommandSupport instance if required
+ */
+ protected final void createCommandSupport(){
+ __commandSupport = new ProtocolCommandSupport(this);
+ }
+
+ /**
+ * Subclasses can override this if they need to provide their own
+ * instance field for backwards compatibilty.
+ *
+ * @return the CommandSupport instance, may be {@code null}
+ * @since 3.0
+ */
protected ProtocolCommandSupport getCommandSupport() {
- return _commandSupport_;
+ return __commandSupport;
}
+ /*
+ * N.B. Fields cannot be pulled up into a super-class without breaking binary \
compatibility, + * so the abstract method is needed to pass the instance to the \
methods which were moved here. + */
}
Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTP.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTP.java?rev=1087387&r1=1087386&r2=1087387&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTP.java \
(original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTP.java Thu \
Mar 31 17:54:10 2011 @@ -221,6 +221,12 @@ public class FTP extends SocketClient
protected String _controlEncoding;
/**
+ * A ProtocolCommandSupport object used to manage the registering of
+ * ProtocolCommandListeners and te firing of ProtocolCommandEvents.
+ */
+ protected ProtocolCommandSupport _commandSupport_;
+
+ /**
* This is used to signal whether a block of multiline responses beginning
* with xxx must be terminated by the same numeric code xxx
* See section 4.2 of RFC 959 for details.
@@ -258,6 +264,7 @@ public class FTP extends SocketClient
_newReplyString = false;
_replyString = null;
_controlEncoding = DEFAULT_CONTROL_ENCODING;
+ _commandSupport_ = new ProtocolCommandSupport(this);
}
// The RFC-compliant multiline termination check
@@ -1712,12 +1719,12 @@ public class FTP extends SocketClient
}
/**
- * Copy of commandSupport needed to maintain binary compatibility.
- * Do not use.
- * @deprecated 3.0 use {@link #getCommandSupport()} instead
+ * Provide command support to super-class
*/
- @Deprecated
- protected ProtocolCommandSupport _commandSupport_= getCommandSupport();
+ @Override
+ protected ProtocolCommandSupport getCommandSupport() {
+ return _commandSupport_;
+ }
}
/* Emacs configuration
Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/nntp/NNTP.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/nntp/NNTP.java?rev=1087387&r1=1087386&r2=1087387&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/nntp/NNTP.java \
(original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/nntp/NNTP.java Thu \
Mar 31 17:54:10 2011 @@ -108,6 +108,12 @@ public class NNTP extends SocketClient
*/
protected BufferedWriter _writer_;
+ /**
+ * A ProtocolCommandSupport object used to manage the registering of
+ * ProtocolCommandListeners and te firing of ProtocolCommandEvents.
+ */
+ protected ProtocolCommandSupport _commandSupport_;
+
/***
* The default NNTP constructor. Sets the default port to
* <code>DEFAULT_PORT</code> and initializes internal data structures
@@ -120,6 +126,7 @@ public class NNTP extends SocketClient
_reader_ = null;
_writer_ = null;
_isAllowedToPost = false;
+ _commandSupport_ = new ProtocolCommandSupport(this);
}
private void __getReply() throws IOException
@@ -1002,12 +1009,12 @@ public class NNTP extends SocketClient
}
/**
- * Copy of commandSupport needed to maintain binary compatibility.
- * Do not use.
- * @deprecated 3.0 use {@link #getCommandSupport()} instead
+ * Provide command support to super-class
*/
- @Deprecated
- protected ProtocolCommandSupport _commandSupport_= getCommandSupport();
+ @Override
+ protected ProtocolCommandSupport getCommandSupport() {
+ return _commandSupport_;
+ }
}
/* Emacs configuration
Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/SMTP.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/SMTP.java?rev=1087387&r1=1087386&r2=1087387&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/SMTP.java \
(original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/SMTP.java Thu \
Mar 31 17:54:10 2011 @@ -95,6 +95,12 @@ public class SMTP extends SocketClient
/** The encoding to use (user-settable) */
private String encoding = __DEFAULT_ENCODING;
+ /**
+ * A ProtocolCommandSupport object used to manage the registering of
+ * ProtocolCommandListeners and te firing of ProtocolCommandEvents.
+ */
+ protected ProtocolCommandSupport _commandSupport_;
+
BufferedReader _reader;
BufferedWriter _writer;
int _replyCode;
@@ -113,6 +119,7 @@ public class SMTP extends SocketClient
_replyLines = new ArrayList<String>();
_newReplyString = false;
_replyString = null;
+ _commandSupport_ = new ProtocolCommandSupport(this);
}
/**
@@ -754,12 +761,12 @@ public class SMTP extends SocketClient
}
/**
- * Copy of commandSupport needed to maintain binary compatibility.
- * Do not use.
- * @deprecated 3.0 use {@link #getCommandSupport()} instead
+ * Provide command support to super-class
*/
- @Deprecated
- protected ProtocolCommandSupport _commandSupport_= getCommandSupport();
+ @Override
+ protected ProtocolCommandSupport getCommandSupport() {
+ return _commandSupport_;
+ }
}
/* Emacs configuration
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic