avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ran...@apache.org
Subject cvs commit: jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver FtpServerImpl.java FtpConnection.java FtpConfig.java
Date Sun, 10 Mar 2002 06:08:21 GMT
rana_b      02/03/09 22:08:21

  Modified:    ftpserver/src/java/org/apache/avalon/ftpserver
                        FtpServerImpl.java FtpConnection.java
                        FtpConfig.java
  Log:
  properly disposing resources
  
  Revision  Changes    Path
  1.12      +11 -19    jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/FtpServerImpl.java
  
  Index: FtpServerImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/FtpServerImpl.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- FtpServerImpl.java	8 Mar 2002 06:33:54 -0000	1.11
  +++ FtpServerImpl.java	10 Mar 2002 06:08:21 -0000	1.12
  @@ -10,18 +10,21 @@
   import java.net.InetAddress;
   import java.net.ServerSocket;
   
  -
   import org.apache.avalon.ftpserver.interfaces.FtpServerInterface;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.component.ComponentManager;
  +
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  +
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.context.ContextException;
  +
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.activity.Disposable;
  +
   import org.apache.avalon.framework.component.Composable;
   import org.apache.avalon.framework.component.ComponentException;
   
  @@ -78,10 +81,6 @@
           }
           catch(Exception ex) {
               getLogger().error("FtpServerImpl.contextualize()", ex);
  -            ex.printStackTrace();
  -            if (mConfig != null) {
  -                mConfig.close();
  -            }
               throw new ContextException("FtpServerImpl.contextualize()", ex);
           }
       }
  @@ -100,10 +99,6 @@
           }
           catch(Exception ex) {
               getLogger().error("FtpServerImpl.compose()", ex);
  -            ex.printStackTrace();
  -            if (mConfig != null) {
  -                mConfig.close();
  -            }
               throw new ComponentException("FtpServerImpl.compose()", ex);
           }
       }
  @@ -136,10 +131,6 @@
          }
          catch(Exception ex) {
              getLogger().error("FtpServerImpl.configure()", ex);
  -           ex.printStackTrace();
  -           if (mConfig != null) {
  -               mConfig.close();
  -           }
              throw new ConfigurationException(ex.getMessage(), ex);
          }
       }
  @@ -149,12 +140,13 @@
        */        
       public void dispose() {
           getLogger().info("Closing Ftp server...");
  -        try {
  -            mServerSocket.close();
  -            mConfig.close();
  -        }
  -        catch(Exception ex) {
  -            getLogger().warn("FtpServerImpl.dispose()", ex);
  +        if (mConfig != null) {
  +            try {
  +                mConfig.dispose();
  +            }
  +            catch(Exception ex) {
  +                getLogger().warn("FtpServerImpl.dispose()", ex);
  +            }
           }
       }
   
  
  
  
  1.9       +6 -14     jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/FtpConnection.java
  
  Index: FtpConnection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/FtpConnection.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- FtpConnection.java	8 Mar 2002 06:36:00 -0000	1.8
  +++ FtpConnection.java	10 Mar 2002 06:08:21 -0000	1.9
  @@ -66,7 +66,7 @@
       private FtpConfig mCfg                  = null;
       private FtpStatus mFtpStatus            = null;
       private FtpDataConnection mDataCon      = null;
  -    private Socket mControlSoc              = null;
  +    public Socket mControlSoc              = null;
       private FtpUser mUser                   = null;
       private SpyConnectionInterface mSpy     = null;
       private FtpConnectionObserver mObserver = null;
  @@ -176,9 +176,9 @@
        */
       private void execute(FtpRequest request, Writer out) throws FtpException, IOException
{
           try {
  -             String metName = "do" + request.getCommand();
  -             Method actionMet = getClass().getDeclaredMethod(metName, new Class[] {FtpRequest.class,
Writer.class});
  -             actionMet.invoke(this, new Object[] {request, out});
  +             String methodName = "do" + request.getCommand();
  +             Method actionMethod = getClass().getDeclaredMethod(methodName, METHOD_INPUT_SIG);
  +             actionMethod.invoke(this, new Object[] {request, out});
            }
            catch(NoSuchMethodException ex) {
                write(out, mFtpStatus.getResponse(502, request, mUser, null));
  @@ -359,15 +359,7 @@
       public void dataTransferred(int sz) {
            notifyObserver();
       }
  -    
  -    /**
  -     * Last defense to logout and close.
  -     */
  -    protected void finalize() throws Throwable {
  -        stop();
  -        super.finalize();
  -    }
  -     
  +         
   
       ////////////////////////////////////////////////////////////
       /////////////////   all the FTP handlers   /////////////////
  @@ -1230,7 +1222,7 @@
        */
       protected void doSTAT(FtpRequest request, Writer out) throws FtpException, IOException
{
           String args[] = {
  -           mCfg.getServerAddress().getHostAddress(),
  +           mCfg.getSelfAddress().getHostAddress(),
              mControlSoc.getInetAddress().getHostAddress(),
              mUser.getName()
           };
  
  
  
  1.12      +5 -17     jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/FtpConfig.java
  
  Index: FtpConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/FtpConfig.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- FtpConfig.java	8 Mar 2002 06:37:12 -0000	1.11
  +++ FtpConfig.java	10 Mar 2002 06:08:21 -0000	1.12
  @@ -56,6 +56,7 @@
       
       private InetAddress mServerAddress          = null;
       private InetAddress mSelfAddress            = null;
  +    
       private Configuration mConf                 = null;
       private BlockContext mContext               = null;
       private Logger mLogger                      = null;
  @@ -366,23 +367,17 @@
        * Close this config and all the related resources. Ftp server
        * <code>FtpServer.stop()</code> method will call this method.
        */
  -    public void close() {
  +    public void dispose() {
            
            // close remote handler
            if (mRemoteHandler != null) {
  -            mRemoteHandler.close();
  +            mRemoteHandler.dispose();
               mRemoteHandler = null;
            }
            
  -         // close user manager
  -         if (mUserManager != null) {
  -             mUserManager.close();
  -             mUserManager = null;
  -         }
  -         
            // close connection service
            if(mConService != null) {
  -             mConService.close();
  +             mConService.dispose();
                mConService = null;
            }
            
  @@ -392,14 +387,7 @@
                mMsgQ = null;
            }
       }
  -    
  -    /**
  -     * Last defense
  -     */
  -    public void finalize() throws Throwable {
  -        close();
  -        super.finalize();
  -    } 
  +
   }
   
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message