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 FtpConfigImpl.java
Date Thu, 06 Oct 2005 05:56:27 GMT
rana_b      2005/10/05 22:56:27

  Modified:    src/java/org/apache/ftpserver FtpConfigImpl.java
  Log:
  commons-logging used
  
  Revision  Changes    Path
  1.3       +28 -31    incubator-ftpserver/src/java/org/apache/ftpserver/FtpConfigImpl.java
  
  Index: FtpConfigImpl.java
  ===================================================================
  RCS file: /home/cvs/incubator-ftpserver/src/java/org/apache/ftpserver/FtpConfigImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FtpConfigImpl.java	9 Sep 2005 11:24:33 -0000	1.2
  +++ FtpConfigImpl.java	6 Oct 2005 05:56:27 -0000	1.3
  @@ -16,13 +16,16 @@
    */
   package org.apache.ftpserver;
   
  +import java.net.InetAddress;
  +
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   import org.apache.ftpserver.ftplet.Component;
   import org.apache.ftpserver.ftplet.Configuration;
   import org.apache.ftpserver.ftplet.EmptyConfiguration;
   import org.apache.ftpserver.ftplet.FileSystemManager;
   import org.apache.ftpserver.ftplet.FtpStatistics;
   import org.apache.ftpserver.ftplet.Ftplet;
  -import org.apache.ftpserver.ftplet.Logger;
   import org.apache.ftpserver.ftplet.UserManager;
   import org.apache.ftpserver.interfaces.IConnectionManager;
   import org.apache.ftpserver.interfaces.IDataConnectionConfig;
  @@ -31,11 +34,8 @@
   import org.apache.ftpserver.interfaces.IIpRestrictor;
   import org.apache.ftpserver.interfaces.IMessageResource;
   import org.apache.ftpserver.interfaces.ISocketFactory;
  -import org.apache.ftpserver.logger.CompositeLogger;
   import org.apache.ftpserver.usermanager.BaseUser;
   
  -import java.net.InetAddress;
  -
   /**
    * FTP server configuration implementation. It holds all 
    * the components used.
  @@ -45,20 +45,19 @@
   public
   class FtpConfigImpl implements IFtpConfig {
   
  -    private final static Configuration EMPTY_CONF = new EmptyConfiguration();
  -    
  +    private LogFactory m_logFactory;
       private ISocketFactory m_socketFactory;
       private IDataConnectionConfig m_dataConConfig;
       private IMessageResource m_messageResource;
       private IConnectionManager m_connectionManager;
  -    private Logger m_logger;
       private IIpRestrictor m_ipRestrictor;
       private UserManager m_userManager;
       private FileSystemManager m_fileSystemManager;
       private FtpletContainer m_ftpletContainer;
  -    
       private IFtpStatistics m_statistics;
       
  +    private Log m_log;
  +    
       
       /**
        * Constructor - set the root configuration.
  @@ -67,8 +66,12 @@
           
           try {
               
  +            // get the log classes
  +            m_logFactory = LogFactory.getFactory();
  +            m_logFactory = new FtpLogFactory(m_logFactory);
  +            m_log        = m_logFactory.getInstance(FtpConfigImpl.class);
  +            
               // create all the components
  -            m_logger            = (Logger)                createComponent(conf, "logger",
             "org.apache.ftpserver.logger.FileLogger");
               m_socketFactory     = (ISocketFactory)        createComponent(conf, "socket-factory",
     "org.apache.ftpserver.socketfactory.FtpSocketFactory");
               m_dataConConfig     = (IDataConnectionConfig) createComponent(conf, "data-connection",
    "org.apache.ftpserver.DataConnectionConfig"); 
               m_messageResource   = (IMessageResource)      createComponent(conf, "message",
            "org.apache.ftpserver.message.MessageResourceImpl");
  @@ -78,11 +81,6 @@
               m_fileSystemManager = (FileSystemManager)     createComponent(conf, "file-system-manager",
"org.apache.ftpserver.filesystem.NativeFileSystemManager");
               m_statistics        = (IFtpStatistics)        createComponent(conf, "statistics",
         "org.apache.ftpserver.FtpStatisticsImpl");
               
  -            // create composite logger
  -            CompositeLogger logger = new CompositeLogger();
  -            logger.addLogger(m_logger);
  -            m_logger = logger;
  -            
               // create user if necessary
               boolean userCreate = conf.getBoolean("create-default-user", true);
               if(userCreate) {
  @@ -92,7 +90,7 @@
               // create and initialize ftlets
               m_ftpletContainer = new FtpletContainer();
               String ftpletNames = conf.getString("ftplets", null);
  -            Configuration ftpletConf = conf.getConfiguration("ftplet", EMPTY_CONF);
  +            Configuration ftpletConf = conf.getConfiguration("ftplet", EmptyConfiguration.INSTANCE);
               m_ftpletContainer.init(this, ftpletNames, ftpletConf);        
           }
           catch(Exception ex) {
  @@ -105,10 +103,10 @@
        * Create component. 
        */
       private Component createComponent(Configuration parentConfig, String configName, String
defaultClass) throws Exception {
  -        Configuration conf = parentConfig.getConfiguration(configName, EMPTY_CONF);
  +        Configuration conf = parentConfig.getConfiguration(configName, EmptyConfiguration.INSTANCE);
           String className = conf.getString("class", defaultClass);
           Component comp = (Component)Class.forName(className).newInstance();
  -        comp.setLogger(m_logger);
  +        comp.setLogFactory(m_logFactory);
           comp.configure(conf);
           return comp; 
       }
  @@ -122,7 +120,7 @@
           // create admin user
           String adminName = userManager.getAdminName();
           if(!userManager.doesExist(adminName)) {
  -            getLogger().info("Creating user : " + adminName);
  +            m_log.info("Creating user : " + adminName);
               BaseUser adminUser = new BaseUser();
               adminUser.setName(adminName);
               adminUser.setPassword(adminName);
  @@ -137,7 +135,7 @@
           
           // create anonymous user
           if(!userManager.doesExist("anonymous")) {
  -            getLogger().info("Creating user : anonymous");
  +            m_log.info("Creating user : anonymous");
               BaseUser anonUser = new BaseUser();
               anonUser.setName("anonymous");
               anonUser.setPassword("");
  @@ -152,6 +150,13 @@
       }
       
       /**
  +     * Get the log factory.
  +     */
  +    public LogFactory getLogFactory() {
  +        return m_logFactory;
  +    }
  +    
  +    /**
        * Get socket factory.
        */
       public ISocketFactory getSocketFactory() {
  @@ -171,13 +176,6 @@
       public IIpRestrictor getIpRestrictor() {
           return m_ipRestrictor;
       }
  -    
  -    /**
  -     * Get logger.
  -     */
  -    public Logger getLogger() {
  -        return m_logger;
  -    }
        
       /**
        * Get connection manager.
  @@ -287,10 +285,9 @@
               m_messageResource = null;
           }
           
  -        if(m_logger != null) {
  -            m_logger.info("Apache FTP Server stopped.");
  -            m_logger.dispose();
  -            m_logger = null;
  +        if(m_logFactory != null) {
  +            m_logFactory.release();
  +            m_logFactory = null;
           }
       }
   } 
  
  
  

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


Mime
View raw message