incubator-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ran...@apache.org
Subject cvs commit: incubator-ftpserver/src/java/org/apache/ftpserver RequestHandler.java
Date Thu, 06 Oct 2005 05:59:20 GMT
rana_b      2005/10/05 22:59:20

  Modified:    src/java/org/apache/ftpserver RequestHandler.java
  Log:
  commons-logging used
  
  Revision  Changes    Path
  1.6       +13 -11    incubator-ftpserver/src/java/org/apache/ftpserver/RequestHandler.java
  
  Index: RequestHandler.java
  ===================================================================
  RCS file: /home/cvs/incubator-ftpserver/src/java/org/apache/ftpserver/RequestHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- RequestHandler.java	4 Oct 2005 07:28:02 -0000	1.5
  +++ RequestHandler.java	6 Oct 2005 05:59:20 -0000	1.6
  @@ -26,11 +26,11 @@
   import java.net.SocketException;
   import java.util.HashMap;
   
  +import org.apache.commons.logging.Log;
   import org.apache.ftpserver.ftplet.FtpException;
   import org.apache.ftpserver.ftplet.FtpRequest;
   import org.apache.ftpserver.ftplet.Ftplet;
   import org.apache.ftpserver.ftplet.FtpletEnum;
  -import org.apache.ftpserver.ftplet.Logger;
   import org.apache.ftpserver.interfaces.ConnectionObserver;
   import org.apache.ftpserver.interfaces.IConnection;
   import org.apache.ftpserver.interfaces.IConnectionManager;
  @@ -53,6 +53,7 @@
       private static final HashMap COMMAND_MAP = new HashMap(64);
       
       private IFtpConfig m_fconfig;
  +    private Log m_log;
       
       private Socket m_controlSocket;
       private FtpRequestImpl m_request;
  @@ -71,6 +72,7 @@
       public RequestHandler(IFtpConfig fconfig, Socket controlSocket) throws IOException
{
           m_fconfig = fconfig;
           m_controlSocket = controlSocket;
  +        m_log = m_fconfig.getLogFactory().getInstance(getClass());
           
           // data connection object
           FtpDataConnection dataCon = new FtpDataConnection();
  @@ -169,12 +171,11 @@
           
           InetAddress clientAddr = m_request.getRemoteAddress();
           IConnectionManager conManager = m_fconfig.getConnectionManager();
  -        Logger logger = m_fconfig.getLogger();
  -        
           try {
               
               // write log message
  -            logger.info("Open connection - " + clientAddr.getHostAddress());
  +            String hostAddress = clientAddr.getHostAddress();
  +            m_log.info("Open connection - " + hostAddress);
               
               // notify ftp statistics
               IFtpStatistics ftpStat = (IFtpStatistics)m_fconfig.getFtpStatistics();
  @@ -197,6 +198,7 @@
                   // IP permission check
                   IIpRestrictor ipRestrictor = m_fconfig.getIpRestrictor();
                   if( !ipRestrictor.hasPermission(clientAddr) ) {
  +                    m_log.warn("No permission to access from " + hostAddress);
                       m_writer.send(530, "ip.restricted", null);
                       return;
                   }
  @@ -204,6 +206,7 @@
                   // connection limit check
                   int maxConnections = conManager.getMaxConnections();
                   if(ftpStat.getCurrentConnectionNumber() > maxConnections) {
  +                    m_log.warn("Maximum connection limit reached.");
                       m_writer.send(530, "connection.limit", null);
                       return;
                   }
  @@ -241,7 +244,7 @@
               // socket closed - no need to do anything
           }
           catch(Exception ex) {
  -            logger.warn("RequestHandler.run()", ex);
  +            m_log.warn("RequestHandler.run()", ex);
           }
           finally {
               // close all resources if not done already
  @@ -285,7 +288,7 @@
                  throw (IOException)ex;
               }
               else {
  -               m_fconfig.getLogger().warn("RequestHandler.service()", ex);
  +                m_log.warn("RequestHandler.service()", ex);
               }
           }
       }
  @@ -304,13 +307,12 @@
           }
           
           // call Ftplet.onDisconnect() method.
  -        Logger logger = m_fconfig.getLogger();
           try {
               Ftplet ftpletContainer = m_fconfig.getFtpletContainer();
               ftpletContainer.onDisconnect(m_request, m_writer);
           }
           catch(Exception ex) {
  -            logger.warn("RequestHandler.close()", ex);
  +            m_log.warn("RequestHandler.close()", ex);
           }
   
           // notify statistics object and close request
  @@ -321,7 +323,7 @@
               // log message
               String userName = request.getUser().getName();
               InetAddress clientAddr = request.getRemoteAddress(); 
  -            logger.info("Close connection : " + clientAddr.getHostAddress() + " - " + userName);
  +            m_log.info("Close connection : " + clientAddr.getHostAddress() + " - " + userName);
               
               // logout if necessary and notify statistics
               if(request.isLoggedIn()) {
  @@ -359,7 +361,7 @@
                   controlSocket.close();
               }
               catch(Exception ex) {
  -                logger.warn("RequestHandler.close()", ex);
  +                m_log.warn("RequestHandler.close()", ex);
               }
               m_controlSocket = null;
           }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@incubator.apache.org
For additional commands, e-mail: cvs-help@incubator.apache.org


Mime
View raw message