Package org.apache.ftpserver.ftplet
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:
- The ftplet is constructed.
- Then initialized with the init method.
- All the callback methods will be invoked.
- The ftplet is taken out of service, then destroyed with the destroy method.
- Then garbage collected and finalized.
- Author:
- Apache MINA Project
-
Method Summary
Modifier and TypeMethodDescriptionafterCommand(FtpSession session, FtpRequest request, FtpReply reply) Called by the ftplet container after a command has been executed by the server.beforeCommand(FtpSession session, FtpRequest request) Called by the ftplet container before a command is executed by the server.voiddestroy()Called by the Ftplet container to indicate to a ftplet that the ftplet is being taken out of service.voidinit(FtpletContext ftpletContext) Called by the ftplet container to indicate to a ftplet that the ftplet is being placed into service.onConnect(FtpSession session) Client connect notification method.onDisconnect(FtpSession session) Client disconnect notification method.
-
Method Details
-
init
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 currentFtpletContext- 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
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 commandFtpletResult.NO_FTPLET: The server does not call any more Ftplets before this command but continues execution of the command as usualFtpletResult.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 sessionrequest- The current request- Returns:
- The desired action to be performed by the server
- Throws:
FtpException- If a FTP error occurredIOException- 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:FtpletResult.DEFAULT: The server continues as normalFtpletResult.NO_FTPLET: The server does not call any more Ftplets before this command but continues as normalFtpletResult.SKIP: Same asFtpletResult.DEFAULTFtpletResult.DISCONNECT: The server will immediately disconnect the client.- Ftplet throws exception: Same as
FtpletResult.DISCONNECT
- Parameters:
session- The current sessionrequest- The current requestreply- 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 occurredIOException- If an IO error occurred
-
onConnect
Client connect notification method.- Parameters:
session- The currentFtpSession- Returns:
- The desired action to be performed by the server
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-
onDisconnect
Client disconnect notification method. This is the last callback method.- Parameters:
session- The currentFtpSession- Returns:
- The desired action to be performed by the server
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-