org.apache.ftpserver.ftplet
Interface Ftplet

All Known Subinterfaces:
FtpletContainer
All Known Implementing Classes:
DefaultFtplet, DefaultFtpletContainer, MyFtplet

public interface Ftplet

Defines methods that all ftplets must implement. A ftplet is a small Java program that runs within an FTP server. Ftplets receive and respond to requests from FTP clients. This interface defines methods to initialize a ftplet, to service requests, and to remove a ftplet from the server. These are known as life-cycle methods and are called in the following sequence:

  1. The ftplet is constructed.
  2. Then initialized with the init method.
  3. All the callback methods will be invoked.
  4. The ftplet is taken out of service, then destroyed with the destroy method.
  5. Then garbage collected and finalized.
All the callback methods return FtpletEnum. If it returns null FtpletEnum.DEFAULT will be assumed. If any ftplet callback method throws exception, that particular connection will be disconnected.

Author:
Apache MINA Project

Method Summary
 FtpletResult afterCommand(FtpSession session, FtpRequest request, FtpReply reply)
          Called by the ftplet container after a command has been executed by the server.
 FtpletResult beforeCommand(FtpSession session, FtpRequest request)
          Called by the ftplet container before a command is executed by the server.
 void destroy()
          Called by the Ftplet container to indicate to a ftplet that the ftplet is being taken out of service.
 void init(FtpletContext ftpletContext)
          Called by the ftplet container to indicate to a ftplet that the ftplet is being placed into service.
 FtpletResult onConnect(FtpSession session)
          Client connect notification method.
 FtpletResult onDisconnect(FtpSession session)
          Client disconnect notification method.
 

Method Detail

init

void init(FtpletContext ftpletContext)
          throws FtpException
Called by the ftplet container to indicate to a ftplet that the ftplet is being placed into service. The ftplet container calls the init method exactly once after instantiating the ftplet. The init method must complete successfully before the ftplet can receive any requests.

Parameters:
ftpletContext - The current FtpletContext
Throws:
FtpException

destroy

void destroy()
Called by the Ftplet container to indicate to a ftplet that the ftplet is being taken out of service. This method is only called once all threads within the ftplet's service method have exited. After the ftplet container calls this method, callback methods will not be executed. If the ftplet initialization method fails, this method will not be called.


beforeCommand

FtpletResult beforeCommand(FtpSession session,
                           FtpRequest request)
                           throws FtpException,
                                  IOException
Called by the ftplet container before a command is executed by the server. The implementation should return based on the desired action to be taken by the server:

Parameters:
session - The current session
request - The current request
Returns:
The desired action to be performed by the server
Throws:
FtpException
IOException

afterCommand

FtpletResult afterCommand(FtpSession session,
                          FtpRequest request,
                          FtpReply reply)
                          throws FtpException,
                                 IOException
Called by the ftplet container after a command has been executed by the server. The implementation should return based on the desired action to be taken by the server:

Parameters:
session - The current session
request - The current request
reply - the reply that was sent for this command. Implementations can use this to check the reply code and thus determine if the command was successfully processed or not.
Returns:
The desired action to be performed by the server
Throws:
FtpException
IOException

onConnect

FtpletResult onConnect(FtpSession session)
                       throws FtpException,
                              IOException
Client connect notification method.

Parameters:
session - The current FtpSession
Returns:
The desired action to be performed by the server
Throws:
FtpException
IOException

onDisconnect

FtpletResult onDisconnect(FtpSession session)
                          throws FtpException,
                                 IOException
Client disconnect notification method. This is the last callback method.

Parameters:
session - The current FtpSession
Returns:
The desired action to be performed by the server
Throws:
FtpException
IOException


Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.