Interface Ftplet

All Known Implementing Classes:
DefaultFtplet

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 Details

    • 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 - If the initialization failed
    • 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:
      • FtpletResult.DEFAULT: The server continues as normal and executes the command
      • FtpletResult.NO_FTPLET: The server does not call any more Ftplets before this command but continues execution of the command as usual
      • FtpletResult.SKIP: The server skips over execution of the command. Note that the Ftplet is responsible for returning the appropriate reply to the client, or the client might deadlock.
      • FtpletResult.DISCONNECT: The server will immediately disconnect the client.
      • Ftplet throws exception: Same as FtpletResult.DISCONNECT
      Parameters:
      session - The current session
      request - The current request
      Returns:
      The desired action to be performed by the server
      Throws:
      FtpException - If a FTP error occurred
      IOException - If an IO error occurred
    • 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 - If a FTP error occurred
      IOException - If an IO error occurred
    • 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 - If a FTP error occurred
      IOException - If an IO error occurred
    • 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 - If a FTP error occurred
      IOException - If an IO error occurred