@Override public void protocolCommandSent(final ProtocolCommandEvent event) { if (logger.isDebugEnabled()) { logger.debug(processor + " : " + event.getMessage().trim()); } }
/** * If there are any listeners, send them the command details. * * @param command the command name * @param message the complete message, including command name * @since 3.0 */ protected void fireCommandSent(String command, String message) { if (getCommandSupport().getListenerCount() > 0) { getCommandSupport().fireCommandSent(command, message); } }
/** * Removes a ProtocolCommandListener. * * @param listener The ProtocolCommandListener to remove. * @since 3.0 */ public void removeProtocolCommandListener(ProtocolCommandListener listener) { getCommandSupport().removeProtocolCommandListener(listener); }
/** * If there are any listeners, send them the reply details. * * @param replyCode the code extracted from the reply * @param reply the full reply text * @since 3.0 */ protected void fireReplyReceived(int replyCode, String reply) { if (getCommandSupport().getListenerCount() > 0) { getCommandSupport().fireReplyReceived(replyCode, reply); } }
/*** * Fires a ProtocolCommandEvent signalling the sending of a command to all * registered listeners, invoking their * {@link org.apache.commons.net.ProtocolCommandListener#protocolCommandSent protocolCommandSent() } * methods. * * @param command The string representation of the command type sent, not * including the arguments (e.g., "STAT" or "GET"). * @param message The entire command string verbatim as sent to the server, * including all arguments. ***/ public void fireCommandSent(String command, String message) { ProtocolCommandEvent event; event = new ProtocolCommandEvent(__source, command, message); for (EventListener listener : __listeners) { ((ProtocolCommandListener)listener).protocolCommandSent(event); } }
/*** * Fires a ProtocolCommandEvent signalling the reception of a command reply * to all registered listeners, invoking their * {@link org.apache.commons.net.ProtocolCommandListener#protocolReplyReceived protocolReplyReceived() } * methods. * * @param replyCode The integer code indicating the natureof the reply. * This will be the protocol integer value for protocols * that use integer reply codes, or the reply class constant * corresponding to the reply for protocols like POP3 that use * strings like OK rather than integer codes (i.e., POP3Repy.OK). * @param message The entire reply as received from the server. ***/ public void fireReplyReceived(int replyCode, String message) { ProtocolCommandEvent event; event = new ProtocolCommandEvent(__source, replyCode, message); for (EventListener listener : __listeners) { ((ProtocolCommandListener)listener).protocolReplyReceived(event); } }
/** * Opens a Socket connected to a remote host at the current default port * and originating from the current host at a system assigned port. * Before returning, {@link #_connectAction_ _connectAction_() } * is called to perform connection initialization actions. * <p> * @param host The remote host. * @throws SocketException If the socket timeout could not be set. * @throws IOException If the socket could not be opened. In most * cases you will only want to catch IOException since SocketException is * derived from it. */ public void connect(InetAddress host) throws SocketException, IOException { _hostname_ = null; connect(host, _defaultPort_); }
/*** * Closes the control connection to the FTP server and sets to null * some internal data so that the memory may be reclaimed by the * garbage collector. The reply text and code information from the * last command is voided so that the memory it used may be reclaimed. * Also sets {@link #_controlInput_} and {@link #_controlOutput_} to null. * * @throws IOException If an error occurs while disconnecting. ***/ @Override public void disconnect() throws IOException { super.disconnect(); _controlInput_ = null; _controlOutput_ = null; _newReplyString = false; _replyString = null; }
/** * Adds a ProtocolCommandListener. * * @param listener The ProtocolCommandListener to add. * @since 3.0 */ public void addProtocolCommandListener(ProtocolCommandListener listener) { getCommandSupport().addProtocolCommandListener(listener); }
/** * Sets the proxy for use with all the connections. * The proxy is used for connections established after the * call to this method. * * @param proxy the new proxy for connections. * @since 3.2 */ public void setProxy(Proxy proxy) { setSocketFactory(new DefaultSocketFactory(proxy)); connProxy = proxy; }
/** * Create the CommandSupport instance if required */ protected void createCommandSupport(){ __commandSupport = new ProtocolCommandSupport(this); }
/*** * Returns true if the ProtocolCommandEvent was generated as a result * of receiving a reply. * * @return true If the ProtocolCommandEvent was generated as a result * of receiving a reply. False otherwise. ***/ public boolean isReply() { return !isCommand(); }
/** * Opens a Socket connected to a remote host at the specified port and * originating from the current host at a system assigned port. * Before returning, {@link #_connectAction_ _connectAction_() } * is called to perform connection initialization actions. * <p> * @param host The remote host. * @param port The port to connect to on the remote host. * @throws SocketException If the socket timeout could not be set. * @throws IOException If the socket could not be opened. In most * cases you will only want to catch IOException since SocketException is * derived from it. */ public void connect(InetAddress host, int port) throws SocketException, IOException { _hostname_ = null; _connect(host, port, null, -1); }
/** * Disconnects the socket connection. * You should call this method after you've finished using the class * instance and also before you call * {@link #connect connect() } * again. _isConnected_ is set to false, _socket_ is set to null, * _input_ is set to null, and _output_ is set to null. * <p> * @throws IOException If there is an error closing the socket. */ public void disconnect() throws IOException { closeQuietly(_socket_); closeQuietly(_input_); closeQuietly(_output_); _socket_ = null; _hostname_ = null; _input_ = null; _output_ = null; }
@Override public void protocolReplyReceived(final ProtocolCommandEvent event) { if (logger.isDebugEnabled()) { logger.debug(processor + " : " + event.getMessage().trim()); } }
/** * Opens a Socket connected to a remote host at the current default * port and originating from the current host at a system assigned port. * Before returning, {@link #_connectAction_ _connectAction_() } * is called to perform connection initialization actions. * <p> * @param hostname The name of the remote host. * @throws SocketException If the socket timeout could not be set. * @throws IOException If the socket could not be opened. In most * cases you will only want to catch IOException since SocketException is * derived from it. * @throws java.net.UnknownHostException If the hostname cannot be resolved. */ public void connect(String hostname) throws SocketException, IOException { connect(hostname, _defaultPort_); }
/*** * Closes the connection to the NNTP server and sets to null * some internal data so that the memory may be reclaimed by the * garbage collector. The reply text and code information from the * last command is voided so that the memory it used may be reclaimed. * <p> * @throws IOException If an error occurs while disconnecting. ***/ @Override public void disconnect() throws IOException { super.disconnect(); _reader_ = null; _writer_ = null; _replyString = null; _isAllowedToPost = false; }
public void protocolCommandSent(ProtocolCommandEvent event) { recordControlMessage("> ", event.getMessage()); }
public void protocolReplyReceived(ProtocolCommandEvent event) { recordControlMessage("< ", event.getMessage()); }
@Override public void protocolReplyReceived(ProtocolCommandEvent event) { if (__directionMarker) { __writer.print("< "); } __writer.print(event.getMessage()); __writer.flush(); } }